Author: pmouawad Date: Wed Aug 22 22:04:11 2018 New Revision: 1838686 URL: http://svn.apache.org/viewvc?rev=1838686&view=rev Log: Bug 62648 - Sub Results of Transaction Controller when "Generate Parent Sample" is checked are modified Bugzilla Id: 62648
Modified: jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Modified: jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java?rev=1838686&r1=1838685&r2=1838686&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java Wed Aug 22 22:04:11 2018 @@ -116,7 +116,7 @@ public class TransactionSampler extends noFailingSamples++; } // Add the sub result to the transaction result - transactionSampleResult.addSubResult(res); + transactionSampleResult.addSubResult(res, false); // Add current time to total for later use (exclude pause time) totalTime += res.getTime(); } Modified: jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java?rev=1838686&r1=1838685&r2=1838686&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java Wed Aug 22 22:04:11 2018 @@ -614,6 +614,16 @@ public class SampleResult implements Ser * the {@link SampleResult} to be added */ public void addSubResult(SampleResult subResult) { + addSubResult(subResult, true); + } + /** + * Add a subresult and adjust the parent byte count and end-time. + * + * @param subResult + * the {@link SampleResult} to be added + * @param renameSubResults boolean do we rename subResults based on position + */ + public void addSubResult(SampleResult subResult, boolean renameSubResults) { if(subResult == null) { // see https://bz.apache.org/bugzilla/show_bug.cgi?id=54778 return; @@ -632,7 +642,7 @@ public class SampleResult implements Ser setSentBytes(getSentBytes() + subResult.getSentBytes()); setHeadersSize(getHeadersSize() + subResult.getHeadersSize()); setBodySize(getBodySizeAsLong() + subResult.getBodySizeAsLong()); - addRawSubResult(subResult); + addRawSubResult(subResult, renameSubResults); } /** @@ -640,9 +650,20 @@ public class SampleResult implements Ser * * @param subResult * the {@link SampleResult} to be added + * @param renameSubResults boolean do we rename subResults based on position */ public void addRawSubResult(SampleResult subResult){ - storeSubResult(subResult); + storeSubResult(subResult, true); + } + + /** + * Add a subresult to the collection without updating any parent fields. + * + * @param subResult + * the {@link SampleResult} to be added + */ + private void addRawSubResult(SampleResult subResult, boolean renameSubResults){ + storeSubResult(subResult, renameSubResults); } /** @@ -656,10 +677,27 @@ public class SampleResult implements Ser * the {@link SampleResult} to be added */ public void storeSubResult(SampleResult subResult) { + storeSubResult(subResult, true); + } + + /** + * Add a subresult read from a results file. + * <p> + * As for {@link SampleResult#addSubResult(SampleResult) + * addSubResult(SampleResult)}, except that the fields don't need to be + * accumulated + * + * @param subResult + * the {@link SampleResult} to be added + * @param renameSubResults boolean do we rename subResults based on position + */ + private void storeSubResult(SampleResult subResult, boolean renameSubResults) { if (subResults == null) { subResults = new ArrayList<>(); } - subResult.setSampleLabel(getSampleLabel()+"-"+subResultIndex++); + if(renameSubResults) { + subResult.setSampleLabel(getSampleLabel()+"-"+subResultIndex++); + } subResults.add(subResult); subResult.setParent(this); }