Skip to content

fix: check field value is non-null in GenericData.containsKey - #2191

Merged
blakeli0 merged 2 commits into
mainfrom
fix-genericdata-containskey
Oct 9, 2026
Merged

blakeli0 merged 2 commits into
mainfrom
fix-genericdata-containskey

Conversation

@blakeli0

@blakeli0 blakeli0 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2187

In GenericData, declared @Key fields with null values are treated as absent from the map (excluded from entrySet() and keySet()). PR #2151 changed GenericData.containsKey(Object) to check classInfo.hasFieldInfo(fieldName), which returned true even when the declared field's value on the instance was null, violating the Map/Set contract and breaking callers checking field presence.

Update GenericData.containsKey(Object) to check fieldInfo.getValue(this) != null when fieldInfo != null, matching DataMap.containsKey() and GenericData.entrySet().

The pom changes are unrelated to the fix but they are required to pass the CI. Because Github runner recently upgraded to Maven 3.10 which errors out on duplicated plugin configurations.

@blakeli0
blakeli0 requested a review from a team as a code owner October 9, 2026 17:51
@product-auto-label product-auto-label Bot added the size: s Pull request size is small. label Oct 9, 2026
@blakeli0
blakeli0 requested a review from whowes October 9, 2026 18:38
@blakeli0
blakeli0 merged commit 3a590c1 into main Oct 9, 2026
28 checks passed
@blakeli0
blakeli0 deleted the fix-genericdata-containskey branch October 9, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GenericData.containsKey() returns true for unset (null) declared fields, violating Map contract

2 participants