Restore the no-arg constructors the Moshi reflective adapters require - #12566
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@codex review |
|
@DataDog review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
More details
Each Moshi-reflective AppSec DTO has a declared no-argument constructor. Adapter creation no longer needs sun.misc.Unsafe.
🤖 Datadog Autotest · Commit e339030 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
There was a problem hiding this comment.
More details
All classes that Moshi creates now have a no-argument constructor. The contract test includes each class that the two reflective adapters use.
🤖 Datadog Autotest · Commit e339030 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for 18d28a1: What to do next?
DetailsSince those jobs are not marked as being allowed to fail, the pipeline will most likely fail. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
c57b5a5
into
master
What Does This Do
Restores the no-arg constructors that Moshi's reflective adapters need:
WAFResultDataand its four nested DTOs (Rule,RuleMatch,Parameter,MatchInfo)AppSecEventWrapperAdds a unit test asserting the contract for every class reached by those adapters, and documents on both classes why the constructors must stay.
Motivation
On a JVM that does not resolve the
jdk.unsupportedmodule, AppSec fails to start:Moshi's reflective adapter instantiates bound classes through a declared no-arg constructor and falls back to
sun.misc.Unsafe.allocateInstancewhen there isn't one.sun.misc.Unsafelives injdk.unsupported, so on a runtime without that module the fallback is gone and building the adapter throws — taking down AppSec startup fromWAFModule's static initializer.#12118 removed those constructors on the stated basis that the
Unsafefallback made them unnecessary. That holds on a standard JVM but not on a trimmed one, so the failure shipped in 1.66.0.AppSecEventWrapperhas had the same flaw sincedcc4363dc(2021): declaringAppSecEventWrapper(Collection)removed its implicit no-arg constructor. Its adapter is only built on the first WAF match, atGatewayBridge.java:1042, so fixing only the WAF DTOs would have moved the crash from startup to the first attack report rather than removing it.Additional Notes
Alternatives checked against a JVM run with
--limit-modules java.base, all rejected:Serializabledoes not help — Moshi's other fallback needsObjectStreamClass.getConstructorId, which exists only on Android; OpenJDK has no such method, so the branch can never fire.JsonAdapter, a customJsonAdapter.Factoryinvoking the canonical constructor, and our in-house reflection-freedatadog.jsonall work, but each replaces Moshi's automatic binding with parsing code we maintain by hand. Five empty constructors on the path Moshi checks first are cheaper. Thedatadog.jsonmigration has value on its own and is worth a separate ticket.AppSecEventWrapper's adapter is only ever used to serialize, but Moshi resolves the instantiation strategy when the adapter is built, not when it is used, so serialize-only does not exempt it.Roughly 115 other Moshi reflective-adapter sites outside AppSec (ci-visibility, debugger, crashtracking, remote-config, telemetry, llmobs, feature-flagging) are unaudited and may carry the same latent issue. Out of scope here.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueJira ticket: APPSEC-70182
🤖 Generated with Claude Code