You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2006/10/27 16:56:33 UTC

svn commit: r468401 - /incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java

Author: rickhall
Date: Fri Oct 27 07:56:33 2006
New Revision: 468401

URL: http://svn.apache.org/viewvc?view=rev&rev=468401
Log:
Fixed a bug where the service registry was holding a reference to a bundle
after it has released all of its used services; this was inhibiting garbage
collection.

Modified:
    incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java

Modified: incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java?view=diff&rev=468401&r1=468400&r2=468401
==============================================================================
--- incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java (original)
+++ incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java Fri Oct 27 07:56:33 2006
@@ -281,7 +281,18 @@
         // bundle.
         if (usage.m_count == 0)
         {
-            m_inUseMap.put(bundle, removeUsageCount(usages, ref));
+            // Remove reference from usages array.
+            usages = removeUsageCount(usages, ref);
+            // If there are no more usages in the array, then remove
+            // the bundle from the inUseMap to allow for garbage collection.
+            if (usages.length == 0)
+            {
+                m_inUseMap.remove(bundle);
+            }
+            else
+            {
+                m_inUseMap.put(bundle, usages);
+            }
             ServiceRegistrationImpl reg =
                 ((ServiceReferenceImpl) ref).getServiceRegistration();
             reg.ungetService(bundle, usage.m_svcObj);