felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r372834 - /incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java
Date Fri, 27 Jan 2006 13:10:30 GMT
Author: rickhall
Date: Fri Jan 27 05:10:24 2006
New Revision: 372834

URL: http://svn.apache.org/viewcvs?rev=372834&view=rev
Log:
Applied memory leak patch from trunk.

Modified:
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java?rev=372834&r1=372833&r2=372834&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/cache/DefaultBundleCache.java
Fri Jan 27 05:10:24 2006
@@ -206,6 +206,18 @@
         return null;
     }
 
+    public int getArchiveIndex(BundleArchive ba)
+    {
+        for (int i = 0; i < m_archives.length; i++)
+        {
+            if (m_archives[i] == ba)
+            {
+                return i;
+            }
+        }
+        return -1;
+    }
+
     public BundleArchive create(long id, String location, InputStream is)
         throws Exception
     {
@@ -257,6 +269,20 @@
     public void remove(BundleArchive ba)
         throws Exception
     {
+        // Remove the archive itself.
         ((DefaultBundleArchive) ba).remove();
+        // Remove the archive from the cache.
+        int idx = getArchiveIndex(ba);
+        if (idx >= 0)
+        {
+            BundleArchive[] bas = new BundleArchive[m_archives.length - 1];
+            System.arraycopy(m_archives, 0, bas, 0, idx);
+            if (idx < bas.length)
+            {
+                System.arraycopy(m_archives, idx + 1, bas, idx,
+                    bas.length - idx);
+            }
+            m_archives = bas;
+        }
     }
 }



Mime
View raw message