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 2012/09/06 08:55:00 UTC
svn commit: r1381480 - in
/jmeter/trunk/src/functions/org/apache/jmeter/functions: IntSum.java
LongSum.java StringFromFile.java
Author: pmouawad
Date: Thu Sep 6 06:55:00 2012
New Revision: 1381480
URL: http://svn.apache.org/viewvc?rev=1381480&view=rev
Log:
Change as per sebb comment
Modified:
jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java
jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java
Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java?rev=1381480&r1=1381479&r2=1381480&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java Thu Sep 6 06:55:00 2012
@@ -28,6 +28,8 @@ import org.apache.jmeter.samplers.Sample
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
/**
* Provides an intSum function that adds two or more integer values.
@@ -36,7 +38,7 @@ import org.apache.jmeter.util.JMeterUtil
* @since 1.8.1
*/
public class IntSum extends AbstractFunction {
-
+ private static final Logger log = LoggingManager.getLoggerForClass();
private static final List<String> desc = new LinkedList<String>();
private static final String KEY = "__intSum"; //$NON-NLS-1$
@@ -69,9 +71,19 @@ public class IntSum extends AbstractFunc
sum += Integer.parseInt(((CompoundVariable) values[i]).execute());
}
- if(StringUtils.isNumeric(varName)) {
- sum += Integer.parseInt(varName);
- varName = null; // there is no variable name
+ try {
+ // Has chances to be a var
+ if(StringUtils.isNumeric(varName)) {
+ sum += Integer.parseInt(varName);
+ varName = null; // there is no variable name
+ }
+ } catch(NumberFormatException ignored) {
+ // TODO Should this be a warning ?
+ if(log.isDebugEnabled()) {
+ if(StringUtils.isNumeric(varName)) {
+ log.debug("Exception parsing "+varName + " as int, value will be considered a variable name and not included in sum");
+ }
+ }
}
String totalString = Integer.toString(sum);
Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java?rev=1381480&r1=1381479&r2=1381480&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java Thu Sep 6 06:55:00 2012
@@ -28,6 +28,8 @@ import org.apache.jmeter.samplers.Sample
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
/**
* Provides a longSum function that adds two or more long values.
@@ -35,6 +37,7 @@ import org.apache.jmeter.util.JMeterUtil
* @since 2.3.2
*/
public class LongSum extends AbstractFunction {
+ private static final Logger log = LoggingManager.getLoggerForClass();
private static final List<String> desc = new LinkedList<String>();
@@ -68,9 +71,19 @@ public class LongSum extends AbstractFun
sum += Long.parseLong(((CompoundVariable) values[i]).execute());
}
- if(StringUtils.isNumeric(varName)) {
- sum += Long.parseLong(varName);
- varName = null; // there is no variable name
+ try {
+ // Has chances to be a var
+ if(StringUtils.isNumeric(varName)) {
+ sum += Long.parseLong(varName);
+ varName = null; // there is no variable name
+ }
+ } catch(NumberFormatException ignored) {
+ // Should this be a warning ?
+ if(log.isDebugEnabled()) {
+ if(StringUtils.isNumeric(varName)) {
+ log.debug("Exception parsing "+varName + " as long, value will be considered a variable name and not included in sum");
+ }
+ }
}
String totalString = Long.toString(sum);
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=1381480&r1=1381479&r2=1381480&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/StringFromFile.java Thu Sep 6 06:55:00 2012
@@ -143,10 +143,17 @@ public class StringFromFile extends Abst
String start = "";
if (values.length >= PARAM_START) {
start = ((CompoundVariable) values[PARAM_START - 1]).execute();
- if(StringUtils.isNumeric(start)) {
+ try {
+ // Low chances to be non numeric, we parse
myStart = Integer.parseInt(start);
- } else {
+ } catch(NumberFormatException e) {
myStart = COUNT_UNUSED;// Don't process invalid numbers
+ // TODO Should this be a warning ?
+ if(log.isDebugEnabled()) {
+ if(StringUtils.isNumeric(start)) {
+ log.debug("Exception parsing "+start + " as int, value will not be considered as Start Number sequence");
+ }
+ }
}
}
// Have we used myCurrent yet?
@@ -157,11 +164,17 @@ public class StringFromFile extends Abst
if (values.length >= PARAM_END) {
String tmp = ((CompoundVariable) values[PARAM_END - 1]).execute();
- if(StringUtils.isNumeric(tmp)) {
+ try {
+ // Low chances to be non numeric, we parse
myEnd = Integer.parseInt(tmp);
- } else {
- myEnd = COUNT_UNUSED;// Don't process invalid numbers
- // (including "")
+ } catch(NumberFormatException e) {
+ myEnd = COUNT_UNUSED;// Don't process invalid numbers (including "")
+ // TODO Should this be a warning ?
+ if(log.isDebugEnabled()) {
+ if(StringUtils.isNumeric(tmp)) {
+ log.debug("Exception parsing "+tmp + " as int, value will not be considered as End Number sequence");
+ }
+ }
}
}