Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2017-04-06 21:30:04 +0000
committerKarsten Thoms2017-06-27 08:09:46 +0000
commitff12ff963d3657c29884b15baa1f105c8a09ac77 (patch)
tree18ddbb6b9b6f80a98598846e55ce8577f466c0aa
parentb1b14d5061eb7a9ae592fbd71a2437bfb5d86ba3 (diff)
downloadrt.equinox.p2-ff12ff963d3657c29884b15baa1f105c8a09ac77.tar.gz
rt.equinox.p2-ff12ff963d3657c29884b15baa1f105c8a09ac77.tar.xz
rt.equinox.p2-ff12ff963d3657c29884b15baa1f105c8a09ac77.zip
Bug 514885 Pooling Version and VersionRange
- Introduce weak object pool for Verson and VersionRange - Use VersionRange.create() for getting pooled instances - JavaDoc & check input for empty string Change-Id: Ie42bdc1059d8c667af312038c26c035a6ef674af Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstructionParser.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/TouchpointManager.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ArtifactDescription.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java2
15 files changed, 80 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
index d0ddc77a5..c6a71deea 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvCommandProvider.java
@@ -81,7 +81,7 @@ public class ProvCommandProvider implements CommandProvider {
if (ProvisioningHelper.addMetadataRepository(agent, repoURI) == null) {
interpreter.println("Unable to add metadata repository: " + repoURI);
} else // add artifact repo at same URL
- if (ProvisioningHelper.addArtifactRepository(agent, repoURI) == null) {
+ if (ProvisioningHelper.addArtifactRepository(agent, repoURI) == null) {
interpreter.println("Unable to add artifact repository: " + repoURI);
}
}
@@ -248,7 +248,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoURL = null;
if (urlString != null && !urlString.equals(WILDCARD_ANY))
repoURL = toURI(interpreter, urlString);
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, QueryUtil.createIUQuery(id, new VersionRange(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoURL, QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
@@ -303,7 +303,7 @@ public class ProvCommandProvider implements CommandProvider {
URI repoLocation = toURI(interpreter, urlString);
if (repoLocation == null)
return;
- IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, QueryUtil.createIUQuery(id, new VersionRange(version)), null));
+ IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, QueryUtil.createIUQuery(id, VersionRange.create(version)), null));
for (int i = 0; i < units.length; i++)
println(interpreter, units[i]);
}
@@ -434,7 +434,7 @@ public class ProvCommandProvider implements CommandProvider {
}
// list the profile contents
- IInstallableUnit[] result = sort(target.query(QueryUtil.createIUQuery(id, new VersionRange(range)), null));
+ IInstallableUnit[] result = sort(target.query(QueryUtil.createIUQuery(id, VersionRange.create(range)), null));
for (int i = 0; i < result.length; i++)
interpreter.println(result[i]);
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstructionParser.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstructionParser.java
index 2b9709d20..5aae66b40 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstructionParser.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/InstructionParser.java
@@ -62,7 +62,7 @@ public class InstructionParser {
while (actionTokenizer.hasMoreTokens()) {
String actionAttribute = actionTokenizer.nextToken().trim();
if (actionAttribute.startsWith(VERSION_EQUALS))
- actionVersionRange = new VersionRange(actionAttribute.substring(VERSION_EQUALS.length() + 1));
+ actionVersionRange = VersionRange.create(actionAttribute.substring(VERSION_EQUALS.length() + 1));
}
result.put(actionKey, new ActionEntry(actionId, actionVersionRange));
result.put(actionId, new ActionEntry(actionId, actionVersionRange));
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index 5e91fd6e0..e8ae44844 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -643,7 +643,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
return false;
//check whether the profile contains the p2 engine from 3.5.0 or earlier
- return profile.available(QueryUtil.createIUQuery("org.eclipse.equinox.p2.engine", new VersionRange("[0.0.0, 1.0.101)")), null).isEmpty(); //$NON-NLS-1$//$NON-NLS-2$
+ return profile.available(QueryUtil.createIUQuery("org.eclipse.equinox.p2.engine", VersionRange.create("[0.0.0, 1.0.101)")), null).isEmpty(); //$NON-NLS-1$//$NON-NLS-2$
}
private void deleteProfile(String profileId) {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/TouchpointManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/TouchpointManager.java
index 1775eeee5..bca1a6e8e 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/TouchpointManager.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/TouchpointManager.java
@@ -118,7 +118,7 @@ public class TouchpointManager implements IRegistryChangeListener {
if (entry == null)
return null;
if (versionRange != null) {
- VersionRange range = new VersionRange(versionRange);
+ VersionRange range = VersionRange.create(versionRange);
if (!range.isIncluded(entry.getVersion()))
return null;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
index f0f808f4d..e761144e8 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
@@ -20,9 +20,7 @@ import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.persistence.XMLParser;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitPatchDescription;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.*;
import org.eclipse.equinox.p2.metadata.expression.*;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
@@ -286,7 +284,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
continue;
}
if (key.equals("equinox.p2.update.range")) { //$NON-NLS-1$
- updateRange = new VersionRange(value);
+ updateRange = VersionRange.create(value);
continue;
}
//End of backward compatibility
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java
index fecd7d209..09d241253 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RangeFunction.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.expression;
-
import org.eclipse.equinox.p2.metadata.VersionRange;
/**
@@ -27,7 +26,7 @@ public final class RangeFunction extends Function {
}
Object createInstance(Object arg) {
- return new VersionRange((String) arg);
+ return VersionRange.create((String) arg);
}
public String getOperator() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java
index 282637572..c24b8cb2f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/Version.java
@@ -12,6 +12,8 @@
package org.eclipse.equinox.p2.metadata;
import java.io.Serializable;
+import java.lang.ref.SoftReference;
+import java.util.WeakHashMap;
import org.eclipse.equinox.internal.p2.metadata.*;
/**
@@ -40,6 +42,7 @@ import org.eclipse.equinox.internal.p2.metadata.*;
*/
public abstract class Version implements Comparable<Version>, Serializable {
public static final String RAW_PREFIX = "raw:"; //$NON-NLS-1$
+ private static WeakHashMap<String, SoftReference<Version>> POOL = new WeakHashMap<String, SoftReference<Version>>();
/**
* The version that is semantically greater then all other versions.
@@ -66,6 +69,12 @@ public abstract class Version implements Comparable<Version>, Serializable {
/**
* Parses a version identifier from the specified string.
+ * <p>
+ * Note that this method performs a non thread-safe object pooling. Instances are
+ * stored in a weak cache, i.e. for multiple calls with the same input it is likely
+ * but not guaranteed that the same instance is retrieved. Same holds for concurrent
+ * access on this method. Clients must not assume to get the same instance for
+ * subsequent calls.
*
* @param version String representation of the version identifier. Leading
* and trailing whitespace will be ignored.
@@ -76,7 +85,18 @@ public abstract class Version implements Comparable<Version>, Serializable {
* formatted.
*/
public static Version create(String version) {
- return version == null ? null : VersionParser.parse(version, 0, version.length());
+ Version v = null;
+ if (version != null && version.length() > 0) {
+ SoftReference<Version> vRef = POOL.get(version);
+ v = vRef != null ? vRef.get() : null;
+ if (v == null) {
+ v = VersionParser.parse(version, 0, version.length());
+ synchronized (POOL) {
+ POOL.put(version, new SoftReference<Version>(v));
+ }
+ }
+ }
+ return v;
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java
index 34d3d81b5..6b017245d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/VersionRange.java
@@ -12,6 +12,8 @@
package org.eclipse.equinox.p2.metadata;
import java.io.Serializable;
+import java.lang.ref.SoftReference;
+import java.util.WeakHashMap;
import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.osgi.util.NLS;
@@ -34,6 +36,7 @@ public class VersionRange implements Serializable {
* An empty OSGi Version range.
*/
public static final VersionRange emptyRange = new VersionRange(Version.emptyVersion, true, Version.MAX_VERSION, true);
+ private static WeakHashMap<String, SoftReference<VersionRange>> POOL = new WeakHashMap<String, SoftReference<VersionRange>>();
private final Version minVersion;
private final boolean includeMin;
@@ -252,6 +255,39 @@ public class VersionRange implements Serializable {
validateRange();
}
+ /**
+ * Parses a version range from the specified string.
+ * <p>
+ * Note that this method performs a non thread-safe object pooling. Instances are
+ * stored in a weak cache, i.e. for multiple calls with the same input it is likely
+ * but not guaranteed that the same instance is retrieved. Same holds for concurrent
+ * access on this method. Clients must not assume to get the same instance for
+ * subsequent calls.
+ *
+ * @param versionRange String representation of the version range. Leading
+ * and trailing whitespace will be ignored.
+ * @return A <code>VersionRange</code> object representing the version range
+ * or <code>null</code> if <code>versionRange</code> is <code>null</code> or
+ * an empty string.
+ * @throws IllegalArgumentException If <code>versionRange</code> is improperly
+ * formatted.
+ * @since 2.3
+ */
+ public static VersionRange create(String versionRange) {
+ VersionRange v = null;
+ if (versionRange != null && versionRange.length() > 0) {
+ SoftReference<VersionRange> vRef = POOL.get(versionRange);
+ v = vRef != null ? vRef.get() : null;
+ if (v == null) {
+ v = new VersionRange(versionRange);
+ synchronized (POOL) {
+ POOL.put(versionRange, new SoftReference<VersionRange>(v));
+ }
+ }
+ }
+ return v;
+ }
+
private static IVersionFormat parseFormat(String versionRange, int[] position) {
int pos = VersionParser.skipWhite(versionRange, position[0]);
if (!versionRange.startsWith("format(", pos)) //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
index 955bf2ff1..30fa51335 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java
@@ -189,7 +189,7 @@ public class FeatureManifestParser extends DefaultHandler {
String versionStr = attributes.getValue("version"); //$NON-NLS-1$
FeatureEntry entry = null;
if ("versionRange".equals(attributes.getValue("match"))) { //$NON-NLS-1$//$NON-NLS-2$
- VersionRange versionRange = new VersionRange(versionStr);
+ VersionRange versionRange = VersionRange.create(versionStr);
entry = FeatureEntry.createRequires(id, versionRange, attributes.getValue("match"), attributes.getValue("filter"), isPlugin); //$NON-NLS-1$ //$NON-NLS-2$
} else {
entry = FeatureEntry.createRequires(id, versionStr, attributes.getValue("match"), attributes.getValue("filter"), isPlugin); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
index 6bda1aeea..d5cf86b02 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
@@ -16,8 +16,9 @@ import java.net.URISyntaxException;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.*;
+import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.publisher.FileSetDescriptor;
@@ -560,7 +561,7 @@ public class FeaturesAction extends AbstractPublisherAction {
return VersionRange.emptyRange;
String match = entry.getMatch();
if ("versionRange".equals(match)) //$NON-NLS-1$
- return new VersionRange(versionSpec);
+ return VersionRange.create(versionSpec);
Version version = Version.parseVersion(versionSpec);
if (version.equals(Version.emptyVersion))
return VersionRange.emptyRange;
@@ -582,7 +583,7 @@ public class FeaturesAction extends AbstractPublisherAction {
return new VersionRange(version, true, upper, false);
}
if (match.equals("greaterOrEqual")) //$NON-NLS-1$
- return new VersionRange(version, true, new VersionRange(null).getMaximum(), true);
+ return new VersionRange(version, true, VersionRange.create(null).getMaximum(), true);
return null;
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
index ad445e9e6..652367d36 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
@@ -199,7 +199,7 @@ public class AdviceFileParser {
return MetadataFactory.createUpdateDescriptor(descriptors, Integer.valueOf(severity), description, (URI) null);
}
range = substituteVersionAndQualifier(range);
- VersionRange versionRange = new VersionRange(range);
+ VersionRange versionRange = VersionRange.create(range);
return MetadataFactory.createUpdateDescriptor(name, versionRange, Integer.valueOf(severity), description);
}
@@ -274,7 +274,7 @@ public class AdviceFileParser {
} else if (token.equals(NAMESPACE)) {
namespace = currentValue();
} else if (token.equals(RANGE)) {
- range = new VersionRange(substituteVersionAndQualifier(currentValue()));
+ range = VersionRange.create(substituteVersionAndQualifier(currentValue()));
} else if (token.equals(MIN)) {
min = Integer.valueOf(currentValue()).intValue();
} else if (token.equals(MAX)) {
@@ -416,7 +416,7 @@ public class AdviceFileParser {
unitUpdateId = currentValue();
next();
} else if (token.equals(UPDATE_RANGE)) {
- unitUpdateRange = new VersionRange(substituteVersionAndQualifier(currentValue()));
+ unitUpdateRange = VersionRange.create(substituteVersionAndQualifier(currentValue()));
next();
} else if (token.equals(UPDATE_SEVERITY)) {
unitUpdateSeverity = Integer.parseInt(currentValue());
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
index 8d25ad08a..bb40705ad 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
@@ -292,7 +292,7 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
sourceIUs = new ArrayList<IInstallableUnit>();
for (int i = 0; i < rootIUs.length; i++) {
String[] segments = getArrayArgsFromString(rootIUs[i], "/"); //$NON-NLS-1$
- VersionRange range = segments.length > 1 ? new VersionRange(segments[1]) : null;
+ VersionRange range = segments.length > 1 ? VersionRange.create(segments[1]) : null;
Iterator<IInstallableUnit> queryResult = metadataRepo.query(QueryUtil.createIUQuery(segments[0], range), null).iterator();
while (queryResult.hasNext())
sourceIUs.add(queryResult.next());
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ArtifactDescription.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ArtifactDescription.java
index 9ff4e3d9d..a672f38e6 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ArtifactDescription.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ArtifactDescription.java
@@ -64,7 +64,7 @@ public class ArtifactDescription extends DataType {
public IQuery<IArtifactKey> createKeyQuery() {
VersionRange keyRange = null;
if (range != null)
- keyRange = new VersionRange(range);
+ keyRange = VersionRange.create(range);
else if (version != null) {
Version keyVersion = Version.parseVersion(version);
keyRange = new VersionRange(keyVersion, true, keyVersion, true);
@@ -75,7 +75,7 @@ public class ArtifactDescription extends DataType {
public IQuery<IArtifactDescriptor> createDescriptorQuery() {
VersionRange keyRange = null;
if (range != null)
- keyRange = new VersionRange(range);
+ keyRange = VersionRange.create(range);
else if (version != null) {
Version keyVersion = Version.parseVersion(version);
keyRange = new VersionRange(keyVersion, true, keyVersion, true);
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
index abc7032fa..fb0570f27 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
@@ -689,7 +689,7 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
public VersionRange checkVersionRange(String element, String attribute, String value) {
try {
if (value != null)
- return new VersionRange(value);
+ return VersionRange.create(value);
} catch (IllegalArgumentException iae) {
invalidAttributeValue(element, attribute, value);
} catch (NullPointerException npe) {
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index 0f0ee0427..28c70f501 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -272,7 +272,7 @@ public class SiteXMLAction extends AbstractPublisherAction {
return Collections.<IInstallableUnit> emptyList();
IQuery<IInstallableUnit> query = null;
if (id != null) {
- VersionRange vRange = new VersionRange(range);
+ VersionRange vRange = VersionRange.create(range);
query = QueryUtil.createIUQuery(id, vRange);
} else if (type.equals("context")) { //$NON-NLS-1$
query = QueryUtil.createQuery(expression, params);

Back to the top