openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1768194 - /openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
Date Sat, 05 Nov 2016 11:29:18 GMT
Author: struberg
Date: Sat Nov  5 11:29:17 2016
New Revision: 1768194

URL: http://svn.apache.org/viewvc?rev=1768194&view=rev
Log:
OPENJPA-2674 properly close JarFile

txs to Kaloyan Spiridonov for the catch!

Modified:
    openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java

Modified: openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java?rev=1768194&r1=1768193&r2=1768194&view=diff
==============================================================================
--- openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
(original)
+++ openjpa/branches/2.4.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/InstrumentationFactory.java
Sat Nov  5 11:29:17 2016
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -369,10 +370,10 @@ public class InstrumentationFactory {
      * @return True if the provided agentClassName is defined as the Agent-Class
      *         in the manifest from the provided agentJarFile. False otherwise.
      */
-    private static boolean validateAgentJarManifest(File agentJarFile, Log log,
-        String agentClassName) {
+    private static boolean validateAgentJarManifest(File agentJarFile, Log log, String agentClassName)
{
+        JarFile jar = null;
         try {
-            JarFile jar = new JarFile(agentJarFile);
+            jar = new JarFile(agentJarFile);
             Manifest manifest = jar.getManifest();
             if (manifest == null) {
                 return false;
@@ -389,6 +390,15 @@ public class InstrumentationFactory {
                     + "exception " + e.getMessage());
             }
         }
+        finally {
+            if (jar != null) {
+                try {
+                    jar.close();
+                } catch (IOException e) {
+                    // don't care. It's just for properly closing the resource
+                }
+            }
+        }
         return false;
     }// end validateAgentJarManifest   
 }



Mime
View raw message