Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Wellmann2021-08-29 15:15:15 -0400
committerAlexander Kurtakov2021-09-08 02:59:52 -0400
commit3605054fbf1427cf927581d82a7d818130afeb10 (patch)
tree67df26dd2afdd4f55e17ff7c2655662d432d7c78
parent1611eb739f960a5279f5d621ead7c178cc7a81a4 (diff)
downloadrt.equinox.p2-I20210908-1800.tar.gz
rt.equinox.p2-I20210908-1800.tar.xz
rt.equinox.p2-I20210908-1800.zip
Bug 575699 - Simplify/avoid creation of EnumerationsI20210908-1800
Change-Id: I8baac46b7b34a270b0e5d72d426534bd92eee7c0 Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.p2/+/184748 Tested-by: Equinox Bot <equinox-bot@eclipse.org> Tested-by: Alexander Kurtakov <akurtako@redhat.com> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.core/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Memento.java14
7 files changed, 16 insertions, 42 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
index 19cf0c2f6..fdd4ec76f 100644
--- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.core;singleton:=true
-Bundle-Version: 2.8.0.qualifier
+Bundle-Version: 2.8.100.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.equinox.internal.p2.core.Activator
Bundle-Vendor: %providerName
diff --git a/bundles/org.eclipse.equinox.p2.core/pom.xml b/bundles/org.eclipse.equinox.p2.core/pom.xml
index e1ca1fe6d..57357f7af 100644
--- a/bundles/org.eclipse.equinox.p2.core/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.core/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.core</artifactId>
- <version>2.8.0-SNAPSHOT</version>
+ <version>2.8.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
index f97d822e7..1c48c0742 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/FileUtils.java
@@ -25,8 +25,7 @@ public class FileUtils {
private static File[] untarFile(File source, File outputDir) throws IOException, TarException {
List<File> untarredFiles = new ArrayList<>();
try (TarFile tarFile = new TarFile(source)) {
- for (Enumeration<TarEntry> e = tarFile.entries(); e.hasMoreElements();) {
- TarEntry entry = e.nextElement();
+ for (TarEntry entry : tarFile.entries()) {
try (InputStream input = tarFile.getInputStream(entry)) {
File outFile = createSubPathFile(outputDir, entry.getName());
outFile = outFile.getCanonicalFile(); //bug 266844
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
index 567be31af..e8ccb6cd0 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/helpers/TarFile.java
@@ -14,7 +14,8 @@
package org.eclipse.equinox.internal.p2.core.helpers;
import java.io.*;
-import java.util.Enumeration;
+import java.util.Objects;
+import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
/**
@@ -23,9 +24,7 @@ import java.util.zip.GZIPInputStream;
public class TarFile implements Closeable {
private File file;
private TarInputStream entryEnumerationStream;
- private TarEntry curEntry;
private TarInputStream entryStream;
-
private InputStream internalEntryStream;
/**
@@ -54,7 +53,6 @@ public class TarFile implements Closeable {
in.close();
throw ex;
}
- curEntry = entryEnumerationStream.getNextEntry();
}
/**
@@ -74,26 +72,15 @@ public class TarFile implements Closeable {
*
* @return enumeration of all files in the archive
*/
- public Enumeration<TarEntry> entries() {
- return new Enumeration<>() {
- @Override
- public boolean hasMoreElements() {
- return (curEntry != null);
- }
-
- @Override
- public TarEntry nextElement() {
- TarEntry oldEntry = curEntry;
- try {
- curEntry = entryEnumerationStream.getNextEntry();
- } catch (TarException e) {
- curEntry = null;
- } catch (IOException e) {
- curEntry = null;
- }
- return oldEntry;
+ public Iterable<TarEntry> entries() throws TarException, IOException {
+ TarEntry first = entryEnumerationStream.getNextEntry(); // throws if stream is empty
+ return Stream.iterate(first, Objects::nonNull, e -> {
+ try {
+ return entryEnumerationStream.getNextEntry();
+ } catch (TarException | IOException e1) {
+ return null;
}
- };
+ })::iterator;
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
index 83eacd2af..72d1dac18 100644
--- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.engine;singleton:=true
-Bundle-Version: 2.7.100.qualifier
+Bundle-Version: 2.7.200.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.engine.EngineActivator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.p2.engine/pom.xml b/bundles/org.eclipse.equinox.p2.engine/pom.xml
index 45e469344..d96856da2 100644
--- a/bundles/org.eclipse.equinox.p2.engine/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.engine/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.engine</artifactId>
- <version>2.7.100-SNAPSHOT</version>
+ <version>2.7.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Memento.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Memento.java
index cab39fdfe..eb82f08d8 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Memento.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/spi/Memento.java
@@ -51,19 +51,7 @@ public final class Memento {
}
public Enumeration<String> getKeys() {
- return new Enumeration<>() {
- Iterator<String> keysIterator = mementoMap.keySet().iterator();
-
- @Override
- public boolean hasMoreElements() {
- return keysIterator.hasNext();
- }
-
- @Override
- public String nextElement() {
- return keysIterator.next();
- }
- };
+ return Collections.enumeration(mementoMap.keySet());
}
private static void validateValue(Object value) {

Back to the top