tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: svn commit: r1640978 - /tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Date Fri, 21 Nov 2014 20:59:47 GMT
2014-11-21 22:01 GMT+03:00  <schultz@apache.org>:
> Author: schultz
> Date: Fri Nov 21 19:01:45 2014
> New Revision: 1640978
>
> URL: http://svn.apache.org/r1640978
> Log:
> Fix Coverty issue 45276: close Jar resource after use.
>
> Modified:
>     tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
>
> Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java?rev=1640978&r1=1640977&r2=1640978&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java (original)
> +++ tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java Fri Nov 21 19:01:45
2014
> @@ -124,12 +124,9 @@ class TagLibraryInfoImpl extends TagLibr
>              tldResourcePath = generateTldResourcePath(uri, ctxt);
>          }
>
> -        Jar jar;
> +        Jar jar = null;
>          try {
>              jar = tldResourcePath.getJar();

Good catch.

The "getJar()" method creates a Jar (with JarFactory.newInstance(..)),
but it is a bit unexpected from a getter method.


> -        } catch (IOException ioe) {
> -            throw new JasperException(ioe);
> -        }
>
>          // Add the dependencies on the TLD to the referencing page
>          PageInfo pageInfo = ctxt.createCompiler().getPageInfo();
> @@ -218,6 +215,14 @@ class TagLibraryInfoImpl extends TagLibr
>          this.tags = tagInfos.toArray(new TagInfo[tagInfos.size()]);
>          this.tagFiles = tagFileInfos.toArray(new TagFileInfo[tagFileInfos.size()]);
>          this.functions = functionInfos.toArray(new FunctionInfo[functionInfos.size()]);
> +        } catch (IOException ioe) {
> +            throw new JasperException(ioe);
> +        }
> +        finally
> +        {

Your code formatting is odd. It would better be " } finally { ".

> +            if(null != jar)
> +                jar.close(); // Jar.close does not throw IOException, but probably should
> +        }
>      }


Best regards,
Konstantin Kolinko

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


Mime
View raw message