On 03/09/2014 19:22, violet...@apache.org wrote:
> Author: violetagg
> Date: Wed Sep  3 18:22:14 2014
> New Revision: 1622312
> 
> URL: http://svn.apache.org/r1622312
> Log:
> Fix some potential resource leaks when reading files and other resources. 
> Reported by Coverity Scan.
> 
> Modified:
>     tomcat/trunk/java/org/apache/catalina/util/CharsetMapper.java
>     
> tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java

I'm guessing you haven't started a Tomcat instance built after this
change was made. Lots of FNFE appear in the logs.

<snip/>

> Modified: 
> tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java?rev=1622312&r1=1622311&r2=1622312&view=diff
> ==============================================================================
> --- 
> tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java
>  (original)
> +++ 
> tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/FragmentJarScannerCallback.java
>  Wed Sep  3 18:22:14 2014
> @@ -111,15 +111,13 @@ public class FragmentJarScannerCallback 
>      @Override
>      public void scan(File file, String webappPath, boolean isWebapp) throws 
> IOException {
>  
> -        InputStream stream = null;
>          WebXml fragment = new WebXml();
>          fragment.setWebappJar(isWebapp);
>          fragment.setDelegate(delegate);
>  
> -        try {
> -            File fragmentFile = new File(file, FRAGMENT_LOCATION);
> +        File fragmentFile = new File(file, FRAGMENT_LOCATION);
> +        try (InputStream stream = new FileInputStream(fragmentFile)) {
>              if (fragmentFile.isFile()) {
> -                stream = new FileInputStream(fragmentFile);
>                  InputSource source =
>                      new InputSource(fragmentFile.toURI().toURL().toString());
>                  source.setByteStream(stream);

Here is the problem. You moved the creation of the stream to before the
isFile() test.

Should be an easy fix.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to