You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/10/07 01:35:49 UTC

svn commit: r702302 - /myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/resource/ClassLoaderResourceLoader.java

Author: lu4242
Date: Mon Oct  6 16:35:49 2008
New Revision: 702302

URL: http://svn.apache.org/viewvc?rev=702302&view=rev
Log:
for close of jar InputStream (avoid jdk bug)

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=702302&r1=702301&r2=702302&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:35:49 2008
@@ -145,51 +145,69 @@
                     // See DIGESTER-29 for related problem
                     conn.setUseCaches(false);
 
-                    if (conn.getJarEntry().isDirectory())
+                    try
                     {
-                        // Unfortunately, we have to scan all entry files
-                        // because there is no proper api to scan it as a
-                        // directory tree.
-                        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
+                            // because there is no proper api to scan it as a
+                            // directory tree.
+                            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 (libraryVersion == null)
-                                {
-                                    libraryVersion = version;
-                                }
-                                else if (getVersionComparator().compare(libraryVersion, version) < 0)
-                                {
-                                    libraryVersion = version;
+                                JarEntry entry = en.nextElement();
+                                String entryName = entry.getName();
+    
+                                if (entryName.startsWith(path + '/'))
+                                {
+                                    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 (libraryVersion == null)
+                                    {
+                                        libraryVersion = version;
+                                    }
+                                    else if (getVersionComparator().compare(libraryVersion, version) < 0)
+                                    {
+                                        libraryVersion = 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)