Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363921 - [Query 2] exception when index bundle is stopped
Summary: [Query 2] exception when index bundle is stopped
Status: ASSIGNED
Alias: None
Product: EMF
Classification: Modeling
Component: Query2 (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: saurav sarkar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-16 10:05 EST by Sébastien Gandon CLA
Modified: 2012-08-03 01:49 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sébastien Gandon CLA 2011-11-16 10:05:25 EST
Build Identifier: 

We are using emf query in a rcp app and have an exception when closing the application cause but the stop method implemetation of 
    org.eclipse.emf.query.index.Activator
See the stack at the bottom.
Here is the stop method : 
 public void stop(BundleContext context) throws Exception {
        plugin = null;
        // Dumping of Indexes at the close of IDE, so that when the IDE is
        // started for the next time, indices must not be build again and
        // instead loaded from saved ones.
        IndexFactory.dumpIndexes();
        super.stop(context);
    }
The problems comes from the fact that  IndexFactory.dumpIndexes(); needs to call back Activator.getDefault() to find the a folder to related the the bundle to store the index. But the plugin has be set to null before that. So the Activator.getDefault() returns null and then no folder is calculated.
here is the simple patch.

 public void stop(BundleContext context) throws Exception {
        // Dumping of Indexes at the close of IDE, so that when the IDE is
        // started for the next time, indices must not be build again and
        // instead loaded from saved ones.
        IndexFactory.dumpIndexes();
        plugin = null;
        super.stop(context);
    }



Here is the stack : 
Caused by: java.lang.IllegalStateException: Base path not set
	at org.eclipse.emf.query.index.internal.impl.PageFileProviderImpl.getFileForElement(PageFileProviderImpl.java:41)
	at org.eclipse.emf.query.index.internal.impl.PageFileProviderImpl.getOutputFile(PageFileProviderImpl.java:36)
	at org.eclipse.emf.query.index.internal.impl.PagingStrategyImpl.pageOut(PagingStrategyImpl.java:297)
	at org.eclipse.emf.query.index.internal.impl.PagingStrategyImpl.flush(PagingStrategyImpl.java:338)
	at org.eclipse.emf.query.index.internal.impl.PagingResourceDescriptorMap.flush(PagingResourceDescriptorMap.java:105)
	at org.eclipse.emf.query.index.internal.impl.PageableIndexImpl.save(PageableIndexImpl.java:126)
	at org.eclipse.emf.query.index.IndexFactory.dumpIndexes(IndexFactory.java:98)
	at org.eclipse.emf.query.index.Activator.stop(Activator.java:49)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:843)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:836)

Reproducible: Always