Skip to content

FINERACT-839: NPE when creating a Loan for a client fix#696

Merged
awasum merged 1 commit intoapache:developfrom
adamsaghy:bugfix/loanproductdata
Jan 23, 2020
Merged

FINERACT-839: NPE when creating a Loan for a client fix#696
awasum merged 1 commit intoapache:developfrom
adamsaghy:bugfix/loanproductdata

Conversation

@adamsaghy
Copy link
Contributor

Description

Describe the changes made and why they were made. Ignore if these details are present on the associated Jira ticket

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

Our guidelines for code reviews is at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

Make sure this passes Spotbugs checks on your local machine.

Lets wait for Travis to build.

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

On your local machine, run ./gradlew clean check build and make sure checkstyle and spotbugs rules are not voilated.

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

Then squash your commits into one when done.

@adamsaghy
Copy link
Contributor Author

The problem is the SpotBug is a little bit too restrictive:
Bad practice Warnings
Code Warning
NP org.apache.fineract.portfolio.loanproduct.data.LoanProductData.isCompoundingToBePostedAsTransaction() has Boolean return type and returns explicit null
Details
NP_BOOLEAN_RETURN_NULL: Method with Boolean return type returns explicit null
A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.

Before the spotBug the business logic required to return null...as it is a valid option from business perspective.

Do you have any advice?

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

The problem is the SpotBug is a little bit too restrictive:
Bad practice Warnings
Code Warning
NP org.apache.fineract.portfolio.loanproduct.data.LoanProductData.isCompoundingToBePostedAsTransaction() has Boolean return type and returns explicit null
Details
NP_BOOLEAN_RETURN_NULL: Method with Boolean return type returns explicit null
A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.

Before the spotBug the business logic required to return null...as it is a valid option from business perspective.

Do you have any advice?

Maybe we add a spotbugs exception to omit checks of this type..Or just for this case in the code base.

@vorburger some help please.

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

What is wron with instead of returning Null we instead do return Boolean.FALSE;, will this still cause issues?

@adamsaghy
Copy link
Contributor Author

From business perspective it is different to return FALSE or NULL. I reckon there was a consideration to choose Boolean as object to make it able to return NULL.

A warning would be better.

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

From business perspective it is different to return FALSE or NULL. I reckon there was a consideration to choose Boolean as object to make it able to return NULL.

A warning would be better.

Ok...In your PR..Suppress spotbugs for the methods having the error..Just above it, place the statement: @FindBugsSuppressWarnings("NP_BOOLEAN_RETURN_NULL") and spotbug check will ignore it.

@adamsaghy adamsaghy closed this Jan 23, 2020
@adamsaghy adamsaghy reopened this Jan 23, 2020
@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

Have u functionally tested this and the problem has gone away? @adamsaghy . I dont have the right environment to test. If everything is fine on your end..let me know to merge this since every spotbugs and checkstyle test is also passing.

Thanks for your patience.

@adamsaghy
Copy link
Contributor Author

I did a quick test as now I was able to open a Loan to the client but havent checked all the iteration.
Basically it is a revert back to the original business logic , which we had before the introduced spotbugs changes.

@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

I did a quick test as now I was able to open a Loan to the client but havent checked all the iteration.
Basically it is a revert back to the original business logic , which we had before the introduced spotbugs changes.

Please...check everything and let us know if this is Ok to be merged.

@adamsaghy
Copy link
Contributor Author

As it worked for 3 years before the spotbugs commit, and we just reverted back to the original behaviour, in my opinion it is safe to merge. ;)

@awasum awasum merged commit dfcad32 into apache:develop Jan 23, 2020
@awasum
Copy link
Contributor

awasum commented Jan 23, 2020

Send more PRs as you identify bugs. Thanks

@adamsaghy adamsaghy deleted the bugfix/loanproductdata branch January 23, 2020 15:33
@vorburger
Copy link
Member

What is wron with instead of returning Null we instead do return Boolean.FALSE;, will this still cause issues?

That's what I would have suggested as well... have commented in FINERACT-839.

@adamsaghy are you motivated to raise a follow-up PR for that?

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