You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "m1a2st (via GitHub)" <gi...@apache.org> on 2026/06/09 13:20:33 UTC
[PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
m1a2st opened a new pull request, #22520:
URL: https://github.com/apache/kafka/pull/22520
Rewite ClientOAuthIntegrationTest and move to clients-integration-tests module
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3506284746
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,16 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ // The following three thread prefixes are spawned by MockOAuth2Server (which uses OkHttp's MockWebServer
+ // internally) in ClientOAuthIntegrationTest.
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
+ private static final String KEEP_ALIVE_TIMER_THREAD_PREFIX = "Keep-Alive-Timer";
+ private static final String POOL_THREAD_PREFIX = "pool-";
Review Comment:
The test error log is
```
Thread leak detected: pool-11-thread-1, pool-10-thread-1, pool-8-thread-1
Expected :true
Actual :false
<Click to see difference>
org.opentest4j.AssertionFailedError: Thread leak detected: pool-11-thread-1, pool-10-thread-1, pool-8-thread-1 ==> expected: <true> but was: <false>
at org.apache.kafka.common.test.junit.ClusterTestExtensions.afterEach(ClusterTestExtensions.java:192)
at java.base/java.util.Optional.ifPresent(Optional.java:178)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
```
[test.log](https://github.com/user-attachments/files/29553318/test.log)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3411581734
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
Yes, this is an existing issue. The original Scala version extended `IntegrationTestHarness` which does not have thread leak detection. After migrating to the new `@ClusterTest framework`, the `ClusterTestExtensions` automatically performs thread leak checking in `afterEach()`, which exposed the `MockWebServer` threads that were not fully terminated after `mockOAuthServer.shutdown()`. So the leak was always there, but the stricter constraints of the new framework made it visible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3420349242
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,16 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ // The following three thread prefixes are spawned by MockOAuth2Server (which uses OkHttp's MockWebServer
+ // internally) in ClientOAuthIntegrationTest.
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
+ private static final String KEEP_ALIVE_TIMER_THREAD_PREFIX = "Keep-Alive-Timer";
+ private static final String POOL_THREAD_PREFIX = "pool-";
Review Comment:
`pool-` is a bit too common I guess. Would you mind using a more specific name instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3391044827
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
Would you mind sharing the reasoning with us?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3411646687
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
Thanks for the explanation. Would you mind adding a comment for it? It would be good to point out which test spawn those threads.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3411417450
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
Is it an existing issue from before? Did you observe it just because the new framework has stricter constraints?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3392869194
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
MockOAuth2Server library internally uses OkHttp's MockWebServer, which spawns threads with the "MockWebServer" prefix. These threads may not be fully terminated by the time the thread leak check runs after each test, causing false-positive thread leak detection failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3428629797
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,16 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ // The following three thread prefixes are spawned by MockOAuth2Server (which uses OkHttp's MockWebServer
+ // internally) in ClientOAuthIntegrationTest.
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
+ private static final String KEEP_ALIVE_TIMER_THREAD_PREFIX = "Keep-Alive-Timer";
+ private static final String POOL_THREAD_PREFIX = "pool-";
Review Comment:
I tried to find a more specific name, but the leaked threads are named pool-N-thread-M, which is the default name produced by `Executors.defaultThreadFactory()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3504934509
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,16 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ // The following three thread prefixes are spawned by MockOAuth2Server (which uses OkHttp's MockWebServer
+ // internally) in ClientOAuthIntegrationTest.
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
+ private static final String KEEP_ALIVE_TIMER_THREAD_PREFIX = "Keep-Alive-Timer";
+ private static final String POOL_THREAD_PREFIX = "pool-";
Review Comment:
>Executors.defaultThreadFactory().
Could you share the code with me? It looks like a real leak?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Rewrite ClientOAuthIntegrationTest from Scala to Java [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #22520:
URL: https://github.com/apache/kafka/pull/22520#discussion_r3413991080
##########
test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java:
##########
@@ -108,10 +108,14 @@ public class ClusterTestExtensions implements TestTemplateInvocationContextProvi
private static final String ATTACH_LISTENER_THREAD_PREFIX = "Attach Listener";
private static final String PROCESS_REAPER_THREAD_PREFIX = "process reaper";
private static final String RMI_THREAD_PREFIX = "RMI";
+ private static final String MOCK_WEB_SERVER_THREAD_PREFIX = "MockWebServer";
Review Comment:
Sure, addressed it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org