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 2005/05/20 02:20:26 UTC

cvs commit: jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler AccessLogSampler.java

sebb        2005/05/19 17:20:26

  Modified:    src/protocol/http/org/apache/jmeter/protocol/http/sampler
                        AccessLogSampler.java
  Log:
  Improve error reporting for parameter errors
  
  Revision  Changes    Path
  1.19      +25 -12    jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSampler.java
  
  Index: AccessLogSampler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AccessLogSampler.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AccessLogSampler.java	14 Aug 2004 16:52:41 -0000	1.18
  +++ AccessLogSampler.java	20 May 2005 00:20:26 -0000	1.19
  @@ -18,6 +18,7 @@
   
   package org.apache.jmeter.protocol.http.sampler;
   
  +import org.apache.jmeter.protocol.http.control.CookieManager;
   import org.apache.jmeter.protocol.http.util.accesslog.Filter;
   import org.apache.jmeter.protocol.http.util.accesslog.LogParser;
   import org.apache.jmeter.samplers.Entry;
  @@ -26,6 +27,7 @@
   import org.apache.jmeter.testelement.TestCloneable;
   import org.apache.jmeter.threads.JMeterContextService;
   import org.apache.jorphan.logging.LoggingManager;
  +import org.apache.jorphan.util.JMeterException;
   import org.apache.log.Logger;
   
   /**
  @@ -127,6 +129,7 @@
         try
         {
   
  +    	  if (PARSER == null) throw new JMeterException("No Parser available");
            /*
             * samp.setDomain(this.getDomain()); samp.setPort(this.getPort());
             */
  @@ -138,6 +141,10 @@
            // huge gigabyte log file and they only want to
            // use a quarter of the entries.
            int thisCount = PARSER.parseAndConfigure(1, this);
  +         if (thisCount < 0) // Was there an error?
  +         {
  +             return errorResult(new Error("Problem parsing the log file"), new HTTPSampleResult());
  +         }
            if (thisCount == 0)
            {
               if (count == 0 || filter == null)
  @@ -146,9 +153,10 @@
               }
               if(filter != null)
                  filter.reset();
  -            getCookieManager().clear();
  +            CookieManager cm = getCookieManager();
  +            if (cm != null) cm.clear();
               count = 0;
  -            return null;
  +            return errorResult(new Error("No entries found"), new HTTPSampleResult());
            }
            count = thisCount;
            res = sample();
  @@ -156,7 +164,8 @@
         }
         catch (Exception e)
         {
  -         log.warn("Sampling failure", e);// e.printStackTrace();
  +         log.warn("Sampling failure", e);
  +         return errorResult(e, new HTTPSampleResult());
         }
         return res;
      }
  @@ -194,14 +203,18 @@
                     PARSER.setSourceFile(this.getLogFile());
                     PARSER.setFilter(filter);
                  }
  +               else
  +               {
  +            	   log.error("No log file specified");
  +               }
               }
  -         }
  -         catch (Exception e)
  -         {
  -            // since samplers shouldn't deal with
  -            // gui stuff, bad class names will
  -            // fail silently.
  -         }
  +         } catch (InstantiationException e) {
  +        	 log.error("",e);
  +		} catch (IllegalAccessException e) {
  +			 log.error("",e);
  +		} catch (ClassNotFoundException e) {
  +       	     log.error("",e);
  +		}
         }
      }
   
  
  
  

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