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

Francesco Chicchiriccò commented on OPENJPA-2674:
-------------------------------------------------

In [1], if you close the JarFile instance created on line 375, you will end up 
by closing the underlying agentJarFile: I would rather close it at the end of 
the getAgentJar() method in the same class.

WDYT?

[1] 
https://github.com/apache/openjpa/blob/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java

> JarFile is not closed
> ---------------------
>
>                 Key: OPENJPA-2674
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2674
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.4.1
>            Reporter: Kaloyan Spiridonov
>             Fix For: 2.4.2, 3.0.0
>
>
> In InstrumentationFactory class at line 375 JarFile is not closed.
> {code}
>  private static boolean validateAgentJarManifest(File agentJarFile, Log log,
>         String agentClassName) {
>         try {
>             JarFile jar = new JarFile(agentJarFile);
>             Manifest manifest = jar.getManifest();
>             if (manifest == null) {
>                 return false;
>             }
>             Attributes attributes = manifest.getMainAttributes();
>             String ac = attributes.getValue("Agent-Class");
>             if (ac != null && ac.equals(agentClassName)) {
>                 return true;
>             }
>         } catch (Exception e) {
>             if (log.isTraceEnabled() == true) {
>                 log.trace(_name
>                     + ".validateAgentJarManifest() caught unexpected "
>                     + "exception " + e.getMessage());
>             }
>         }
>         return false;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to