You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2014/11/21 22:04:30 UTC

svn commit: r1641000 - /tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java

Author: kkolinko
Date: Fri Nov 21 21:04:30 2014
New Revision: 1641000

URL: http://svn.apache.org/r1641000
Log:
Close Jars opened during a test.

Modified:
    tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java

Modified: tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java?rev=1641000&r1=1640999&r2=1641000&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/bcel/TesterPerformance.java Fri Nov 21 21:04:30 2014
@@ -51,22 +51,23 @@ public class TesterPerformance {
         long duration = 0;
 
         for (URL jarURL : jarURLs) {
-            Jar jar = JarFactory.newInstance(jarURL);
-            jar.nextEntry();
-            String jarEntryName = jar.getEntryName();
-            while (jarEntryName != null) {
-                if (jarEntryName.endsWith(".class")) {
-                    InputStream is = jar.getEntryInputStream();
-                    long start = System.nanoTime();
-                    ClassParser cp = new ClassParser(is);
-                    cp.parse();
-                    duration += System.nanoTime() - start;
-                }
+            try (Jar jar = JarFactory.newInstance(jarURL)) {
                 jar.nextEntry();
-                jarEntryName = jar.getEntryName();
+                String jarEntryName = jar.getEntryName();
+                while (jarEntryName != null) {
+                    if (jarEntryName.endsWith(".class")) {
+                        InputStream is = jar.getEntryInputStream();
+                        long start = System.nanoTime();
+                        ClassParser cp = new ClassParser(is);
+                        cp.parse();
+                        duration += System.nanoTime() - start;
+                    }
+                    jar.nextEntry();
+                    jarEntryName = jar.getEntryName();
+                }
             }
         }
 
-        System.out.println("ClassParser performance test took: " + duration + "ns");
+        System.out.println("ClassParser performance test took: " + duration + " ns");
     }
 }



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