jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1812582 - /jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java
Date Wed, 18 Oct 2017 21:09:57 GMT
Author: pmouawad
Date: Wed Oct 18 21:09:56 2017
New Revision: 1812582

URL: http://svn.apache.org/viewvc?rev=1812582&view=rev
Log:
Fix SONAR issues
Fix wrong matching

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java?rev=1812582&r1=1812581&r2=1812582&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/BoundaryExtractor.java Wed Oct
18 21:09:56 2017
@@ -156,7 +156,7 @@ public class BoundaryExtractor extends A
             }
         } catch (RuntimeException e) {
             if (log.isWarnEnabled()) {
-                log.warn("{}: Error while generating result. {}", getName(), e.toString());
+                log.warn("{}: Error while generating result. {}", getName(), e.toString());
// NOSONAR We don't want to be too verbose
             }
         }
     }
@@ -242,16 +242,17 @@ public class BoundaryExtractor extends A
     private int extract(String leftBoundary, String rightBoundary, int matchNumber, String
inputString,
             List<String> result, int found) {
         int startIndex = -1;
-        int endIndex = -1;
+        int endIndex;
+        int newFound = found;
         List<String> matches = new ArrayList<>();
         while(true) {
             startIndex = inputString.indexOf(leftBoundary, startIndex+1);
             if(startIndex >= 0) {
                 endIndex = inputString.indexOf(rightBoundary, startIndex+leftBoundary.length());
                 if(endIndex >= 0) {
-                    result.add(inputString.substring(startIndex+leftBoundary.length(), endIndex));
+                    matches.add(inputString.substring(startIndex+leftBoundary.length(), endIndex));
                 } else {
-                    result.add(inputString.substring(startIndex+leftBoundary.length()));
+                    matches.add(inputString.substring(startIndex+leftBoundary.length()));
                     break;
                 }
             } else {
@@ -260,14 +261,14 @@ public class BoundaryExtractor extends A
         }
         
         for (String element : matches) {
-            if (matchNumber <= 0 || found != matchNumber) {
+            if (matchNumber <= 0 || newFound != matchNumber) {
                 result.add(element);
-                found++;
+                newFound++;
             } else {
                 break;
             }
         }
-        return found;
+        return newFound;
     }
 
     public void setRefName(String refName) {



Mime
View raw message