jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1210091 - /jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java
Date Sun, 04 Dec 2011 11:46:19 GMT
Author: pmouawad
Date: Sun Dec  4 11:46:18 2011
New Revision: 1210091

URL: http://svn.apache.org/viewvc?rev=1210091&view=rev
Log:
Bug 52266 - Code:Inconsistent synchronization

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java?rev=1210091&r1=1210090&r2=1210091&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java Sun Dec  4
11:46:18 2011
@@ -35,6 +35,7 @@ import org.apache.jmeter.threads.JMeterV
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JMeterStopThreadException;
+import org.apache.jorphan.util.JOrphanUtils;
 import org.apache.log.Logger;
 
 /**
@@ -101,33 +102,13 @@ public class StringFromFile extends Abst
     private String fileName; // needed for error messages
 
     public StringFromFile() {
-        init();
+    	myValue = ERR_IND;
+    	myName = "StringFromFile_";//$NON-NLS-1$
         if (log.isDebugEnabled()) {
             log.debug("++++++++ Construct " + this);
         }
     }
 
-    private void init(){
-        myValue = ERR_IND;
-        myName = "StringFromFile_";//$NON-NLS-1$
-    }
-
-    /**
-     * Close file and log
-     */
-    private void closeFile() {
-        if (myBread == null) {
-            return;
-        }
-        String tn = Thread.currentThread().getName();
-        log.info(tn + " closing file " + fileName);//$NON-NLS-1$
-        try {
-            myBread.close();
-        } catch (IOException e) {
-            log.error("closeFile() error: " + e.toString(), e);//$NON-NLS-1$
-        }
-    }
-
     private static final int COUNT_UNUSED = -2;
 
     private int myStart = COUNT_UNUSED;
@@ -232,7 +213,7 @@ public class StringFromFile extends Abst
                 if (line == null) { // EOF, re-open file
                     String tn = Thread.currentThread().getName();
                     log.info(tn + " EOF on  file " + fileName);//$NON-NLS-1$
-                    closeFile();
+                    JOrphanUtils.closeQuietly(myBread);
                     openFile();
                     if (myBread != null) {
                         line = myBread.readLine();
@@ -329,7 +310,7 @@ public class StringFromFile extends Abst
 
     /** {@inheritDoc} */
     public void testEnded(String host) {
-        closeFile();
+        JOrphanUtils.closeQuietly(myBread);
     }
 
     /** {@inheritDoc} */



Mime
View raw message