felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r464939 - in /incubator/felix/trunk/framework/src/main/java/org/apache/felix: framework/cache/DirectoryRevision.java framework/cache/JarRevision.java moduleloader/JarContent.java
Date Tue, 17 Oct 2006 15:05:26 GMT
Author: rickhall
Date: Tue Oct 17 08:05:23 2006
New Revision: 464939

URL: http://svn.apache.org/viewvc?view=rev&rev=464939
Log:
Improved how Felix ignores non-existent bundle class path entries; now it
tests for existence and removes them if they are invalid.

Modified:
    incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
    incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
    incubator/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java

Modified: incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java?view=diff&rev=464939&r1=464938&r2=464939
==============================================================================
--- incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
(original)
+++ incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
Tue Oct 17 08:05:23 2006
@@ -20,7 +20,7 @@
 
 import java.io.*;
 import java.security.cert.X509Certificate;
-import java.util.Map;
+import java.util.*;
 import java.util.jar.*;
 
 import org.apache.felix.framework.Logger;
@@ -132,12 +132,12 @@
 
         // Create the bundles class path.
         IContent self = new DirectoryContent(m_refDir);
-        IContent[] contentPath = new IContent[classPathStrings.length];
+        List contentList = new ArrayList();
         for (int i = 0; i < classPathStrings.length; i++)
         {
             if (classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
             {
-                contentPath[i] = self;
+                contentList.add(self);
             }
             else
             {
@@ -145,23 +145,27 @@
                 File file = new File(m_refDir, classPathStrings[i]);
                 if (BundleCache.getSecureAction().isFileDirectory(file))
                 {
-                    contentPath[i] = new DirectoryContent(file);
+                    contentList.add(new DirectoryContent(file));
                 }
                 else
                 {
-                    contentPath[i] = new JarContent(file);
+                    // Ignore any entries that do not exist per the spec.
+                    if (BundleCache.getSecureAction().fileExists(file))
+                    {
+                        contentList.add(new JarContent(file));
+                    }
                 }
             }
         }
 
         // If there is nothing on the class path, then include
         // "." by default, as per the spec.
-        if (contentPath.length == 0)
+        if (contentList.size() == 0)
         {
-            contentPath = new IContent[] { self };
+            contentList.add(new IContent[] { self });
         }
 
-        return contentPath;
+        return (IContent[]) contentList.toArray(new IContent[contentList.size()]);
     }
 
 // TODO: This will need to consider security.

Modified: incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java?view=diff&rev=464939&r1=464938&r2=464939
==============================================================================
--- incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
(original)
+++ incubator/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
Tue Oct 17 08:05:23 2006
@@ -148,12 +148,12 @@
         {
             bundleJar = BundleCache.getSecureAction().openJAR(m_bundleFile);
             IContent self = new JarContent(m_bundleFile);
-            IContent[] contentPath = new IContent[classPathStrings.length];
+            List contentList = new ArrayList();
             for (int i = 0; i < classPathStrings.length; i++)
             {
                 if (classPathStrings[i].equals(FelixConstants.CLASS_PATH_DOT))
                 {
-                    contentPath[i] = self;
+                    contentList.add(self);
                 }
                 else
                 {
@@ -162,23 +162,28 @@
                     ZipEntry entry = bundleJar.getEntry(classPathStrings[i]);
                     if ((entry != null) && entry.isDirectory())
                     {
-                        contentPath[i] = new ContentDirectoryContent(self, classPathStrings[i]);
+                        contentList.add(new ContentDirectoryContent(self, classPathStrings[i]));
                     }
                     else
                     {
-                        contentPath[i] = new JarContent(new File(embedDir, classPathStrings[i]));
+                        // Ignore any entries that do not exist per the spec.
+                        File extractedJar = new File(embedDir, classPathStrings[i]);
+                        if (BundleCache.getSecureAction().fileExists(extractedJar))
+                        {
+                            contentList.add(new JarContent(extractedJar));
+                        }
                     }
                 }
             }
 
             // If there is nothing on the class path, then include
             // "." by default, as per the spec.
-            if (contentPath.length == 0)
+            if (contentList.size() == 0)
             {
-                contentPath = new IContent[] { self };
+                contentList.add(new IContent[] { self });
             }
 
-            return contentPath;
+            return (IContent[]) contentList.toArray(new IContent[contentList.size()]);
         }
         finally
         {

Modified: incubator/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java?view=diff&rev=464939&r1=464938&r2=464939
==============================================================================
--- incubator/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
(original)
+++ incubator/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
Tue Oct 17 08:05:23 2006
@@ -19,9 +19,7 @@
 package org.apache.felix.moduleloader;
 
 import java.io.*;
-import java.util.*;
 import java.util.Enumeration;
-import java.util.NoSuchElementException;
 import java.util.zip.ZipEntry;
 
 import org.apache.felix.framework.util.SecureAction;
@@ -274,7 +272,6 @@
     private static class EntriesEnumeration implements Enumeration
     {
         private Enumeration m_enumeration = null;
-        private Object m_next = null;
 
         public EntriesEnumeration(Enumeration enumeration)
         {



Mime
View raw message