myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3888) Resource from classpath locked on windows after change in eclipse
Date Wed, 14 May 2014 11:17:15 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-3888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13997468#comment-13997468
] 

Leonardo Uribe commented on MYFACES-3888:
-----------------------------------------

It looks like the patch can be applied. There is a code that closes the stream in ResourceLoaderUtils
but only for jar files, but it looks like with the mentioned configuration another type is
used and that causes the problem. The spec of InputStream says that close a stream twice has
no effect.

> 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
>         Attachments: FaceletCacheImpl_patched.java, patch_input_stream_close.patch
>
>
> 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)

Mime
View raw message