You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2011/11/12 11:14:21 UTC

svn commit: r1201240 - /jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java

Author: pmouawad
Date: Sat Nov 12 10:14:21 2011
New Revision: 1201240

URL: http://svn.apache.org/viewvc?rev=1201240&view=rev
Log:
Bug 52150 - FileServer has 3 confusingly similar methods to set the file base

Step 2, facctor common check code

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java?rev=1201240&r1=1201239&r2=1201240&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java Sat Nov 12 10:14:21 2011
@@ -113,10 +113,7 @@ public class FileServer {
      * @throws IllegalStateException if files are still open
      */
     public synchronized void setBasedir(String basedir) {
-        if (filesOpen()) {
-            throw new IllegalStateException("Files are still open, cannot change base directory");
-        }
-        files.clear();
+        checkForOpenFiles();
         if (basedir != null) {
             base = new File(basedir);
             if (!base.isDirectory()) {
@@ -139,10 +136,7 @@ public class FileServer {
         if (scriptPath == null){
             throw new IllegalArgumentException("scriptPath must not be null");
         }
-        if (filesOpen()) {
-            throw new IllegalStateException("Files are still open, cannot change base directory");
-        }
-        files.clear();
+        checkForOpenFiles();
         // getParentFile() may not work on relative paths
         setScriptName(scriptPath.getName());
         base = scriptPath.getAbsoluteFile().getParentFile();
@@ -160,14 +154,21 @@ public class FileServer {
         if (jmxBase == null) {
             throw new IllegalArgumentException("jmxBase must not be null");
         }
-        if (filesOpen()) {
-            throw new IllegalStateException("Files are still open, cannot change base directory");
-        }
-        files.clear();
+        checkForOpenFiles();
         base = jmxBase;
         log.info("Set new base='"+base+"'");
     }
 
+	/**
+	 * @throws IllegalStateException
+	 */
+	private void checkForOpenFiles() throws IllegalStateException {
+		if (filesOpen()) {
+            throw new IllegalStateException("Files are still open, cannot change base directory");
+        }
+        files.clear();
+	}
+
     public synchronized String getBaseDir() {
         return base.getAbsolutePath();
     }