MYFACES-4375
diff --git a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
index 8fcbbd1..bdca6f0 100755
--- a/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
+++ b/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
@@ -277,7 +277,7 @@
         }
         catch (IOException e)
         {
-            log.log(Level.SEVERE, "Could not read resource " + resource, e);
+            log.log(Level.SEVERE, "Could not read lastModified " + resource, e);
         }
         return 0;
     }
diff --git a/impl/src/main/java/org/apache/myfaces/resource/ResourceLoaderUtils.java b/impl/src/main/java/org/apache/myfaces/resource/ResourceLoaderUtils.java
index c70286d..31d68b8 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/ResourceLoaderUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/ResourceLoaderUtils.java
@@ -19,6 +19,7 @@
 package org.apache.myfaces.resource;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -66,40 +67,39 @@
 
     public static long getResourceLastModified(URL url) throws IOException
     {
-        return getResourceLastModified(url.openConnection());
-    }
+        long lastModified;
 
-    public static long getResourceLastModified(URLConnection connection) throws IOException
-    {
-        long modified;
-        if (connection instanceof JarURLConnection)
+        InputStream is = null;
+        try
         {
-            // The following hack is required to work-around a JDK bug.
-            // getLastModified() on a JAR entry URL delegates to the actual JAR file
-            // rather than the JAR entry.
-            // This opens internally, and does not close, an input stream to the JAR
-            // file.
-            // In turn, you cannot close it by yourself, because it's internal.
-            // The work-around is to get the modification date of the JAR file
-            // manually,
-            // and then close that connection again.
-
-            URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
-            URLConnection jarFileConnection = null;
-
-            try
+            URLConnection connection = url.openConnection();
+            if (connection instanceof JarURLConnection)
             {
-                jarFileConnection = jarFileUrl.openConnection();
-                modified = jarFileConnection.getLastModified();
+                // The following hack is required to work-around a JDK bug.
+                // getLastModified() on a JAR entry URL delegates to the actual JAR file rather than the JAR entry.
+                // This opens internally, and does not close, an input stream to the JAR file.
+                // In turn, you cannot close it by yourself, because it's internal.
+                // The work-around is to get the modification date of the JAR file manually,
+                // and then close that connection again.
+                JarURLConnection jarUrlConnection = (JarURLConnection) connection; 
+                URL jarFileUrl = jarUrlConnection.getJarFileURL(); 
+                URLConnection jarFileConnection = jarFileUrl.openConnection();
+                is = jarFileConnection.getInputStream();
+                lastModified = jarFileConnection.getLastModified(); 
             }
-            finally
+            else
+            {
+                is = connection.getInputStream();
+                lastModified = connection.getLastModified();
+            }
+        }
+        finally
+        {
+            if (is != null)
             {
                 try
                 {
-                    if (jarFileConnection != null)
-                    {
-                        jarFileConnection.getInputStream().close();
-                    }
+                    is.close();
                 }
                 catch (Exception e)
                 {
@@ -107,14 +107,10 @@
                 }
             }
         }
-        else
-        {
-            modified = connection.getLastModified();
-        }
 
-        return modified;
+        return lastModified;
     }
-    
+
     public static int getDepth(String path)
     {
         int depth = 0;
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/CacheELFaceletCacheImpl.java b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/CacheELFaceletCacheImpl.java
index 90ec406..fa1fafb 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/CacheELFaceletCacheImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/CacheELFaceletCacheImpl.java
@@ -20,7 +20,6 @@
 
 import java.io.IOException;
 import java.net.URL;
-import java.net.URLConnection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
@@ -225,8 +224,7 @@
             // Should check for file modification
             try
             {
-                URLConnection conn = facelet.getSource().openConnection();
-                long lastModified = ResourceLoaderUtils.getResourceLastModified(conn);
+                long lastModified = ResourceLoaderUtils.getResourceLastModified(facelet.getSource());
 
                 return lastModified == 0 || lastModified > target;
             }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java
index 980cda8..fe0e321 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletFactory.java
@@ -21,7 +21,6 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URL;
-import java.net.URLConnection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -301,12 +300,9 @@
         if (System.currentTimeMillis() > target)
         {
             // Should check for file modification
-
-            URLConnection conn = null;
             try
             {
-                conn = facelet.getSource().openConnection();
-                long lastModified = ResourceLoaderUtils.getResourceLastModified(conn);
+                long lastModified = ResourceLoaderUtils.getResourceLastModified(facelet.getSource());
 
                 return lastModified == 0 || lastModified > target;
             }
@@ -314,20 +310,6 @@
             {
                 throw new FaceletException("Error Checking Last Modified for " + facelet.getAlias(), e);
             }
-            finally
-            {
-                if (conn != null)
-                {
-                    try
-                    {
-                        conn.getInputStream().close();
-                    }
-                    catch (Exception e)
-                    {
-                        // Ignored
-                    }
-                }
-            }
         }
 
         return false;
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java
index 6e09097..d8da986 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java
@@ -19,9 +19,7 @@
 package org.apache.myfaces.view.facelets.impl;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
-import java.net.URLConnection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -151,12 +149,9 @@
         if (System.currentTimeMillis() > target)
         {
             // Should check for file modification
-
-            URLConnection conn = null;
             try
             {
-                conn = facelet.getSource().openConnection();
-                long lastModified = ResourceLoaderUtils.getResourceLastModified(conn);
+                long lastModified = ResourceLoaderUtils.getResourceLastModified(facelet.getSource());
 
                 return lastModified == 0 || lastModified > target;
             }
@@ -164,25 +159,6 @@
             {
                 throw new FaceletException("Error Checking Last Modified for " + facelet.getAlias(), e);
             }
-            finally
-            {
-                // finally close input stream when finished, if fails just continue.
-                if (conn != null)
-                {
-                    try 
-                    {
-                        InputStream is = conn.getInputStream();
-                        if (is != null)
-                        {
-                            is.close();
-                        }
-                    }
-                    catch (IOException e)
-                    {
-                        // Ignore 
-                    }
-                }
-            }
         }
 
         return false;