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/10/15 19:53:31 UTC

cvs commit: jakarta-jmeter/src/components/org/apache/jmeter/extractor RegexExtractor.java

sebb        2003/10/15 10:53:31

  Modified:    src/components/org/apache/jmeter/extractor
                        RegexExtractor.java
  Log:
  Detect Malformed RE and log a warning message
  
  Revision  Changes    Path
  1.11      +38 -33    jakarta-jmeter/src/components/org/apache/jmeter/extractor/RegexExtractor.java
  
  Index: RegexExtractor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/extractor/RegexExtractor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RegexExtractor.java	5 Oct 2003 01:08:40 -0000	1.10
  +++ RegexExtractor.java	15 Oct 2003 17:53:31 -0000	1.11
  @@ -18,6 +18,7 @@
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.log.Logger;
  +import org.apache.oro.text.MalformedCachePatternException;
   import org.apache.oro.text.PatternCacheLRU;
   import org.apache.oro.text.regex.MatchResult;
   import org.apache.oro.text.regex.Pattern;
  @@ -73,38 +74,42 @@
               new PatternMatcherInput(
                   new String(context.getPreviousResult().getResponseData()));
           log.debug("Regex = " + getRegex());
  -        Pattern pattern =
  -            patternCache.getPattern(getRegex(), Perl5Compiler.READ_ONLY_MASK);
  -        List matches = new ArrayList();
  -        int x = 0;
  -        boolean done = false;
  -        do
  -        {
  -            if (matcher.contains(input, pattern))
  -            {
  -                log.debug("RegexExtractor: Match found!");
  -                matches.add(matcher.getMatch());
  -            }
  -            else
  -            {
  -                done = true;
  -            }
  -            x++;
  -        }
  -        while (x != getMatchNumber() && !done);
  -        try
  -        {
  -            MatchResult match = getCorrectMatch(matches);
  -            if (match != null)
  -            {
  -                context.getVariables().put(getRefName(), generateResult(match));
  -                saveGroups(context.getVariables(), getRefName(), match);
  -            }
  -        }
  -        catch (RuntimeException e)
  -        {
  -            log.warn("Error while generating result");
  -        }
  +		try {
  +			Pattern pattern =
  +			    patternCache.getPattern(getRegex(), Perl5Compiler.READ_ONLY_MASK);
  +			List matches = new ArrayList();
  +			int x = 0;
  +			boolean done = false;
  +			do
  +			{
  +			    if (matcher.contains(input, pattern))
  +			    {
  +			        log.debug("RegexExtractor: Match found!");
  +			        matches.add(matcher.getMatch());
  +			    }
  +			    else
  +			    {
  +			        done = true;
  +			    }
  +			    x++;
  +			}
  +			while (x != getMatchNumber() && !done);
  +			try
  +			{
  +			    MatchResult match = getCorrectMatch(matches);
  +			    if (match != null)
  +			    {
  +			        context.getVariables().put(getRefName(), generateResult(match));
  +			        saveGroups(context.getVariables(), getRefName(), match);
  +			    }
  +			}
  +			catch (RuntimeException e)
  +			{
  +			    log.warn("Error while generating result");
  +			}
  +		} catch (MalformedCachePatternException e) {
  +			log.warn("Error in pattern: "+ getRegex());
  +		}
       }
   
       private void saveGroups(
  
  
  

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