Author: mgrigorov
Date: Thu Jul 14 10:01:39 2011
New Revision: 1146626

URL: http://svn.apache.org/viewvc?rev=1146626&view=rev
Log:
WICKET-3895 Ignore the exception when closing a connection used to get the 
resource last modification time

Close the connection just once.
It seems some InputStream implementations fail if you try to close them twice.


Modified:
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java

Modified: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java?rev=1146626&r1=1146625&r2=1146626&view=diff
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
 (original)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
 Thu Jul 14 10:01:39 2011
@@ -48,8 +48,8 @@ public class Connections
        {
                // check if url points to a local file
                final File file = Files.getLocalFileFromUrl(url);
-               
-               if(file != null)
+
+               if (file != null)
                {
                        // in that case we can get the timestamp faster
                        return Files.getLastModified(file);
@@ -59,7 +59,7 @@ public class Connections
                URLConnection connection = url.openConnection();
 
                final long milliseconds;
-               
+
                try
                {
                        if (connection instanceof JarURLConnection)
@@ -67,36 +67,28 @@ public class Connections
                                JarURLConnection jarUrlConnection = 
(JarURLConnection)connection;
                                URL jarFileUrl = 
jarUrlConnection.getJarFileURL();
                                URLConnection jarFileConnection = 
jarFileUrl.openConnection();
-                               
-                               try
-                               {
-                                       // get timestamp from JAR
-                                       milliseconds = 
jarFileConnection.getLastModified();
-                               }
-                               finally
-                               {
-                                       close(jarFileConnection);
-                               }
+                               // get timestamp from JAR
+                               milliseconds = 
jarFileConnection.getLastModified();
                        }
                        else
                        {
                                // get timestamp from URL
                                milliseconds = connection.getLastModified();
                        }
-                       
+
                        // return null if timestamp is unavailable
                        if (milliseconds == 0)
                        {
                                return null;
                        }
-                       
+
                        // return UNIX timestamp
                        return Time.millis(milliseconds);
-                       
+
                }
                finally
                {
-                       close(connection);
+                       closeQuietly(connection);
                }
        }
 


Reply via email to