diff options
author | Thomas Watson | 2009-09-25 20:16:54 +0000 |
---|---|---|
committer | Thomas Watson | 2009-09-25 20:16:54 +0000 |
commit | 5166b47734b8616542abc44dd7fff8089db24869 (patch) | |
tree | 28cdbd1b7aa870aa856dd4dd5cdb8692cf4e84b2 /bundles/org.eclipse.osgi | |
parent | 84caa01ed0f999cd71086fab7c1553b22e5c58e0 (diff) | |
download | rt.equinox.framework-5166b47734b8616542abc44dd7fff8089db24869.tar.gz rt.equinox.framework-5166b47734b8616542abc44dd7fff8089db24869.tar.xz rt.equinox.framework-5166b47734b8616542abc44dd7fff8089db24869.zip |
Bug 290389 - File handle leaked if bundle is uninstalled when it's depended upon by another bundlev20090928Root_OSGI_R4_3_RI
Diffstat (limited to 'bundles/org.eclipse.osgi')
3 files changed, 32 insertions, 7 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java index b01ca97f1..d8c78e47b 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java @@ -632,7 +632,20 @@ public class PackageAdminImpl implements PackageAdmin { return ((AbstractBundle) bundle).isFragment() ? PackageAdmin.BUNDLE_TYPE_FRAGMENT : 0; } - protected void cleanup() { //This is only called when the framework is shutting down + protected void cleanup() { + //This is only called when the framework is shutting down + synchronized (removalPendings) { + for (Iterator pendings = removalPendings.values().iterator(); pendings.hasNext();) { + List removals = (List) pendings.next(); + for (Iterator iRemovals = removals.iterator(); iRemovals.hasNext();) + try { + ((BundleData) iRemovals.next()).close(); + } catch (IOException e) { + // ignore + } + } + removalPendings.clear(); + } } protected void setResolvedBundles(InternalSystemBundle systemBundle) { diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java index 1c3d3178c..34e570880 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseStorage.java @@ -917,9 +917,9 @@ public class BaseStorage implements SynchronousBundleListener { private void cleanOSGiCache() { File osgiConfig = LocationManager.getOSGiConfigurationDir(); - if (!AdaptorUtil.rm(osgiConfig)) { - // TODO log error? - } + if (!AdaptorUtil.rm(osgiConfig)) + adaptor.getFrameworkLog().log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, "Unable to clean storage area: " + osgiConfig.getAbsolutePath(), 0, null, null)); //$NON-NLS-1$ + } /** diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/StateManager.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/StateManager.java index 20452604f..2b2834a9d 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/StateManager.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/StateManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,8 @@ package org.eclipse.osgi.internal.baseadaptor; import java.io.File; import java.io.IOException; import org.eclipse.osgi.framework.internal.core.FrameworkProperties; +import org.eclipse.osgi.internal.loader.BundleLoader; +import org.eclipse.osgi.internal.loader.BundleLoaderProxy; import org.eclipse.osgi.internal.resolver.*; import org.eclipse.osgi.service.resolver.*; import org.osgi.framework.BundleContext; @@ -103,12 +105,22 @@ public class StateManager implements PlatformAdmin, Runnable { */ public void shutdown(File stateFile, File lazyFile) throws IOException { BundleDescription[] removalPendings = systemState.getRemovalPendings(); - if (removalPendings.length > 0) - systemState.resolve(removalPendings); + cleanRemovalPendings(removalPendings); writeState(systemState, stateFile, lazyFile); stopDataManager(); } + private void cleanRemovalPendings(BundleDescription[] removalPendings) { + if (removalPendings.length == 0) + return; + systemState.resolve(removalPendings); + for (int i = 0; i < removalPendings.length; i++) { + Object userObject = removalPendings[i].getUserObject(); + if (userObject instanceof BundleLoaderProxy) + BundleLoader.closeBundleLoader((BundleLoaderProxy) userObject); + } + } + /** * Update the given target files with the state data in memory. * @param stateFile |