Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2010-08-25 19:16:33 +0000
committerDJ Houghton2010-08-25 19:16:33 +0000
commita88270cc04812279fe5831da4696ee3b45565feb (patch)
tree4710f07d873076908c1d5d3e7c27f3c53212d192 /bundles/org.eclipse.equinox.p2.reconciler.dropins
parentb9bdbd19204348b00d80f1003392d7f3679fb27e (diff)
downloadrt.equinox.p2-a88270cc04812279fe5831da4696ee3b45565feb.tar.gz
rt.equinox.p2-a88270cc04812279fe5831da4696ee3b45565feb.tar.xz
rt.equinox.p2-a88270cc04812279fe5831da4696ee3b45565feb.zip
Bug 288759 - [reconciler] eclipse will always report null point error when a non-existing path is used for links
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.reconciler.dropins')
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java54
2 files changed, 48 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
index da9120463..3894dc184 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/Activator.java
@@ -18,6 +18,7 @@ import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryMan
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.p2.extensionlocation.*;
import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
+import org.eclipse.equinox.internal.p2.reconciler.dropins.DropinsRepositoryListener.LinkedRepository;
import org.eclipse.equinox.internal.p2.update.Configuration;
import org.eclipse.equinox.internal.p2.update.PathUtil;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher;
@@ -357,9 +358,10 @@ public class Activator implements BundleActivator {
File child = children[inner];
if (child.isFile() && child.getName().toLowerCase().endsWith(EXT_LINK)) {
// if we have a link file then add the link file and its target
- File target = DropinsRepositoryListener.getLinkedFile(child);
- if (target == null || !target.exists())
+ LinkedRepository repo = DropinsRepositoryListener.getLinkedRepository(child);
+ if (repo == null || !repo.exists())
continue;
+ File target = repo.getLocation();
result.add(child);
result.add(target);
File eclipse = new File(target, DIR_ECLIPSE);
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
index ddf584ff0..642c7f0d2 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.reconciler.dropins;
-import org.eclipse.equinox.p2.query.QueryUtil;
-
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -28,6 +26,7 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
@@ -43,6 +42,7 @@ public class DropinsRepositoryListener extends RepositoryListener {
private static final String LINK = ".link"; //$NON-NLS-1$
private static final String ZIP = ".zip"; //$NON-NLS-1$
private static final String LINKS_PATH = "path"; //$NON-NLS-1$
+ private static final String LINK_IS_OPTIONAL = "optional"; //$NON-NLS-1$
private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories"; //$NON-NLS-1$
private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories"; //$NON-NLS-1$
private static final String PIPE = "|"; //$NON-NLS-1$
@@ -50,6 +50,34 @@ public class DropinsRepositoryListener extends RepositoryListener {
private List<IMetadataRepository> metadataRepositories = new ArrayList<IMetadataRepository>();
private List<IArtifactRepository> artifactRepositories = new ArrayList<IArtifactRepository>();
+ static class LinkedRepository {
+ LinkedRepository(File location) {
+ super();
+ if (location == null)
+ throw new IllegalArgumentException("Repository location cannot be null."); //$NON-NLS-1$
+ this.location = location;
+ }
+
+ boolean exists() {
+ return location.exists();
+ }
+
+ File getLocation() {
+ return location;
+ }
+
+ boolean isOptional() {
+ return optional;
+ }
+
+ void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ private File location;
+ private boolean optional = false;
+ }
+
public DropinsRepositoryListener(IProvisioningAgent agent, String repositoryName) {
super(repositoryName, true);
this.agent = agent;
@@ -81,6 +109,8 @@ public class DropinsRepositoryListener extends RepositoryListener {
private void addRepository(File file) {
URI repoLocation = createRepositoryLocation(file);
+ if (repoLocation == null)
+ return;
Map<String, String> properties = new HashMap<String, String>();
// if the file pointed to a link file, keep track of the attribute
// so we can add it to the repo later
@@ -89,17 +119,15 @@ public class DropinsRepositoryListener extends RepositoryListener {
if (linkLocation != null)
properties.put(Site.PROP_LINK_FILE, file.getAbsolutePath());
}
- if (repoLocation != null) {
- getMetadataRepository(repoLocation, properties);
- getArtifactRepository(repoLocation, properties);
- }
+ getMetadataRepository(repoLocation, properties);
+ getArtifactRepository(repoLocation, properties);
}
/*
* Return the file pointed to by the given link file. Return null if there is a problem
* reading the file or resolving the location.
*/
- static File getLinkedFile(File file) {
+ static LinkedRepository getLinkedRepository(File file) {
Properties links = new Properties();
try {
InputStream input = new BufferedInputStream(new FileInputStream(file));
@@ -133,7 +161,13 @@ public class DropinsRepositoryListener extends RepositoryListener {
linkedFile = new File(root, path);
}
try {
- return linkedFile.getCanonicalFile();
+ LinkedRepository result = new LinkedRepository(linkedFile.getCanonicalFile());
+ // Check if the link target is marked as optional.
+ // If link is optional, then the link target may not exist.
+ // So IF link is marked as optional AND does not exist, simply ignore it.
+ String optional = links.getProperty(LINK_IS_OPTIONAL);
+ result.setOptional(Boolean.valueOf(optional).booleanValue());
+ return result;
} catch (IOException e) {
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_resolving_link, linkedFile.getAbsolutePath(), file.getAbsolutePath()), e));
return null;
@@ -179,13 +213,13 @@ public class DropinsRepositoryListener extends RepositoryListener {
}
private URI getLinkRepository(File file, boolean logMissingLink) {
- File repo = getLinkedFile(file);
+ LinkedRepository repo = getLinkedRepository(file);
if (repo == null) {
if (logMissingLink)
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Unable to determine link location from file: " + file.getAbsolutePath())); //$NON-NLS-1$
return null;
}
- return repo.toURI();
+ return repo.isOptional() && !repo.exists() ? null : repo.getLocation().toURI();
}
public void getMetadataRepository(URI repoURL, Map<String, String> properties) {

Back to the top