Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-02-11 18:48:57 +0000
committerJohn Arthorne2009-02-11 18:48:57 +0000
commit2d8d70c861f269d77bcb8270c580688f6bbd8d50 (patch)
treebce7344211ea79cd2fcf514c7060a1c0126aa839 /bundles
parent3178fed49d4fd3097a350284f4be10e660f769ed (diff)
downloadrt.equinox.p2-2d8d70c861f269d77bcb8270c580688f6bbd8d50.tar.gz
rt.equinox.p2-2d8d70c861f269d77bcb8270c580688f6bbd8d50.tar.xz
rt.equinox.p2-2d8d70c861f269d77bcb8270c580688f6bbd8d50.zip
Bug 264111 NPE in SimpleArtifactRepositoryFactory
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/artifact/repository/SimpleArtifactRepositoryFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java22
6 files changed, 27 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
index 60e12f695..020228ba9 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepositoryFactory.java
@@ -43,9 +43,9 @@ public class CompositeArtifactRepositoryFactory extends ArtifactRepositoryFactor
boolean compress = true;
if (PROTOCOL_FILE.equals(location.getScheme())) {
local = true;
- localFile = new File(CompositeArtifactRepository.getActualLocation(location, true).getPath());
+ localFile = URIUtil.toFile(CompositeArtifactRepository.getActualLocation(location, true));
if (!localFile.exists()) {
- localFile = new File(CompositeArtifactRepository.getActualLocation(location, false).getPath());
+ localFile = URIUtil.toFile(CompositeArtifactRepository.getActualLocation(location, false));
compress = false;
}
} else {
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
index d518b503f..f4eb22736 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/Messages.java
@@ -22,6 +22,7 @@ public class Messages extends NLS {
public static String io_failedRead;
public static String ecf_configuration_error;
public static String io_incompatibleVersion;
+ public static String io_invalidLocation;
public static String SignatureVerification_failedRead;
public static String SignatureVerification_invalidContent;
public static String SignatureVerification_invalidFileContent;
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
index 832a8c018..30333f5a3 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/messages.properties
@@ -19,6 +19,7 @@ io_parseError=\
ecf_configuration_error=Transport initialization error.
io_incompatibleVersion=\
Simple artifact repository has incompatible version {0}; expected {1}.
+io_invalidLocation=Invalid repository location: {0}
mirroring=Mirroring:
repoFailedWrite=Unable to write to repository: {0}.
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 672549529..49d3c43ef 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -20,7 +20,8 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5Verifier;
import org.eclipse.equinox.internal.p2.artifact.repository.*;
import org.eclipse.equinox.internal.p2.artifact.repository.Messages;
-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.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -217,11 +218,11 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
}
- public static URI getActualLocation(URI base, boolean compress) {
+ public static URI getActualLocation(URI base, boolean compress) throws IOException {
return getActualLocation(base, compress ? JAR_EXTENSION : XML_EXTENSION);
}
- private static URI getActualLocation(URI base, String extension) {
+ private static URI getActualLocation(URI base, String extension) throws IOException {
final String name = CONTENT_FILENAME + extension;
String spec = base.toString();
if (spec.endsWith(name))
@@ -233,7 +234,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
try {
return new URI(spec);
} catch (URISyntaxException e) {
- return null;
+ throw new IOException(NLS.bind(Messages.io_invalidLocation, spec));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/artifact/repository/SimpleArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/artifact/repository/SimpleArtifactRepositoryFactory.java
index 93d4a3dbd..bc9a9439d 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/artifact/repository/SimpleArtifactRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/artifact/repository/SimpleArtifactRepositoryFactory.java
@@ -43,9 +43,9 @@ public class SimpleArtifactRepositoryFactory extends ArtifactRepositoryFactory {
boolean compress = true;
if (PROTOCOL_FILE.equals(location.getScheme())) {
local = true;
- localFile = new File(SimpleArtifactRepository.getActualLocation(location, true).getPath());
+ localFile = URIUtil.toFile(SimpleArtifactRepository.getActualLocation(location, true));
if (!localFile.exists()) {
- localFile = new File(SimpleArtifactRepository.getActualLocation(location, false).getPath());
+ localFile = URIUtil.toFile(SimpleArtifactRepository.getActualLocation(location, false));
compress = false;
}
} else {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
index 4d09dec6d..f368deb49 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
@@ -45,32 +45,32 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
}
}
- public void testGetActualLocation1() throws URISyntaxException {
+ public void testGetActualLocation1() throws Exception {
URI base = new URI("http://localhost/artifactRepository");
assertEquals(new URI(base + "/artifacts.xml"), SimpleArtifactRepository.getActualLocation(base, false));
}
- public void testGetActualLocation2() throws URISyntaxException {
+ public void testGetActualLocation2() throws Exception {
URI base = new URI("http://localhost/artifactRepository/");
assertEquals(new URI(base + "artifacts.xml"), SimpleArtifactRepository.getActualLocation(base, false));
}
- public void testGetActualLocation3() throws URISyntaxException {
+ public void testGetActualLocation3() throws Exception {
URI base = new URI("http://localhost/artifactRepository/artifacts.xml");
assertEquals(base, SimpleArtifactRepository.getActualLocation(base, false));
}
- public void testGetActualLocationCompressed1() throws URISyntaxException {
+ public void testGetActualLocationCompressed1() throws Exception {
URI base = new URI("http://localhost/artifactRepository");
assertEquals(new URI(base + "/artifacts.jar"), SimpleArtifactRepository.getActualLocation(base, true));
}
- public void testGetActualLocationCompressed2() throws URISyntaxException {
+ public void testGetActualLocationCompressed2() throws Exception {
URI base = new URI("http://localhost/artifactRepository/");
assertEquals(new URI(base + "artifacts.jar"), SimpleArtifactRepository.getActualLocation(base, true));
}
- public void testGetActualLocationCompressed3() throws URISyntaxException {
+ public void testGetActualLocationCompressed3() throws Exception {
URI base = new URI("http://localhost/artifactRepository/artifacts.jar");
assertEquals(base, SimpleArtifactRepository.getActualLocation(base, true));
}
@@ -141,6 +141,16 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Repository should create artifact.xml");
}
+ public void testLoadInvalidLocation() {
+ try {
+ getArtifactRepositoryManager().loadRepository(new URI("file:d:/foo"), getMonitor());
+ } catch (ProvisionException e) {
+ //expected
+ } catch (URISyntaxException e) {
+ fail("4.99", e);
+ }
+ }
+
public void test_248772() {
SimpleArtifactRepositoryFactory factory = new SimpleArtifactRepositoryFactory();
URI location = null;

Back to the top