Skip to content

Commit

Permalink
Fix SONAR issues
Browse files Browse the repository at this point in the history
Fix wrong matching

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1812582 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pmouawad committed Oct 18, 2017
1 parent 3e9dc1c commit 0f21113
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void process() {
}
} 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
}
}
}
Expand Down Expand Up @@ -242,16 +242,17 @@ private List<String> extractMatchingStrings(JMeterVariables vars,
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 {
Expand All @@ -260,14 +261,14 @@ private int extract(String leftBoundary, String rightBoundary, int matchNumber,
}

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) {
Expand Down

0 comments on commit 0f21113

Please sign in to comment.