Skip to content

Conversation

@timyates
Copy link
Contributor

Where possible this commit switches from Boolean class parameters to primitive booleans.

The problem with Boolean is that it introduces 3 states, TRUE, FALSE and null.

Where the contract has a Nullable requirement, I have updated the if statements, as if (obj.nullableMember()) { will throw a null pointer exception if the Boolean result is null. The safe replacement is if (Boolean.TRUE.equals(obj.nullableMember())) {

Where possible this commit switches from `Boolean` class parameters to primitive booleans.

The problem with `Boolean` is that it introduces 3 states, TRUE, FALSE and null.

And if you have a comparator such as `if (svc.returnsBoolean())` and the method returns null, you get a NPE
@timyates timyates requested a review from mkimberlin June 17, 2024 11:31
@timyates timyates self-assigned this Jun 17, 2024
@timyates timyates requested a review from vhscom June 17, 2024 15:39
Copy link
Member

@mkimberlin mkimberlin left a comment

Choose a reason for hiding this comment

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

I'm not going to lie. This makes me a little sad. I have a personal hatred of primitives in Java.

@timyates
Copy link
Contributor Author

Unexpected NullPointerExceptions are worse imho 😉

@timyates timyates merged commit c59ee03 into develop Jun 18, 2024
@timyates timyates deleted the bugfix-remove-unrequired-Boolean-class-params branch June 18, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants