FSchumacher commented on a change in pull request #700:
URL: https://github.com/apache/jmeter/pull/700#discussion_r817763864
##########
File path:
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
##########
@@ -870,26 +871,42 @@ boolean filterContentType(SampleResult result) {
* @return boolean true if Matching expression
*/
private boolean testPattern(String expression, String sampleContentType,
boolean expectedToMatch) {
- if(expression != null && expression.length() > 0) {
- if(log.isDebugEnabled()) {
- log.debug(
- "Testing Expression : {} on sampleContentType: {},
expected to match: {}",
- expression, sampleContentType, expectedToMatch);
- }
+ if (expression == null || expression.isEmpty()) {
+ return true;
+ }
+ if(log.isDebugEnabled()) {
+ log.debug(
+ "Testing Expression : {} on sampleContentType: {},
expected to match: {}",
+ expression, sampleContentType, expectedToMatch);
+ }
- Pattern pattern = null;
- try {
- pattern = JMeterUtils.getPatternCache().getPattern(expression,
Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
- if(JMeterUtils.getMatcher().contains(sampleContentType,
pattern) != expectedToMatch) {
- return false;
- }
- } catch (MalformedCachePatternException e) {
- log.warn("Skipped invalid content pattern: {}", expression, e);
+ try {
+ boolean contains;
+ if (useJavaRegex) {
+ contains = isContainedWithJavaRegex(expression,
sampleContentType);
+ } else {
+ contains = isContainedWithOroRegex(expression,
sampleContentType);
+ }
+ if (contains != expectedToMatch) {
+ return false;
}
+ } catch (PatternSyntaxException | MalformedCachePatternException e) {
+ log.warn("Skipped invalid content pattern: {}", expression, e);
}
return true;
}
+ private boolean isContainedWithJavaRegex(String expression, String
sampleContentType) {
+ java.util.regex.Pattern pattern =
java.util.regex.Pattern.compile(expression);
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]