You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/03/14 19:54:25 UTC

svn commit: r385854 - /jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java

Author: sebb
Date: Tue Mar 14 10:54:18 2006
New Revision: 385854

URL: http://svn.apache.org/viewcvs?rev=385854&view=rev
Log:
Fix potential NPE

Modified:
    jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java

Modified: jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java?rev=385854&r1=385853&r2=385854&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/components/org/apache/jmeter/timers/BeanShellTimer.java Tue Mar 14 10:54:18 2006
@@ -53,18 +53,24 @@
 	 * @see org.apache.jmeter.timers.Timer#delay()
 	 */
 	public long delay() {
-        String ret="";
+        String ret="0";
+        JMeterContext jmctx = JMeterContextService.getContext();
+        JMeterVariables vars = jmctx.getVariables();
         try {
             // Add variables for access to context and variables
-            JMeterContext jmctx = JMeterContextService.getContext();
-            JMeterVariables vars = jmctx.getVariables();
             bshInterpreter.set("ctx", jmctx);//$NON-NLS-1$
             bshInterpreter.set("vars", vars);//$NON-NLS-1$
-            ret = bshInterpreter.eval(script).toString();
+            Object o = bshInterpreter.eval(script);
+            if (o != null) ret=o.toString();
         } catch (JMeterException e) {
             log.warn("Problem in BeanShell script "+e);
         }
-		return Long.decode(ret).longValue();
+        try {
+        	return Long.decode(ret).longValue();
+        } catch (NumberFormatException e){
+        	log.warn(e.getLocalizedMessage());
+        	return 0;
+        }
 	}
 
 	public Object clone() {



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org