Skip to content

Commit 99719ec

Browse files
author
Jörg Kubitz
committed
fix ClasspathComputer: ignore if oldEntry not found #820
fixes random failing ClasspathUpdaterTest #820
1 parent 5c22fae commit 99719ec

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.jdt.core.IClasspathAttribute;
3535
import org.eclipse.jdt.core.IClasspathEntry;
3636
import org.eclipse.jdt.core.IJavaModelStatus;
37+
import org.eclipse.jdt.core.IJavaModelStatusConstants;
3738
import org.eclipse.jdt.core.IJavaProject;
3839
import org.eclipse.jdt.core.IPackageFragmentRoot;
3940
import org.eclipse.jdt.core.JavaConventions;
@@ -267,17 +268,23 @@ private static void addLibraryEntry(IPluginLibrary library, Map<String, IPath> s
267268

268269
IPackageFragmentRoot root = context.javaProject.getPackageFragmentRoot(jarFile);
269270
if (root.exists() && root.getKind() == IPackageFragmentRoot.K_BINARY) {
270-
IClasspathEntry oldEntry = root.getRawClasspathEntry();
271-
// If we have the same binary root but new or different source, we
272-
// should recreate the entry. That is when the source attachment:
273-
// - is not defined: the default could be available now, or
274-
// - is overridden with a different value.
275-
if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null)
276-
|| (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) {
277-
context.reloaded.add(oldEntry);
278-
return;
271+
try {
272+
IClasspathEntry oldEntry = root.getRawClasspathEntry();
273+
// If we have the same binary root but new or different source, we
274+
// should recreate the entry. That is when the source attachment:
275+
// - is not defined: the default could be available now, or
276+
// - is overridden with a different value.
277+
if ((sourceAttachment == null && oldEntry.getSourceAttachmentPath() != null)
278+
|| (sourceAttachment != null && sourceAttachment.equals(oldEntry.getSourceAttachmentPath()))) {
279+
context.reloaded.add(oldEntry);
280+
return;
281+
}
282+
isExported = oldEntry.isExported();
283+
} catch (JavaModelException e) {
284+
if (e.getStatus().getCode() != IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH) {
285+
throw e;
286+
}
279287
}
280-
isExported = oldEntry.isExported();
281288
}
282289
reloadClasspathEntry(jarFile, name, sourceAttachment, isExported, context);
283290
}

0 commit comments

Comments
 (0)