Skip to content

fix: handle null Java values for absent JSON fields - #6

Merged
gregory-bonaventure merged 1 commit into
mainfrom
fix/null-safety
Feb 22, 2026
Merged

fix: handle null Java values for absent JSON fields#6
gregory-bonaventure merged 1 commit into
mainfrom
fix/null-safety

Conversation

@gregory-bonaventure

Copy link
Copy Markdown
Contributor

Summary

  • Fix NPE when a JSON field is absent from the object (e.g. optional margin_rate in Kraken assets)
  • Map.get() returns Java null for absent keys, but JsonMapper methods only checked for JsonNull
  • All nullable-return methods (toString, toBigDecimal, toBigInteger, toEnum, toList, toMap, boxed types) now treat null the same as JsonNull
  • Primitive methods (toInt, toLong, toDouble, toFloat, toBoolean) throw a clear error message instead of NPE

Test plan

  • All 62 existing tests pass
  • Fixes NullPointerException in KrakenAssetJsonAdapter.fromJson when margin_rate is absent

🤖 Generated with Claude Code

When a JSON field is absent from the object, Map.get() returns Java
null (not JsonNull). All JsonMapper methods now treat null the same
as JsonNull — returning null for nullable types and throwing a clear
error for primitive types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gregory-bonaventure
gregory-bonaventure merged commit dd08865 into main Feb 22, 2026
1 check failed
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.

1 participant