jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1380843 - /jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java
Date Tue, 04 Sep 2012 20:06:51 GMT
Author: pmouawad
Date: Tue Sep  4 20:06:50 2012
New Revision: 1380843

URL: http://svn.apache.org/viewvc?rev=1380843&view=rev
Log:
Avoid NumberFormatException by testing numericity

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=1380843&r1=1380842&r2=1380843&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java Tue Sep  4
20:06:50 2012
@@ -26,6 +26,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -142,10 +143,10 @@ public class StringFromFile extends Abst
         String start = "";
         if (values.length >= PARAM_START) {
             start = ((CompoundVariable) values[PARAM_START - 1]).execute();
-            try {
-                myStart = Integer.valueOf(start).intValue();
-            } catch (NumberFormatException e) {
-                myStart = COUNT_UNUSED;// Don't process invalid numbers
+            if(StringUtils.isNumeric(start)) {
+                myStart = Integer.parseInt(start);
+            } else {
+                myStart = COUNT_UNUSED;// Don't process invalid numbers                 
  
             }
         }
         // Have we used myCurrent yet?
@@ -156,13 +157,12 @@ public class StringFromFile extends Abst
 
         if (values.length >= PARAM_END) {
             String tmp = ((CompoundVariable) values[PARAM_END - 1]).execute();
-            try {
-                myEnd = Integer.valueOf(tmp).intValue();
-            } catch (NumberFormatException e) {
+            if(StringUtils.isNumeric(start)) {
+                myEnd = Integer.parseInt(tmp);
+            } else {
                 myEnd = COUNT_UNUSED;// Don't process invalid numbers
-                                        // (including "")
+                // (including "")
             }
-
         }
 
         if (values.length >= PARAM_START) {



Mime
View raw message