Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-09-01 11:17:01 -0400
committerDJ Houghton2008-09-01 11:17:01 -0400
commitd37f8de52ee696d5dff89d1f14af000994c92e35 (patch)
treeaf579fe6b0ae07d934ba94ea64b09de93a431335 /bundles/org.eclipse.equinox.p2.directorywatcher
parent4a974f67736c17082492cb969bbced7ffd79a825 (diff)
downloadrt.equinox.p2-d37f8de52ee696d5dff89d1f14af000994c92e35.tar.gz
rt.equinox.p2-d37f8de52ee696d5dff89d1f14af000994c92e35.tar.xz
rt.equinox.p2-d37f8de52ee696d5dff89d1f14af000994c92e35.zip
Bug 243166 - NullPointerException in java.io.File constructorv20080901
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.directorywatcher')
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties1
3 files changed, 29 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java
index 1c5ded922..49999d0ee 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java
@@ -9,6 +9,7 @@ public class Messages extends NLS {
public static String error_processing;
public static String failed_create_artifact_repo;
public static String failed_create_metadata_repo;
+ public static String filename_missing;
public static String metadata_repo_manager_not_registered;
public static String multiple_bundle_ius;
public static String null_folder;
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
index 477aa0450..3e68f10a6 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
@@ -14,6 +14,8 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -221,7 +223,13 @@ public class RepositoryListener extends DirectoryChangeListener {
IInstallableUnit iu = (IInstallableUnit) candidate;
if (changes.contains(iu))
return true;
- File iuFile = new File(iu.getProperty(FILE_NAME));
+ String filename = iu.getProperty(FILE_NAME);
+ if (filename == null) {
+ String message = NLS.bind(Messages.filename_missing, "installable unit", iu.getId()); //$NON-NLS-1$
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null));
+ return false;
+ }
+ File iuFile = new File(filename);
return removedFiles.contains(iuFile);
}
};
@@ -249,9 +257,15 @@ public class RepositoryListener extends DirectoryChangeListener {
IArtifactDescriptor[] descriptors = artifactRepository.getArtifactDescriptors(key);
for (int i = 0; i < descriptors.length; i++) {
ArtifactDescriptor descriptor = (ArtifactDescriptor) descriptors[i];
- File artifactFile = new File(descriptor.getRepositoryProperty(FILE_NAME));
- if (removedFiles.contains(artifactFile))
- artifactRepository.removeDescriptor(descriptor);
+ String filename = descriptor.getRepositoryProperty(FILE_NAME);
+ if (filename == null) {
+ String message = NLS.bind(Messages.filename_missing, "artifact", descriptor.getArtifactKey()); //$NON-NLS-1$
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null));
+ } else {
+ File artifactFile = new File(filename);
+ if (removedFiles.contains(artifactFile))
+ artifactRepository.removeDescriptor(descriptor);
+ }
}
}
}
@@ -268,9 +282,15 @@ public class RepositoryListener extends DirectoryChangeListener {
Collector ius = metadataRepository.query(InstallableUnitQuery.ANY, new Collector(), null);
for (Iterator it = ius.iterator(); it.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) it.next();
- File iuFile = new File(iu.getProperty(FILE_NAME));
- Long iuLastModified = new Long(iu.getProperty(FILE_LAST_MODIFIED));
- currentFiles.put(iuFile, iuLastModified);
+ String filename = iu.getProperty(FILE_NAME);
+ if (filename == null) {
+ String message = NLS.bind(Messages.filename_missing, "installable unit", iu.getId()); //$NON-NLS-1$
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null));
+ } else {
+ File iuFile = new File(filename);
+ Long iuLastModified = new Long(iu.getProperty(FILE_LAST_MODIFIED));
+ currentFiles.put(iuFile, iuLastModified);
+ }
}
}
//
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties
index 858807af3..db82ed280 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties
@@ -3,6 +3,7 @@ error_main_loop=Error in watcher thread main loop.
error_processing=Error Processing: {0}
failed_create_artifact_repo=Could not create artifact repository for: {0}
failed_create_metadata_repo=Could not create metadata repository for: {0}
+filename_missing=The {0} {1} is missing the filename property.
metadata_repo_manager_not_registered=MetadataRepositoryManager not registered.
multiple_bundle_ius=There should be exactly one Bundle IU
null_folder=Folder must not be null

Back to the top