This is an automated email from the ASF dual-hosted git repository. pmouawad pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push: new 27bb77a Bug 63862 Search Dialog / Search in View Results Tree: Uncaught exception if regex is checked and regex is invalid 27bb77a is described below commit 27bb77a5fee2143e8e9cff3f2f132e20dbfddf20 Author: pmouawad <p.moua...@ubik-ingenierie.com> AuthorDate: Thu Oct 17 21:41:45 2019 +0200 Bug 63862 Search Dialog / Search in View Results Tree: Uncaught exception if regex is checked and regex is invalid --- .../apache/jmeter/visualizers/SearchTreePanel.java | 2 +- .../apache/jmeter/gui/action/RawTextSearcher.java | 5 +++++ .../apache/jmeter/gui/action/RegexpSearcher.java | 21 +++++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/SearchTreePanel.java b/src/components/src/main/java/org/apache/jmeter/visualizers/SearchTreePanel.java index 1275dda..239a808 100644 --- a/src/components/src/main/java/org/apache/jmeter/visualizers/SearchTreePanel.java +++ b/src/components/src/main/java/org/apache/jmeter/visualizers/SearchTreePanel.java @@ -207,7 +207,7 @@ public class SearchTreePanel extends JPanel implements ActionListener { node.updateState(); return node.isNodeHasMatched() || node.isChildrenNodesHaveMatched(); } catch (Exception e) { - log.error("Error extracting data from tree node"); + log.error("Error extracting data from tree node using searcher:{}", searcher, e); return false; } } diff --git a/src/core/src/main/java/org/apache/jmeter/gui/action/RawTextSearcher.java b/src/core/src/main/java/org/apache/jmeter/gui/action/RawTextSearcher.java index 4670456..dc7b426 100644 --- a/src/core/src/main/java/org/apache/jmeter/gui/action/RawTextSearcher.java +++ b/src/core/src/main/java/org/apache/jmeter/gui/action/RawTextSearcher.java @@ -55,4 +55,9 @@ public class RawTextSearcher implements Searcher { .map(token -> caseSensitive ? token : token.toLowerCase()) .anyMatch(token -> token.contains(textToSearch)); } + + @Override + public String toString() { + return "RawTextSearcher [caseSensitive=" + caseSensitive + ", textToSearch=" + textToSearch + "]"; + } } diff --git a/src/core/src/main/java/org/apache/jmeter/gui/action/RegexpSearcher.java b/src/core/src/main/java/org/apache/jmeter/gui/action/RegexpSearcher.java index c1d3db4..634070b 100644 --- a/src/core/src/main/java/org/apache/jmeter/gui/action/RegexpSearcher.java +++ b/src/core/src/main/java/org/apache/jmeter/gui/action/RegexpSearcher.java @@ -30,8 +30,7 @@ import org.apache.commons.lang3.StringUtils; public class RegexpSearcher implements Searcher { private boolean caseSensitive; - private Pattern pattern; - + private String regexp; /** * Constructor * @param caseSensitive is search case sensitive @@ -40,19 +39,20 @@ public class RegexpSearcher implements Searcher { public RegexpSearcher(boolean caseSensitive, String regexp) { super(); this.caseSensitive = caseSensitive; - if (caseSensitive) { - pattern = Pattern.compile(regexp); - } else { - pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); - } + this.regexp = regexp; } - /** * {@inheritDoc} */ @Override public boolean search(List<String> textTokens) { + Pattern pattern; + if (caseSensitive) { + pattern = Pattern.compile(regexp); + } else { + pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); + } return textTokens.stream() .filter(token -> !StringUtils.isEmpty(token)) .map(token -> caseSensitive ? @@ -60,4 +60,9 @@ public class RegexpSearcher implements Searcher { pattern.matcher(token.toLowerCase())) .anyMatch(Matcher::find); } + + @Override + public String toString() { + return "RegexpSearcher [caseSensitive=" + caseSensitive + ", regexp=" + regexp + "]"; + } }