Skip to content

Document why OkHttpUtils's NoSuchMethodError catch isn't a ClassLatch candidate - #12719

Closed
dougqh wants to merge 1 commit into
dougqh/abstract-method-guardfrom
dougqh/classlatch-okhttp
Closed

dougqh wants to merge 1 commit into
dougqh/abstract-method-guardfrom
dougqh/classlatch-okhttp

Conversation

@dougqh

@dougqh dougqh commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of the APMLP-1895 scan for sites that could benefit from ClassLatch (#12702, unmerged — this PR is stacked on it). Evaluated OkHttpUtils.buildHttpClient's catch (NoSuchMethodError e) around eventListenerFactory(...) and concluded it's not a good candidate, for two independent reasons confirmed in code:

  • Cold path. buildHttpClient is called once per component construction (writer, telemetry client, profiling uploader, crash uploader, AI Guard, etc.), never per request. There's no repeated-failure-per-class cost to amortize.
  • Production-safe already. The comment's claim checks out: dd-java-agent/build.gradle relocates the entire okhttp3 package to datadog.okhttp3 in the shaded agent jar. In a real deployed agent there is no okhttp3 classpath collision possible at all — the catch can only ever fire in this module's own unshaded test builds, where a different okhttp3 version can land on the test classpath.

No behavior change. Added a short comment documenting the evaluation so this doesn't get re-flagged by a future scan.

Test plan

  • ./gradlew spotlessApply
  • ./gradlew :communication:test --tests "*OkHttpUtils*" — pass (default, JDK 8, JDK 11)

🤖 Generated with Claude Code

…candidate

Evaluated as part of the APMLP-1895 scan for ClassLatch candidates:
buildHttpClient runs once per component (writer, telemetry, profiling,
etc.), not per request, and the shaded agent jar relocates okhttp3
entirely, so this catch can never fire outside this module's own
unshaded test builds.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core type: documentation tag: no release notes Changes to exclude from release notes tag: ai generated Largely based on code generated by an AI or LLM labels Oct 1, 2026
@dougqh

dougqh commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the catch here only fires in this module's own unshaded test builds (okhttp3 is relocated to datadog.okhttp3 in the shaded agent jar), so there's no real per-class repeated-failure cost in production to amortize with ClassLatch. Leaving the plain catch in place.

@dougqh dougqh closed this Oct 1, 2026
@dougqh
dougqh deleted the dougqh/classlatch-okhttp branch October 1, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant