This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new 31e4242623 Deprecate TestElement.threadName as it is not related to
TestElement
31e4242623 is described below
commit 31e42426238ec74e4f355baa927e55df780c3057
Author: Vladimir Sitnikov <[email protected]>
AuthorDate: Mon Jun 5 19:07:53 2023 +0300
Deprecate TestElement.threadName as it is not related to TestElement
Samplers should use JMeterContextService.getContext().thread.threadName
instead.
Fixes https://github.com/apache/jmeter/issues/5961
---
.../org/apache/jmeter/testelement/AbstractTestElement.java | 2 ++
.../src/main/java/org/apache/jmeter/threads/JMeterThread.java | 7 ++++++-
.../main/kotlin/org/apache/jmeter/testelement/TestElement.kt | 11 +++++++++++
xdocs/changes.xml | 1 +
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git
a/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
b/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
index 0e461f809a..579464e57f 100644
---
a/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
+++
b/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
@@ -763,6 +763,7 @@ public abstract class AbstractTestElement implements
TestElement, Serializable,
* @return Returns the threadName.
*/
@Override
+ @SuppressWarnings("deprecation")
public String getThreadName() {
return threadName;
}
@@ -772,6 +773,7 @@ public abstract class AbstractTestElement implements
TestElement, Serializable,
* The threadName to set.
*/
@Override
+ @SuppressWarnings("deprecation")
public void setThreadName(String inthreadName) {
if (threadName != null) {
if (!threadName.equals(inthreadName)) {
diff --git a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
index f7735d42ac..8b7f13f790 100644
--- a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
+++ b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
@@ -634,7 +634,7 @@ public class JMeterThread implements Runnable,
Interruptible {
*/
private SampleResult doSampling(JMeterContext threadContext, Sampler
sampler) {
sampler.setThreadContext(threadContext);
- sampler.setThreadName(threadName);
+ setSamplerThreadName(sampler);
TestBeanHelper.prepare(sampler);
// Perform the actual sample
@@ -659,6 +659,11 @@ public class JMeterThread implements Runnable,
Interruptible {
}
}
+ @SuppressWarnings("deprecation")
+ private void setSamplerThreadName(Sampler sampler) {
+ sampler.setThreadName(threadName);
+ }
+
private SampleResult doEndTransactionSampler(
TransactionSampler transactionSampler, Sampler parent,
SamplePackage transactionPack, JMeterContext threadContext) {
diff --git
a/src/core/src/main/kotlin/org/apache/jmeter/testelement/TestElement.kt
b/src/core/src/main/kotlin/org/apache/jmeter/testelement/TestElement.kt
index 3d99ed4075..ee5fd7d36c 100644
--- a/src/core/src/main/kotlin/org/apache/jmeter/testelement/TestElement.kt
+++ b/src/core/src/main/kotlin/org/apache/jmeter/testelement/TestElement.kt
@@ -21,6 +21,7 @@ import org.apache.jmeter.testelement.property.JMeterProperty
import org.apache.jmeter.testelement.property.NullProperty
import org.apache.jmeter.testelement.property.PropertyIterator
import org.apache.jmeter.threads.JMeterContext
+import org.apiguardian.api.API
public interface TestElement : Cloneable {
public companion object {
@@ -237,7 +238,17 @@ public interface TestElement : Cloneable {
/**
* Associates a thread name with this element.
+ * @deprecated Use `JMeterContextService.getContext().thread.threadName`
instead
*/
+ @Deprecated(
+ message = "Use JMeterContextService.getContext().thread.threadName
instead",
+ replaceWith = ReplaceWith(
+ "JMeterContextService.getContext().thread.threadName",
+ imports = ["org.apache.jmeter.threads.JMeterContextService"]
+ )
+ )
+ @get:API(status = API.Status.DEPRECATED, since = "5.6")
+ @set:API(status = API.Status.DEPRECATED, since = "5.6")
public var threadName: String
/**
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 2359237d51..faecc676d3 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -142,6 +142,7 @@ Summary
<li>Update lets-plot-batik to 3.1.0 (from 2.1.1)</li>
<li>Added randomized test GitHub Actions matrix for better coverage of
locales and time zones</li>
<li><pr>5960</pr>Add OpenJDK JMH for creating microbenchmarks in JMeter
code</li>
+ <li><issue>5961</issue>Deprecate TestElement.threadName as it is not related
to TestElement</li>
</ul>
<!-- =================== Bug fixes =================== -->