mimaison commented on code in PR #18339:
URL: https://github.com/apache/kafka/pull/18339#discussion_r2378618891


##########
build.gradle:
##########
@@ -484,11 +484,36 @@ subprojects {
     }
   }
 
+  // Workaround for Mockito Java Agent restrictions in Java 21+
+  // Starting with Java 21, the JDK restricts libraries from attaching a Java 
agent
+  // to their own JVM. As a result, Mockito’s inline mock maker (mockito-core)
+  // fails without explicit instrumentation, and the JVM consistently emits 
warnings.
+  // See also: 
https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#mockito-instrumentation
+  afterEvaluate { subproject ->
+    def hasMockitoCore = subproject.configurations.findAll {
+      it.canBeResolved
+    }.any { config ->
+      config.incoming.dependencies.any { dependency ->
+        "${dependency.group}:${dependency.name}" == "org.mockito:mockito-core"

Review Comment:
   Could we use:
   ```
   "$dependency" == libs.mockitoCore
   ```
   to avoid hardcoding org.mockito:mockito-core?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to