Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support null data in nodes #4380

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

pjfanning
Copy link
Member

@pjfanning pjfanning commented Feb 13, 2024

relates to #4379

It may not be expected that these node types wrap nulls but our constructors let you create instances that wrap nulls. So unfortunately, we need to code for them.

There is an argument that we should fix the constructors to not allow null inputs.

@cowtowncoder
Copy link
Member

Looks good. 2 notes:

  1. Probably should also make hashCode() null-safe (similar to TextNode)
  2. Backport: maybe best to backport to 2.15, easy to then merge forward

Also: I will create another issue for preventing passing null as value for JsonNode types.

// we need a stable hash code for _value == null
return 0;
}
return Double.valueOf(doubleValue()).hashCode();
Copy link
Member

Choose a reason for hiding this comment

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

huh? Oh, that's how code already was. Ok. :)

Copy link
Member

Choose a reason for hiding this comment

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

But not sure why not use BigDecimal.hashCode(), fwtw.
Maybe something else to change in.... 2.17 I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

The pre-existing equals method is odd as well. It would be easier to use .equals on the BigDecimal instances.

Copy link
Member

Choose a reason for hiding this comment

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

compareTo and the special hashCode are necessary here because BigDecimal equality is weird wrt scaling. 1.9 and 1.90 are considered unequal by BigDecimal but equal by this DecimalNode impl.

Copy link
Member

Choose a reason for hiding this comment

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

Ok; will then leave that as-is.

@pjfanning pjfanning changed the base branch from 2.17 to 2.15 February 13, 2024 20:42
@pjfanning pjfanning force-pushed the more-null-node-equals branch from d4753f0 to 39305f9 Compare February 13, 2024 20:45
@pjfanning
Copy link
Member Author

Looks good. 2 notes:

  1. Probably should also make hashCode() null-safe (similar to TextNode)
  2. Backport: maybe best to backport to 2.15, easy to then merge forward

Also: I will create another issue for preventing passing null as value for JsonNode types.

@cowtowncoder retargeted to 2.15 branch

@cowtowncoder cowtowncoder merged commit a9e9a8d into FasterXML:2.15 Feb 14, 2024
4 checks passed
@cowtowncoder
Copy link
Member

Thank you @pjfanning ! I merged; did minor clean up for 2.17, some more for 3.0 and planning to do #4381 tomorrow, to prevent wrapping of null except for POJONode (where null sort of makes sense).

@pjfanning pjfanning deleted the more-null-node-equals branch February 14, 2024 08:32
Philzen pushed a commit to Philzen/jackson-databind that referenced this pull request Apr 26, 2024
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.

3 participants