Skip to content

HDDS-15868. Enable dynamic agent loading for tests#10816

Open
prathmesh12-coder wants to merge 1 commit into
apache:masterfrom
prathmesh12-coder:HDDS-15868
Open

HDDS-15868. Enable dynamic agent loading for tests#10816
prathmesh12-coder wants to merge 1 commit into
apache:masterfrom
prathmesh12-coder:HDDS-15868

Conversation

@prathmesh12-coder

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • In JDK 21, the JVM still allows dynamic agent loading, but emits a warning :
WARNING: A Java agent has been loaded dynamically (file:/u/bob/agent.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
  • In a future JDK release, dynamic agent loading will be disallowed by default. see (JEP 451)
  • In future release, dynamically loading an agent without -XX:+EnableDynamicAgentLoading may cause an exception to be thrown:
com.sun.tools.attach.AgentLoadException: Failed to load agent library: 
Dynamic agent loading is not enabled. Use -XX:+EnableDynamicAgentLoading 
to launch target VM.
  • Ozone unit tests use Mockito inline (mock-maker-inline), which causes ByteBuddy to dynamically attach its agent during Surefire runs. That triggers these warnings on JDK 21+
  • Added -XX:+EnableDynamicAgentLoading to maven-surefire-plugin.argLine in the root pom.xml which suppresses the JDK 21+ dynamic-agent warnings

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15868

How was this patch tested?

  • Manually tested :
    • reproduced :

      mvn -pl :hdds-container-service test -Dtest=TestStorageVolumeChecker -DskipShade -DskipRecon -DskipDocs
      
    • .../surefire-reports/*TestStorageVolumeChecker-output.txt contained dynamic-agent warnings shown above

      psapate@CWJC2KR9DP ozone % grep -A3 "Java agent has been loaded dynamically" hadoop-hdds/container-service/target/surefire-reports/*TestStorageVolumeChecker-output.txt
      
      WARNING: A Java agent has been loaded dynamically (/Users/psapate/.m2/repository/net/bytebuddy/byte-buddy-agent/1.18.11/byte-buddy-agent-1.18.11.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
      
    • after adding the -XX:+EnableDynamicAgentLoading to maven-surefire-plugin.argLine in the root pom.xml same command no longer emits those warnings and all 20 tests pass.

      psapate@CWJC2KR9DP ozone % grep -A3 "Java agent has been loaded dynamically" hadoop-hdds/container-service/target/surefire-reports/*TestStorageVolumeChecker-output.txt
      
  • CI success : https://github.com/prathmesh12-coder/ozone/actions/runs/29682107246

@anuragp010 anuragp010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good 👍

@sarvekshayr
sarvekshayr requested a review from adoroszlai July 20, 2026 12:30
@jojochuang
jojochuang requested a review from smengcl July 20, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants