|
30 | 30 | import java.util.concurrent.TimeUnit; |
31 | 31 |
|
32 | 32 | import org.apache.jmeter.assertions.AssertionResult; |
33 | | -import org.apache.jmeter.control.TransactionSampler; |
34 | 33 | import org.apache.jmeter.gui.Searchable; |
35 | 34 | import org.apache.jmeter.testelement.TestPlan; |
36 | | -import org.apache.jmeter.threads.JMeterContext; |
37 | 35 | import org.apache.jmeter.threads.JMeterContext.TestLogicalAction; |
38 | | -import org.apache.jmeter.threads.JMeterContextService; |
39 | 36 | import org.apache.jmeter.util.JMeterUtils; |
40 | 37 | import org.apache.jorphan.util.JOrphanUtils; |
41 | 38 | import org.apache.jorphan.util.StringUtilities; |
@@ -67,15 +64,10 @@ public class SampleResult implements Serializable, Cloneable, Searchable { |
67 | 64 | private static final String INVALID_CALL_SEQUENCE_MSG = "Invalid call sequence"; // $NON-NLS-1$ |
68 | 65 |
|
69 | 66 |
|
70 | | - // Bug 33196 - encoding ISO-8859-1 is only suitable for Western countries |
71 | | - // However the suggested System.getProperty("file.encoding") is Cp1252 on |
72 | | - // Windows |
73 | | - // So use a new property with the original value as default |
74 | | - // needs to be accessible from test code |
75 | 67 | /** |
76 | 68 | * The default encoding to be used to decode the responseData byte array. |
77 | 69 | * The value is defined by the property "sampleresult.default.encoding" |
78 | | - * with a default of DEFAULT_HTTP_ENCODING if that is not defined. |
| 70 | + * with a default of {@link #DEFAULT_HTTP_ENCODING} if that is not defined. |
79 | 71 | */ |
80 | 72 | protected static final String DEFAULT_ENCODING |
81 | 73 | = JMeterUtils.getPropDefault("sampleresult.default.encoding", // $NON-NLS-1$ |
@@ -1603,62 +1595,10 @@ public void setStartNextThreadLoop(boolean startNextThreadLoop) { |
1603 | 1595 | } |
1604 | 1596 |
|
1605 | 1597 | /** |
1606 | | - * Clean up cached data, but only if this is a root result (no parent) |
1607 | | - * and not part of a parent transaction. |
| 1598 | + * Clean up cached data |
1608 | 1599 | */ |
1609 | 1600 | public void cleanAfterSample() { |
1610 | | - // Only clean if this is a root result (no parent) |
1611 | | - if (parent != null) { |
1612 | | - return; |
1613 | | - } |
1614 | | - |
1615 | | - // Check if we're part of a parent transaction by walking up the sampler hierarchy |
1616 | | - JMeterContext context = JMeterContextService.getContext(); |
1617 | | - if (context != null) { |
1618 | | - Sampler currentSampler = context.getCurrentSampler(); |
1619 | | - if (currentSampler instanceof TransactionSampler) { |
1620 | | - TransactionSampler transSampler = (TransactionSampler) currentSampler; |
1621 | | - // Get the parent sampler from the transaction |
1622 | | - Sampler parentSampler = transSampler.getSubSampler(); |
1623 | | - // If there's a parent sampler and it's a transaction, we're nested |
1624 | | - if (parentSampler instanceof TransactionSampler) { |
1625 | | - return; |
1626 | | - } |
1627 | | - } |
1628 | | - } |
1629 | | - |
1630 | | - cleanRecursively(); |
1631 | | - } |
1632 | | - |
1633 | | - /** |
1634 | | - * Internal method to clean this result and all its sub-results |
1635 | | - */ |
1636 | | - private void cleanRecursively() { |
1637 | | - // Clean sub-results first |
1638 | | - if (subResults != null) { |
1639 | | - for (SampleResult subResult : subResults) { |
1640 | | - if (subResult != null) { |
1641 | | - subResult.cleanRecursively(); |
1642 | | - } |
1643 | | - } |
1644 | | - subResults.clear(); |
1645 | | - subResults = null; |
1646 | | - } |
1647 | | - |
1648 | | - // Clean assertion results |
1649 | | - if (assertionResults != null) { |
1650 | | - assertionResults.clear(); |
1651 | | - assertionResults = null; |
1652 | | - } |
1653 | | - |
1654 | | - // Clear only memory-heavy data and caches, preserve samplerData |
1655 | | - this.parent = null; |
1656 | 1601 | this.responseDataAsString = null; |
1657 | | - this.responseData = EMPTY_BA; |
1658 | | - this.responseHeaders = ""; |
1659 | | - this.requestHeaders = ""; |
1660 | | - this.samplerData = null; |
1661 | | - |
1662 | 1602 | } |
1663 | 1603 |
|
1664 | 1604 | @Override |
@@ -1726,50 +1666,4 @@ public TestLogicalAction getTestLogicalAction() { |
1726 | 1666 | public void setTestLogicalAction(TestLogicalAction testLogicalAction) { |
1727 | 1667 | this.testLogicalAction = testLogicalAction; |
1728 | 1668 | } |
1729 | | - |
1730 | | - /** |
1731 | | - * Create a deep copy for async listeners |
1732 | | - * @return A deep copy of this result |
1733 | | - */ |
1734 | | - public SampleResult cloneForListeners() { |
1735 | | - // Create clone with the correct type |
1736 | | - SampleResult clone; |
1737 | | - try { |
1738 | | - // Use the same constructor that was used to create this instance |
1739 | | - clone = this.getClass().getConstructor(this.getClass()).newInstance(this); |
1740 | | - } catch (Exception e) { |
1741 | | - // Fallback to base class if constructor is not available |
1742 | | - log.debug("Could not create clone with type: " + this.getClass().getName() + ", using base class", e); |
1743 | | - clone = new SampleResult(this); |
1744 | | - } |
1745 | | - |
1746 | | - // Deep copy mutable fields that the copy constructor doesn't handle deeply |
1747 | | - if (responseData != EMPTY_BA) { |
1748 | | - clone.responseData = responseData.clone(); |
1749 | | - } |
1750 | | - |
1751 | | - // Deep copy subResults |
1752 | | - if (subResults != null) { |
1753 | | - clone.subResults = new ArrayList<>(subResults.size()); |
1754 | | - for (SampleResult sub : subResults) { |
1755 | | - SampleResult subClone = sub.cloneForListeners(); |
1756 | | - subClone.setParent(clone); |
1757 | | - clone.subResults.add(subClone); |
1758 | | - } |
1759 | | - } |
1760 | | - |
1761 | | - // Deep copy assertion results |
1762 | | - if (assertionResults != null) { |
1763 | | - clone.assertionResults = new ArrayList<>(assertionResults.size()); |
1764 | | - for (AssertionResult assertionResult : assertionResults) { |
1765 | | - clone.assertionResults.add(assertionResult); // AssertionResult is immutable |
1766 | | - } |
1767 | | - } |
1768 | | - |
1769 | | - // Clear only the caches and unnecessary references in the clone |
1770 | | - clone.responseDataAsString = null; |
1771 | | - clone.parent = null; // Parent reference not needed in the clone |
1772 | | - |
1773 | | - return clone; |
1774 | | - } |
1775 | 1669 | } |
0 commit comments