Bug 65036
Exception on shutdown
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
index 0bc364a..b87e886 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/framework/internal/defaultadaptor/DefaultAdaptor.java
@@ -158,6 +158,18 @@
}
/**
+ * Shutdown the StateManager for the adaptor. This should persist the state
+ * for reading when createStateManager is called.
+ */
+ protected void shutdownStateManager() {
+ try {
+ stateManager.shutdown(new File(getBundleStoreRootDir(), ".state")); //$NON-NLS-1$
+ } catch (IOException e) {
+ frameworkLog.log(new FrameworkEvent(FrameworkEvent.ERROR,context.getBundle(),e));
+ }
+ }
+
+ /**
*
*
*/
@@ -802,11 +814,7 @@
}
public void frameworkStop(BundleContext context) throws BundleException {
- try {
- stateManager.shutdown();
- } catch (IOException e) {
- throw new BundleException(null, e);
- }
+ shutdownStateManager();
super.frameworkStop(context);
frameworkLog.close();
diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
index c2448d4..e646a61 100644
--- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
+++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java
@@ -148,6 +148,15 @@
return stateManager;
}
+ public void shutdownStateManager() {
+ try {
+ File stateLocation = LocationManager.getConfigurationFile(LocationManager.STATE_FILE);
+ stateManager.shutdown(stateLocation); //$NON-NLS-1$
+ } catch (IOException e) {
+ frameworkLog.log(new FrameworkEvent(FrameworkEvent.ERROR,context.getBundle(),e));
+ }
+ }
+
private void cleanOSGiCache() {
File osgiConfig = LocationManager.getOSGiConfigurationDir();
if (!rm(osgiConfig)) {
@@ -518,10 +527,7 @@
out.close();
}
} catch (IOException e) {
- if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
- Debug.println("Error writing framework metadata: " + e.getMessage()); //$NON-NLS-1$
- Debug.printStackTrace(e);
- }
+ frameworkLog.log(new FrameworkEvent(FrameworkEvent.ERROR,context.getBundle(),e));
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateManager.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateManager.java
index 13829c1..4eb4b92 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateManager.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateManager.java
@@ -22,7 +22,6 @@
public static boolean MONITOR_PLATFORM_ADMIN = false;
private long readStartupTime;
private StateImpl systemState;
- private File stateLocation;
private StateObjectFactoryImpl factory;
private long lastTimeStamp;
private BundleInstaller installer;
@@ -34,19 +33,18 @@
public StateManager(File stateLocation, long expectedTimeStamp) {
factory = new StateObjectFactoryImpl();
- this.stateLocation = stateLocation;
- readState(expectedTimeStamp);
+ readState(stateLocation, expectedTimeStamp);
}
- public void shutdown() throws IOException {
- writeState();
+ public void shutdown(File stateLocation) throws IOException {
+ writeState(stateLocation);
//systemState should not be set to null as when the framework
//is restarted from a shutdown state, the systemState variable will
//not be reset, resulting in a null pointer exception
//systemState = null;
}
- private void readState(long expectedTimeStamp) {
+ private void readState(File stateLocation, long expectedTimeStamp) {
if (!stateLocation.isFile())
return;
if (DEBUG_READER)
@@ -76,7 +74,7 @@
}
}
- private void writeState() throws IOException {
+ private void writeState(File stateLocation) throws IOException {
if (systemState == null)
return;
if (stateLocation.isFile() && lastTimeStamp == systemState.getTimeStamp())
@@ -142,10 +140,6 @@
return StateHelperImpl.getInstance();
}
- public File getStateLocation() {
- return stateLocation;
- }
-
public BundleInstaller getInstaller() {
return installer;
}