Repository navigation
AVRO-4362: [java] Avoid retaining default name validator - #4100
Open
hutiefang76 wants to merge 1 commit into
Open
hutiefang76 wants to merge 1 commit into
hutiefang76 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
cd lang/java && mvn -Dmaven.build.cache.enabled=false -pl avro -am clean verifysucceeds, 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 testsucceeds 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.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
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.