jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1347104 - /jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
Date Wed, 06 Jun 2012 20:36:10 GMT
Author: pmouawad
Date: Wed Jun  6 20:36:10 2012
New Revision: 1347104

URL: http://svn.apache.org/viewvc?rev=1347104&view=rev
Log:
DecimalFormat is not thread-safe, so remove static instance
Make format a static method

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java?rev=1347104&r1=1347103&r2=1347104&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java Wed Jun  6 20:36:10
2012
@@ -224,9 +224,7 @@ public class Summariser extends Abstract
         return JOrphanUtils.rightAlign(sb, len);
     }
 
-    private static final DecimalFormat dfDouble = new DecimalFormat("#0.0"); // $NON-NLS-1$
-
-    private static StringBuilder doubleToSb(StringBuilder sb, double d, int len, int frac)
{
+    private static StringBuilder doubleToSb(DecimalFormat dfDouble, StringBuilder sb, double
d, int len, int frac) {
         sb.setLength(0);
         dfDouble.setMinimumFractionDigits(frac);
         dfDouble.setMaximumFractionDigits(frac);
@@ -239,7 +237,8 @@ public class Summariser extends Abstract
      * @param string
      * @return
      */
-    private String format(String name, RunningSample s, String type) {
+    private static String format(String name, RunningSample s, String type) {
+        DecimalFormat dfDouble = new DecimalFormat("#0.0"); // $NON-NLS-1$
         StringBuilder tmp = new StringBuilder(20); // for intermediate use
         StringBuilder sb = new StringBuilder(100); // output line buffer
         sb.append(name);
@@ -249,10 +248,10 @@ public class Summariser extends Abstract
         sb.append(longToSb(tmp, s.getNumSamples(), 5));
         sb.append(" in ");
         long elapsed = s.getElapsed();
-        sb.append(doubleToSb(tmp, elapsed / 1000.0, 5, 1));
+        sb.append(doubleToSb(dfDouble, tmp, elapsed / 1000.0, 5, 1));
         sb.append("s = ");
         if (elapsed > 0) {
-            sb.append(doubleToSb(tmp, s.getRate(), 6, 1));
+            sb.append(doubleToSb(dfDouble, tmp, s.getRate(), 6, 1));
         } else {
             sb.append("******");// Rate is effectively infinite
         }



Mime
View raw message