vorburger commented on a change in pull request #683: FINERACT-824: 
NullPointerException is thrown when submitting a loan account application with 
an existing externalId
URL: https://github.com/apache/fineract/pull/683#discussion_r365602700
 
 

 ##########
 File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
 ##########
 @@ -1036,12 +1036,11 @@ else if(existingLoanApplication.getGroup() != null){
      */
     private void handleDataIntegrityIssues(final JsonCommand command, final 
Throwable realCause, final Exception dve) {
        
-        if (realCause.getMessage().contains("loan_account_no_UNIQUE") || 
realCause.getCause().getMessage().contains("loan_account_no_UNIQUE")) {
-
+        if (realCause.getMessage().contains("loan_account_no_UNIQUE")) {
             final String accountNo = 
command.stringValueOfParameterNamed("accountNo");
             throw new 
PlatformDataIntegrityException("error.msg.loan.duplicate.accountNo", "Loan with 
accountNo `" + accountNo
                     + "` already exists", "accountNo", accountNo);
-        } else if (realCause.getMessage().contains("loan_externalid_UNIQUE") 
|| realCause.getCause().getMessage().contains("loan_externalid_UNIQUE")) {
 
 Review comment:
   @angelboxes I don't know much about this code, but it looks like someone 
thought that it would be useful to also check the cause... your 
[FINERACT-824](https://issues.apache.org/jira/browse/FINERACT-824) indicates 
that this can lead to NPEs, so instead of just completely removing the 
`getCause()` related check, do you think it may be a good idea to check it like 
this (for both):
   
       } else if (realCause.getMessage().contains("loan_externalid_UNIQUE") || 
(realCause.getCause() != null && 
realCause.getCause().getMessage().contains("loan_externalid_UNIQUE"))) {
   
   Just a thought, as this would perhaps seem more prudent in case that extra 
check for the cause was there for a good reason. If you are totally confident 
that this cause is never set and always null, then this is also OK for me, but 
I thought it would be worth to clarify?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to