pmouawad commented on a change in pull request #700:
URL: https://github.com/apache/jmeter/pull/700#discussion_r817427761



##########
File path: 
src/core/src/main/java/org/apache/jmeter/report/dashboard/ReportGenerator.java
##########
@@ -458,6 +458,19 @@ private ApdexSummaryConsumer createApdexSummaryConsumer() {
         return apdexSummaryConsumer;
     }
 
+    private boolean isMatching(String sampleName, String keyName) {
+        if (sampleName == null) {
+            return false;
+        }
+        if (useJavaRegex) {
+            java.util.regex.Pattern pattern = 
java.util.regex.Pattern.compile(keyName);

Review comment:
       Should this be cached ? 

##########
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:
       Should this be cached ? 

##########
File path: 
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
##########
@@ -1219,6 +1276,32 @@ private int getPositionOfBody(String stringToCheck) {
     }
 
     private String getBoundaryStringFromContentType(String requestHeaders) {
+        if (useJavaRegex) {
+            return 
getBoundaryStringFromContentTypeWithJavaRegex(requestHeaders);
+        }
+        return getBoundaryStringFromContentTypeWithOroRegex(requestHeaders);
+    }
+
+    private String getBoundaryStringFromContentTypeWithJavaRegex(String 
requestHeaders) {

Review comment:
       Would it be better to use Optional<String> as return




-- 
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]


Reply via email to