Skip to content

Alternate approach to #797: warn-and-skip instead of throw on null input (Fixed #750)#807

Open
sappenin wants to merge 3 commits into
mainfrom
df/alt-AffectedNodeDeserializer-npe
Open

Alternate approach to #797: warn-and-skip instead of throw on null input (Fixed #750)#807
sappenin wants to merge 3 commits into
mainfrom
df/alt-AffectedNodeDeserializer-npe

Conversation

@sappenin

@sappenin sappenin commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

The current code and the approach proposed in #797 both throw on invalid input. This PR takes a different stance: log a warning and skip the offending entry rather than failing hard. The rationale: rippled should never produce a null JSON value, but in practice it doesn't always behave the way Java expects — particularly around null inputs.

Changes:
AffectedNodeDeserializer: when LedgerEntryType is absent from a CreatedNode, ModifiedNode, or DeletedNode payload, the deserializer now warns and skips rather than propagating an exception.

Exception behavior fix: MismatchedInputException is now thrown (instead of NullPointerException) when LedgerEntryType is missing — correcting the existing error type regardless of the null-input path
AffectedNodeDeserializerTest: added unit tests, which were previously absent entirely

Signed-off-by: David Fuelling <sappenin@gmail.com>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.52%. Comparing base (4871032) to head (b6d5c86).

Files with missing lines Patch % Lines
...odel/jackson/modules/AffectedNodeDeserializer.java 97.05% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #807      +/-   ##
============================================
+ Coverage     93.51%   93.52%   +0.01%     
- Complexity     2606     2617      +11     
============================================
  Files           486      487       +1     
  Lines          6580     6607      +27     
  Branches        566      570       +4     
============================================
+ Hits           6153     6179      +26     
  Misses          270      270              
- Partials        157      158       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
AffectedNode node = elementDeserializer.deserialize(jsonParser, ctxt);
if (node != null) {
result.add(node);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TODO: An else block should warn if node == null

@sappenin sappenin self-assigned this Jun 16, 2026
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