1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 17:55:39 +02:00

Catch possible risk of NPE

This commit is contained in:
Alain Magloire 2002-12-19 20:50:14 +00:00
parent 00f303ec04
commit 6a8c0ef458

View file

@ -137,11 +137,14 @@ public class BinaryContainerAdapter extends Container implements IFolder {
if (f == null) { if (f == null) {
// Pass it to parent to create a fake/phantom if the object // Pass it to parent to create a fake/phantom if the object
// is not in the archive. // is not in the archive.
f = getParent().getFile(path); IContainer container = getParent();
// Add it to the list of phantoms if (container != null) {
if (! phantomResources.contains(f)) { f = container.getFile(path);
phantomResources.add(f); // Add it to the list of phantoms
phantomResources.trimToSize(); if (! phantomResources.contains(f)) {
phantomResources.add(f);
phantomResources.trimToSize();
}
} }
} }
return f; return f;
@ -176,10 +179,14 @@ public class BinaryContainerAdapter extends Container implements IFolder {
public IFolder getFolder(IPath path) { public IFolder getFolder(IPath path) {
// Only Files in the archive pass this to the parent // Only Files in the archive pass this to the parent
// to create a phatom resource // to create a phatom resource
IFolder f = getParent().getFolder(path); IFolder f = null;
if (!phantomResources.contains(f)) { IContainer container = getParent();
phantomResources.add(f); if (container != null) {
phantomResources.trimToSize(); f = container.getFolder(path);
if (!phantomResources.contains(f)) {
phantomResources.add(f);
phantomResources.trimToSize();
}
} }
return f; return f;
} }