fix(性能测试): 修复多个线程组开启了rpslimit时报数组越界

This commit is contained in:
Captain.B 2020-11-19 10:41:11 +08:00
parent 8429add30e
commit 6e6a98fbd6
1 changed files with 18 additions and 18 deletions

View File

@ -880,6 +880,24 @@ public class JmeterDocumentParser implements DocumentParser {
} }
private void processVariableThroughputTimer(Element variableThroughputTimer) { private void processVariableThroughputTimer(Element variableThroughputTimer) {
Object durations = context.getProperty("duration");
Integer duration;
if (durations instanceof List) {
Object o = ((List<?>) durations).get(0);
duration = (Integer) o;
((List<?>) durations).remove(0);
} else {
duration = (Integer) durations;
}
Object rpsLimits = context.getProperty("rpsLimit");
String rpsLimit;
if (rpsLimits instanceof List) {
Object o = ((List<?>) rpsLimits).get(0);
((List<?>) rpsLimits).remove(0);
rpsLimit = o.toString();
} else {
rpsLimit = rpsLimits.toString();
}
if (variableThroughputTimer.getChildNodes().getLength() > 0) { if (variableThroughputTimer.getChildNodes().getLength() > 0) {
final NodeList childNodes = variableThroughputTimer.getChildNodes(); final NodeList childNodes = variableThroughputTimer.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
@ -905,27 +923,9 @@ public class JmeterDocumentParser implements DocumentParser {
stringPropCount++; stringPropCount++;
} else { } else {
stringPropCount = 0; stringPropCount = 0;
Object durations = context.getProperty("duration");
Integer duration;
if (durations instanceof List) {
Object o = ((List<?>) durations).get(0);
duration = (Integer) o;
((List<?>) durations).remove(0);
} else {
duration = (Integer) durations;
}
prop.getFirstChild().setNodeValue(String.valueOf(duration)); prop.getFirstChild().setNodeValue(String.valueOf(duration));
continue; continue;
} }
Object rpsLimits = context.getProperty("rpsLimit");
String rpsLimit;
if (rpsLimits instanceof List) {
Object o = ((List<?>) rpsLimits).get(0);
((List<?>) rpsLimits).remove(0);
rpsLimit = o.toString();
} else {
rpsLimit = rpsLimits.toString();
}
prop.getFirstChild().setNodeValue(rpsLimit); prop.getFirstChild().setNodeValue(rpsLimit);
} }
} }