Skip to content

AVRO-4362: [java] Avoid retaining default name validator - #4100

Open
hutiefang76 wants to merge 1 commit into
apache:mainfrom
hutiefang76:AVRO-4362-validator-scope
Open

hutiefang76 wants to merge 1 commit into
apache:mainfrom
hutiefang76:AVRO-4362-validator-scope

Conversation

@hutiefang76

Copy link
Copy Markdown

What is the purpose of the change

Fix AVRO-4362: validating a name on a long-lived thread currently retains an Avro validator object and its classloader.

Use a plain thread-local with a UTF validator fallback instead of storing the default validator. Parser cleanup removes an unset scope or restores the exact previous validator, including when closing the JSON parser throws. Custom and reentrant parser scopes retain their existing behavior.

Verifying this change

This change adds 12 regression tests for default construction, valid/invalid names, successful and failing parses, custom validator restoration, reentrant parsing, and parser-close failures. On the original implementation, nine assertions fail; the same tests pass with this change.

  • The 12 new tests and 65 neighboring tests pass in each of the three configured core modes, with no skips.
  • cd lang/java && mvn -Dmaven.build.cache.enabled=false -pl avro -am clean verify succeeds, including the official JDK 11, 17, and 21 Invoker runs. All 12 new tests pass on each JDK; the existing Invoker suites report 6, 7, and 8 skips respectively.
  • cd lang/java && mvn -Dmaven.build.cache.enabled=false clean test succeeds across all 26 Java modules. Final XML reports contain 4,256 passes, 8 skips, and no failures or errors. Repeated core modes are not counted as distinct cases.
  • A separate bounded classloader probe on JDK 11, 17, and 21 retains the loader before the fix and collects it after the fix. Explicit-removal and terminated-thread controls collect it in both versions. The probe is separate from the deterministic JUnit tests.

Maven runs on JDK 21 with Java 11 release compatibility; the main unit-test toolchain is JDK 17. Other language SDKs were not run.

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

AI disclosure

The code, regression tests, and this description were generated with DeepSeek V4 Pro and OpenAI Codex. The local test results above were executed against this revision.

Use the default name validator without retaining an Avro object in the
calling thread's ThreadLocal. Restore the prior parser scope even when
closing the JSON parser fails.

Add coverage for default, custom, reentrant and failing parse scopes.

Generated-by: DeepSeek deepseek-v4-pro
Generated-by: OpenAI Codex
@github-actions github-actions Bot added the Java Pull Requests for Java binding label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant