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 2003/01/13 04:44:42 UTC

cvs commit: jakarta-jmeter/src/components/org/apache/jmeter/timers ConstantTimer.java

seade       2003/01/12 19:44:42

  Modified:    src/components/org/apache/jmeter/timers ConstantTimer.java
  Log:
  Deal with situation where delay value cannot be determined (set delay to zero and log error).
  
  Revision  Changes    Path
  1.3       +20 -7     jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantTimer.java
  
  Index: ConstantTimer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantTimer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConstantTimer.java	10 Jan 2003 13:59:51 -0000	1.2
  +++ ConstantTimer.java	13 Jan 2003 03:44:42 -0000	1.3
  @@ -55,10 +55,13 @@
   
   package org.apache.jmeter.timers;
   
  -import java.util.*;
  -import java.io.*;
  +import java.io.Serializable;
  +import java.util.LinkedList;
  +import java.util.List;
   
   import org.apache.jmeter.util.JMeterUtils;
  +import org.apache.log.Hierarchy;
  +import org.apache.log.Logger;
   import org.apache.jmeter.testelement.AbstractTestElement;
   import org.apache.jmeter.testelement.ThreadListener;
   import org.apache.jmeter.testelement.VariablesCollection;
  @@ -75,6 +78,9 @@
   public class ConstantTimer extends AbstractTestElement 
           implements Timer, Serializable, ThreadListener
   {
  +	private static Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor(
  +			"jmeter.elements");
  +
   	public final static String DELAY = "ConstantTimer.delay";
   	private VariablesCollection vars = new VariablesCollection();
   	private JMeterVariables variables;
  @@ -83,8 +89,6 @@
   
   	/**
   	 * No-arg constructor.
  -	 * 
  -	 * @see java.lang.Object#Object()
   	 */
   	public ConstantTimer()
   	{
  @@ -159,8 +163,17 @@
   	public void iterationStarted(int iterationCount)
   	{
   		variables = vars.getVariables();
  -		String delayString = (String) getProperty(DELAY);
  -		delay = Long.parseLong(delayString);
  +		
  +        try
  +        {
  +            String delayString = (String) getProperty(DELAY);
  +            delay = Long.parseLong(delayString);
  +        }
  +        catch (ClassCastException ex)
  +        {
  +            log.error("Unable to determine delay - you may have used an undefined variable in the test element with the name: " + getName(), ex);
  +            delay = 0;
  +        }
   	}
   
   	/**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>