myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r702304 - /myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
Date Mon, 06 Oct 2008 23:37:52 GMT
Author: lu4242
Date: Mon Oct  6 16:37:51 2008
New Revision: 702304

URL: http://svn.apache.org/viewvc?rev=702304&view=rev
Log:
enhance jar opening for getResourceVersion

Modified:
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java?rev=702304&r1=702303&r2=702304&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
(original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java
Mon Oct  6 16:37:51 2008
@@ -298,50 +298,71 @@
                 if (url != null)
                 {
                     JarURLConnection conn = (JarURLConnection)url.openConnection();
+                    // See DIGESTER-29 for related problem
+                    conn.setUseCaches(false);
 
-                    if (conn.getJarEntry().isDirectory())
+                    try
                     {
-                        // Unfortunately, we have to scan all entry files
-                        JarFile file = conn.getJarFile();
-                        for (Enumeration<JarEntry> en = file.entries(); en.hasMoreElements();)
+                        if (conn.getJarEntry().isDirectory())
                         {
-                            JarEntry entry = en.nextElement();
-                            String entryName = entry.getName();
-
-                            if (entryName.startsWith(path + '/'))
+                            // Unfortunately, we have to scan all entry files
+                            JarFile file = conn.getJarFile();
+                            for (Enumeration<JarEntry> en = file.entries(); en.hasMoreElements();)
                             {
-                                if (entryName.length() == path.length() + 1)
-                                {
-                                    // the same string, just skip it
-                                    continue;
-                                }
-
-                                if (entryName.charAt(entryName.length() - 1) != '/')
-                                {
-                                    // Skip files
-                                    continue;
-                                }
-
-                                entryName = entryName.substring(path.length() + 1, entryName.length()
- 1);
-
-                                if (entryName.indexOf('/') >= 0)
-                                {
-                                    // Inner Directory
-                                    continue;
-                                }
-
-                                String version = entryName;
-                                if (resourceVersion == null)
-                                {
-                                    resourceVersion = version;
-                                }
-                                else if (getVersionComparator().compare(resourceVersion,
version) < 0)
+                                JarEntry entry = en.nextElement();
+                                String entryName = entry.getName();
+    
+                                if (entryName.startsWith(path + '/'))
                                 {
-                                    resourceVersion = version;
+                                    if (entryName.length() == path.length() + 1)
+                                    {
+                                        // the same string, just skip it
+                                        continue;
+                                    }
+    
+                                    if (entryName.charAt(entryName.length() - 1) != '/')
+                                    {
+                                        // Skip files
+                                        continue;
+                                    }
+    
+                                    entryName = entryName.substring(path.length() + 1, entryName.length()
- 1);
+    
+                                    if (entryName.indexOf('/') >= 0)
+                                    {
+                                        // Inner Directory
+                                        continue;
+                                    }
+    
+                                    String version = entryName;
+                                    if (resourceVersion == null)
+                                    {
+                                        resourceVersion = version;
+                                    }
+                                    else if (getVersionComparator().compare(resourceVersion,
version) < 0)
+                                    {
+                                        resourceVersion = version;
+                                    }
                                 }
                             }
                         }
                     }
+                    finally
+                    {
+                        //See TRINIDAD-73
+                        //just close the input stream again if
+                        //by inspecting the entries the stream
+                        //was let open.
+                        try
+                        {
+                            conn.getInputStream().close();
+                        }
+                        catch (Exception exception)
+                        {
+                            // Ignored
+                        }
+                    }
+
                 }
             }
             catch (IOException e)



Mime
View raw message