jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1227444 - /jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
Date Thu, 05 Jan 2012 02:20:13 GMT
Author: sebb
Date: Thu Jan  5 02:20:12 2012
New Revision: 1227444

URL: http://svn.apache.org/viewvc?rev=1227444&view=rev
Log:
FindBugs reports IC: Initialization circularity (IC_INIT_CIRCULARITY)

A circularity was detected in the static initializers of the two classes
referenced by the bug instance.  Many kinds of unexpected behavior may
arise from such circularity.

This was caused by calling the static method SampleResult.sampleNsClock() from a NanoOffset
static block; fixed by performing the init externally.

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1227444&r1=1227443&r2=1227444&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Thu Jan  5 02:20:12
2012
@@ -225,6 +225,8 @@ public class SampleResult implements Ser
         log.info("sampleresult.nanoThreadSleep="+NANOTHREAD_SLEEP);
 
         if (USENANOTIME && NANOTHREAD_SLEEP > 0) {
+            // Make sure we start with a reasonable value
+            NanoOffset.nanoOffset = System.currentTimeMillis() - SampleResult.sampleNsClockInMs();
             NanoOffset nanoOffset = new NanoOffset();
             nanoOffset.setDaemon(true);
             nanoOffset.setName("NanoOffset");
@@ -677,7 +679,7 @@ public class SampleResult implements Ser
             return new String(responseData,getDataEncodingWithDefault());
         } catch (UnsupportedEncodingException e) {
             log.warn("Using platform default as "+getDataEncodingWithDefault()+" caused "+e);
-            return new String(responseData);
+            return new String(responseData); // N.B. default charset is used deliberately
here
         }
     }
 
@@ -1264,10 +1266,8 @@ public class SampleResult implements Ser
 
     private static class NanoOffset extends Thread {
 
-        private static volatile long nanoOffset = 
-                // Make sure we start with a reasonable value
-                System.currentTimeMillis() - SampleResult.sampleNsClockInMs();
-        
+        private static volatile long nanoOffset; 
+
         static long getNanoOffset() {
             return nanoOffset;
         }



Mime
View raw message