Details
Description
Loading a JSF page from the classpath in Tomcat in an Eclipse on Windows environment, then changing the JSF file via Eclipse lead to the original file resource being locked by the finalizer thread trying to close an InputStream to the file resource. After a GC the resource was overwritable again. The reason was the unclosed input stream in FaceletCacheImpl.java .
The following patch fixes the issue.
— java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java 8 Jan 2013 14:28:47 -0000 1.2
+++ java/org/apache/myfaces/view/facelets/impl/FaceletCacheImpl.java 24 Apr 2014 16:20:49 -0000
@@ -154,9 +154,10 @@
{
// Should check for file modification
+ URLConnection conn = null;
try
{
- URLConnection conn = facelet.getSource().openConnection();
+ conn = facelet.getSource().openConnection();
long lastModified = ResourceLoaderUtils.getResourceLastModified(conn);
return lastModified == 0 || lastModified > target;
@@ -165,6 +166,16 @@
+ // finally close input stream when finished
+ finally {
+ if (conn != null) {
+ try
catch (IOException e)
{ + throw new FaceletException("Error Checking Last Modified for " + facelet.getAlias(), e); + }+ }
+ }
}
return false;