jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1722383 - /jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
Date Wed, 30 Dec 2015 17:12:19 GMT
Author: fschumacher
Date: Wed Dec 30 17:12:19 2015
New Revision: 1722383

URL: http://svn.apache.org/viewvc?rev=1722383&view=rev
Log:
Extract methods for temp dir management out of method generate

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java?rev=1722383&r1=1722382&r2=1722383&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java Wed Dec
30 17:12:19 2015
@@ -173,16 +173,7 @@ public class ReportGenerator {
         log.debug("Start report generation");
 
         File tmpDir = configuration.getTempDirectory();
-        boolean tmpDirCreated = false;
-        if (!tmpDir.exists()) {
-            tmpDirCreated = tmpDir.mkdir();
-            if (!tmpDirCreated) {
-                String message = String.format(
-                        "Cannot create temporary directory \"%s\".", tmpDir);
-                log.error(message);
-                throw new GenerationException(message);
-            }
-        }
+        boolean tmpDirCreated = createTempDir(tmpDir);
 
         // Build consumers chain
         SampleContext sampleContext = new SampleContext();
@@ -240,6 +231,13 @@ public class ReportGenerator {
 
         log.debug("End of data exporting");
 
+        removeTempDir(tmpDir, tmpDirCreated);
+
+        log.debug("End of report generation");
+
+    }
+
+    private void removeTempDir(File tmpDir, boolean tmpDirCreated) {
         if (tmpDirCreated) {
             try {
                 FileUtils.deleteDirectory(tmpDir);
@@ -249,9 +247,20 @@ public class ReportGenerator {
                         tmpDir), ex);
             }
         }
+    }
 
-        log.debug("End of report generation");
-
+    private boolean createTempDir(File tmpDir) throws GenerationException {
+        boolean tmpDirCreated = false;
+        if (!tmpDir.exists()) {
+            tmpDirCreated = tmpDir.mkdir();
+            if (!tmpDirCreated) {
+                String message = String.format(
+                        "Cannot create temporary directory \"%s\".", tmpDir);
+                log.error(message);
+                throw new GenerationException(message);
+            }
+        }
+        return tmpDirCreated;
     }
 
     private void addGraphConsumer(FilterConsumer nameFilter,



Mime
View raw message