Conversation
WalkthroughField constructors in Schema.java updated to pass a boolean parameter to JacksonUtils.toJsonNode. Two new toJsonNode method overloads added to JacksonUtils with schema context flag. Bytes serialization behavior modified based on schema context flag. Test coverage added for byte array default fields. Changes
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code graph analysis (2)lang/java/avro/src/main/java/org/apache/avro/util/internal/JacksonUtils.java (1)
lang/java/avro/src/main/java/org/apache/avro/Schema.java (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review - AVRO-4197 Fix schema bytes defaultsThank you for this contribution! This PR addresses an important issue with how byte array default values are handled in schema field definitions. Here's my detailed review: ✅ Positive Aspects
🔍 Code Quality ObservationsSchema.java (lines 616, 626)
JacksonUtils.java (lines 60-120)
TestSchema.java (lines 236-243)
🤔 Potential Issues & Concerns
🔒 Security ConsiderationsNo security concerns identified. The use of ISO-8859-1 encoding is appropriate for Avro byte string representation. ⚡ Performance ConsiderationsThe changes add minimal overhead (one boolean parameter and conditional check). Performance impact is negligible. 📝 Recommendations
SummaryThis is a solid fix that addresses a real issue with byte array defaults in schema fields. The implementation is clean and maintains backward compatibility. With the addition of a few more tests and minor improvements, this would be ready to merge. Recommendation: Approve with minor changes suggested above. Review generated with assistance from Claude Code |
| Schema.Field field = new Schema.Field("bytesField", Schema.create(Schema.Type.BYTES), "my bytes field", defaultBytes); | ||
| Schema rSchema = Schema.createRecord("myRecord", "myRecord docs", "me", false, List.of(field)); | ||
| GenericData.Record rec = new GenericRecordBuilder(rSchema).build(); | ||
| assertArrayEquals(((ByteBuffer) rec.get("bytesField")).array(), defaultBytes); |
There was a problem hiding this comment.
Consider swapping the parameters to assertArrayEquals so it’s expected, actual; JUnit uses this order and it improves failure messages.
🤖 Was this useful? React with 👍 or 👎
There was a problem hiding this comment.
value:good-to-have; category:bug; feedback: The Augment AI reviewer is correct that the arguments are swapped. In case of non equal values they will be reported wrongly by JUnit library.
|
Findings
Everything else in the diff looks consistent with the goal of emitting ISO-8859-1 strings for schema-time byte defaults, and the new unit test covers the regression path. |
3543: To review by AI
Note
Ensures bytes default values are encoded as strings when building schemas and adds a unit test validating default byte[] handling.
Schema.Fieldconstructors, route default values throughJacksonUtils.toJsonNode(..., true)so bytes defaults are encoded for schema context.toJsonNode(object, boolean inSchemaContext)and propagateinSchemaContextthroughtoJson(...).inSchemaContextis true, serializebyte[]as ISO-8859-1 strings; otherwise keep binary.TestSchema.byteArrayDefaultFieldto assert defaultbytesfields materialize correctly asByteBuffercontents.Written by Cursor Bugbot for commit bd96b04. This will update automatically on new commits. Configure here.