3525: AVRO-4189: [java] Simplify the setting of the serializable classes#10
3525: AVRO-4189: [java] Simplify the setting of the serializable classes#10martin-augment wants to merge 4 commits intomainfrom
Conversation
PR Review: AVRO-4189SummaryThis PR introduces ClassSecurityValidator to centralize class security validation. Good refactoring with backward compatibility maintained. High Priority Issues1. Thread Safety (ClassSecurityValidator.java:70)setGlobal() modifies static variable without synchronization - potential race condition. 2. Package Matching Bug (ClassSecurityValidator.java:250-251)False positives possible: "com.example." would match "com.example2.BadClass". Medium Priority Issues
Strengths
Security Notes
Test CoverageMissing: Concurrent access test for setGlobal()/getGlobal() RecommendationSolid refactoring but needs fixes for thread safety and package matching before merge. Generated with Claude Code |
| import java.math.BigDecimal; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertThrows; |
There was a problem hiding this comment.
Consider using JUnit 5’s Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows) instead of org.junit.Assert.assertThrows to align with the JUnit Jupiter @Test and avoid requiring JUnit 4.13 on the classpath.
🤖 React with 👍 or 👎 to let us know if the comment was useful.
There was a problem hiding this comment.
value:valid-but-wont-fix; category:typo; feedback:using JUnit 5.x only APIs would be preferred but the old tests already use the JUnit 4.x assertEquals method in several places. The migration to JUnit 5.x could be done in a separate commit.
| private static final String SYSPROP_SERIALIZABLE_PACKAGES = "org.apache.avro.SERIALIZABLE_PACKAGES"; | ||
|
|
||
| static { | ||
| // add the hard-coded trusted classes as well |
There was a problem hiding this comment.
The comment "add the hard-coded trusted classes as well" appears misleading here: the defaults aren’t added to SERIALIZABLE_CLASSES, they’re combined via DEFAULT = composite(DEFAULT_TRUSTED_CLASSES, SYSTEM_PROPERTIES). Consider updating the comment to reflect that.
🤖 React with 👍 or 👎 to let us know if the comment was useful.
There was a problem hiding this comment.
value:good-to-have; category:documentation; feedback:The comment is indeed wrong. The hardcoded classes are defined with DEFAULT_TRUSTED_CLASSES at line 117. The comment is about the extra classes provided with system properties.
These issues block merging; once the branch is rebased and the unintended regressions are cleared up we can take another look at the functional changes. |
3525: To review by AI