Skip to content

Attach Mockito as an agent #12749

@scholzj

Description

@scholzj

When running some tests using Mockito we get the following warning:

Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
WARNING: A Java agent has been loaded dynamically (/Users/scholzj/.m2/repository/net/bytebuddy/byte-buddy-agent/1.17.7/byte-buddy-agent-1.17.7.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

Steps to reproduce:

  • Go to cluster-operator
  • Run mvn test -Dtest=io.strimzi.operator.cluster.operator.assembly.KafkaListenerReconcilerRoutesTest
  • Check the output

I tried to fix it in #12748 but it does not seem to be so simple. The PR fixes the warnings in the tests where it was raised. But it seems to break other tests/modules. So maybe we need to apply it on module-by-module basis. So this issue should be used to keep track of it. This is not urgent as we have no plans to move beyond Java 21 right now, but it would be nice to be prepared.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions