[
https://issues.apache.org/jira/browse/MYFACES-3888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Patrick McLaren updated MYFACES-3888:
-------------------------------------
Status: Patch Available (was: Open)
> Resource from classpath locked on windows after change in eclipse
> -----------------------------------------------------------------
>
> Key: MYFACES-3888
> URL: https://issues.apache.org/jira/browse/MYFACES-3888
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.1.12, 2.1.13, 2.1.14, 2.1.15
> Environment: Tomcat in an Eclipse on Windows environment
> Reporter: Patrick McLaren
>
> 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 @@
> {
> throw new FaceletException("Error Checking Last Modified for
> " + facelet.getAlias(), e);
> }
> + // finally close input stream when finished
> + finally {
> + if (conn != null) {
> + try {
> + conn.getInputStream().close();
> + } catch (IOException e) {
> + throw new FaceletException("Error Checking Last
> Modified for " + facelet.getAlias(), e);
> + }
> + }
> + }
> }
>
> return false;
--
This message was sent by Atlassian JIRA
(v6.2#6252)