Skip to content

[Java] Default avroRecordType to GENERIC_RECORD when not configured#519

Open
jvdadda wants to merge 2 commits intoawslabs:masterfrom
mobsuccess-devops:fix/avro-record-type-default
Open

[Java] Default avroRecordType to GENERIC_RECORD when not configured#519
jvdadda wants to merge 2 commits intoawslabs:masterfrom
mobsuccess-devops:fix/avro-record-type-default

Conversation

@jvdadda
Copy link
Copy Markdown

@jvdadda jvdadda commented Mar 12, 2026

Issue #, if available: Fixes #128

Description of changes:

When avroRecordType is not set in the Kafka Connect connector configuration, GlueSchemaRegistryConfiguration.avroRecordType is null. This null value is passed to DatumReaderInstance.from(), which performs a switch on it, causing a NullPointerException during deserialization.

The fix defaults avroRecordType to GENERIC_RECORD in GlueSchemaRegistryConfiguration, which is the safest default since GenericDatumReader works without requiring specific code-generated schema classes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Prevents NullPointerException in DatumReaderInstance.from() when
avroRecordType is not set in Kafka Connect configuration.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Kafka Connect deserialization NullPointerException by ensuring GlueSchemaRegistryConfiguration.avroRecordType is never null when the connector config omits avroRecordType, defaulting it to GENERIC_RECORD.

Changes:

  • Default GlueSchemaRegistryConfiguration.avroRecordType to AvroRecordType.GENERIC_RECORD when not configured.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jvdadda
Copy link
Copy Markdown
Author

jvdadda commented Mar 12, 2026

Addressed Copilot review: added assertion in testBuildConfig_valuesNotPassed_usesDefault verifying that getAvroRecordType() returns GENERIC_RECORD when AVRO_RECORD_TYPE is not configured (fcb9b98).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWSKafkaAvroConverter throws "java.lang.NullPointerException" in absence of "avroRecordType" in connector config

2 participants