Project: JDT
Bug 249155 [common navigator] Potential StackOverflow in JavaNavigatorContentProvider
Reported: 2008-09-30 13:55:26 | Status: verified fixed

Build ID: org.eclipse.jdt.ui_3.4.0.v20080603-2000.jar Steps To Reproduce: We are using the common navigation framework in our product. In one instance of the navigator, we passed another project as input (the tree gets partially shaped by this project). However, we hit some problems with theJavaNavigatorContentProvider. This is the stack trace which overflows: .... org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 922 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 927 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 927 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 927 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 927 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).isParent(java.lang.Object, java.lang.Object) line: 927 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).postRefresh(java.lang.Object, int, java.lang.Object, java.util.Collection) line: 903 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).handleAffectedChildren(org.eclipse.jdt.core.IJavaElementDelta, org.eclipse.jdt.core.IJavaElement, java.util.Collection) line: 745 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).processDelta(org.eclipse.jdt.core.IJavaElementDelta, java.util.Collection) line: 700 org.eclipse.jdt.internal.ui.navigator.JavaNavigatorContentProvider(org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider).elementChanged(org.eclipse.jdt.core.ElementChangedEvent) line: 126 org.eclipse.jdt.internal.core.DeltaProcessor$3.run() line: 1545 From what I can tell, this content provider does not like us using the project as input (the project does NOT have the java nature... it is a simple project with one proprietary nature). A project is being added to the workspace when the problem starts. Both "root" and "affectedElement" in the postRefresh() method are the JavaModel root. It then tries to determine if the input is a child, given the root. When getParent() is called for the input (the non-Java project), the code gets the parent for the project, which is the JavaModel root. It then assumes (I think) that the JavaModel relates to the viewer input's "real input". This assumption is not true for the input we are sending to the viewer. In the end, it thinks that the parent of the element is itself, which ends up causing the stack overflow. Perhaps more error checking should be done in here? If the element IS the input, then it shouldn't have any parent. Likewise, if the code determines that the parent of an object is the exact same object, then it must know that something is wrong. More information:

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorContentProvider.java