Repository navigation
Fix discriminator state leaking between alternative branches - #1379
Conversation
|
Review of head 1. Quadratic cost on arrays of discriminated items (
A payload of a few thousand polymorphic items becomes about 70x slower. Suggestion: keep an append-only creation log in 2. The non-validating walk loops do nothing ( 3. API shape ( 4. Test gaps ( 5. CHANGELOG ( The same points apply to #1380, which has identical code. |
|
Review of the uncommitted follow-up on 1. The journal hooks only 2. OpenAPI 3.1 is affected too ( 3. Duplicated validate/walk dispatch ( 4. Scale test does not exercise the journal path ( |
|
Second follow-up on the uncommitted working tree for Checked: 1. The scale test cannot see scans inside 2. Two public 3. Seven-method anonymous map, and changed gating ( |
|
Third and fourth follow-ups on the uncommitted working tree for The earlier findings are addressed: the scale tests now count operations on the actual backing map and assert linear growth, the callback/dispatch overloads are replaced by a scope API with a shared no-op scope, Checked: the discriminator tests, One minor point remains. The scale test mutates a final field by reflection ( |
Fixes #1378. Nested OpenAPI 3.0 discriminators in sibling alternatives could throw SchemaException when the same value mapped to different schemas. Snapshot discriminator locations before each oneOf/anyOf branch and discard newly recorded descendant state afterward, in both validation and walk loops. Preserve same-location and pre-existing state; allOf and DiscriminatorValidator remain unchanged.
Regression coverage uses the issue document and all four instances with outer oneOf and anyOf. Both variants reproduced the exception before the fix. Full offline suite passed: 10,595 tests, 0 failures/errors, 30 skipped (
mvn -o -q test -Dversion.maven-surefire=3.6.0; pinned 3.6.1 is unavailable offline). Existing Issue1270 and same-location discriminator guards pass. GitNexus impact and compare-to-master detection reported LOW risk.Known limitation: alternative branches defining discriminators at the outer validator's own instance location can still throw; this remains undefined behavior.