Bug 35473 - NPE when exiting Eclipse
Summary: NPE when exiting Eclipse
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 35608 35642 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-03-21 10:28 EST by Andre Weinand CLA
Modified: 2003-03-28 06:46 EST (History)
4 users (show)

See Also:


Attachments
Patch for this NPE (919 bytes, patch)
2003-03-21 12:19 EST, Olivier Thomann CLA
no flags Details | Diff
Better fix for this issue (1.06 KB, patch)
2003-03-21 12:25 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Weinand CLA 2003-03-21 10:28:17 EST
RC3a
whenever I exit Eclipse with some small test workspace,
I get the following NPE:

!SESSION Mar 21, 2003 16:04:43.492 ---------------------------------------------
java.version=1.4.1-beta
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86 -install 
file:D:/eclipse/rt/eclipse/
!ENTRY org.eclipse.core.runtime 4 2 Mar 21, 2003 16:04:43.492
!MESSAGE Problems occurred when invoking code from plug-
in: "org.eclipse.core.runtime".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.shutdown
(IndexManager.java:511)
	at org.eclipse.jdt.internal.core.JavaModelManager.shutdown
(JavaModelManager.java:1550)
	at org.eclipse.jdt.core.JavaCore.shutdown(JavaCore.java:3004)
	at org.eclipse.core.internal.plugins.PluginRegistry$2.run
(PluginRegistry.java:283)
	at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:937)
	at org.eclipse.core.internal.plugins.PluginRegistry$1.visit
(PluginRegistry.java:296)
	at org.eclipse.core.internal.plugins.PluginRegistry.accept
(PluginRegistry.java:55)
	at org.eclipse.core.internal.plugins.PluginRegistry.shutdownPlugins
(PluginRegistry.java:299)
	at org.eclipse.core.internal.plugins.PluginRegistry.shutdown
(PluginRegistry.java:265)
	at org.eclipse.core.internal.runtime.InternalPlatform.loaderShutdown
(InternalPlatform.java:518)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.internal.boot.InternalBootLoader.shutdown
(InternalBootLoader.java:979)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:850)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
	at org.eclipse.core.launcher.Main.run(Main.java:747)
	at org.eclipse.core.launcher.Main.main(Main.java:583)


To reproduce
- download the workspace from http://www.weinand.org/eclipse/workspace.zip (its 
being uploaded so wait for another 30 minutes).
- Unzip and copy the workspace into the same directory where Eclipse lives.
- Start Eclipse and quit immediately.
- open the .log file. There should be a new entry at the end.
Comment 1 Olivier Thomann CLA 2003-03-21 12:15:11 EST
In this code,

	IIndex[] selectedIndexes = indexSelector.getIndexes();
	SimpleLookupTable knownPaths = new SimpleLookupTable();
	for (int i = 0, max = selectedIndexes.length; i < max; i++) {
		String path = selectedIndexes[i].getIndexFile().getAbsolutePath();
		knownPaths.put(path, path);
	}

getIndexes() can return a collection which contains null entries, if some index
needs to be created.
So a fix would be to add a null check in the for loop.
	IIndex[] selectedIndexes = indexSelector.getIndexes();
	SimpleLookupTable knownPaths = new SimpleLookupTable();
	for (int i = 0, max = selectedIndexes.length; i < max; i++) {
                IIndex selectedIndex = selectedIndexes[i];
                if (selectedIndex != null) {
                     String path = selectedIndex.getIndexFile().getAbsolutePath();
		     knownPaths.put(path, path);
                }
	}
Comment 2 Olivier Thomann CLA 2003-03-21 12:19:47 EST
Created attachment 4289 [details]
Patch for this NPE

Applying this patch fixed the problem on my machine.
Comment 3 Philipe Mulet CLA 2003-03-21 12:22:03 EST
Null indexes could be computed incorrectly as a consequence of fix for bug 
35306. This is a regression.

Need to be fixed for RC4 (null indexes are simply to be ignored).
Comment 4 Philipe Mulet CLA 2003-03-21 12:25:32 EST
Created attachment 4290 [details]
Better fix for this issue

#getIndexes() must not answer null indexes, since clients do not expect this.
Also the problem may occur elsewhere than during shutdown (whenever a search
job is running without waiting for indexing to have finished).
Comment 5 Olivier Thomann CLA 2003-03-21 12:38:05 EST
Patch verified.
Comment 6 Erich Gamma CLA 2003-03-21 12:44:11 EST
+1
Comment 7 Debbie Wilson CLA 2003-03-24 11:02:18 EST
Is this a regression of Bug 33462?  I am seeing it in RC3b.
Comment 8 Jerome Lanneluc CLA 2003-03-24 17:09:32 EST
No, this is a different problem. In fact, this is a consequence of fixing bug 
35306.

Fix is not yet released (that's why you're seeing it in RC3b)
Comment 9 Jerome Lanneluc CLA 2003-03-24 17:12:39 EST
*** Bug 35608 has been marked as a duplicate of this bug. ***
Comment 10 Philipe Mulet CLA 2003-03-25 09:51:40 EST
*** Bug 35642 has been marked as a duplicate of this bug. ***
Comment 11 Philipe Mulet CLA 2003-03-25 12:01:05 EST
Fix released for integration
Comment 12 David Audel CLA 2003-03-28 06:46:03 EST
Verified.