This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7fe9d2b  use throw instead of confusing return null inside catch
7fe9d2b is described below

commit 7fe9d2bcbfef2374aa4097748d66d9ac5caa78ca
Author: Michael Vorburger <[email protected]>
AuthorDate: Sat May 2 20:44:25 2020 +0200

    use throw instead of confusing return null inside catch
    
    in JournalEntryWritePlatformServiceJpaRepositoryImpl
---
 ...rnalEntryWritePlatformServiceJpaRepositoryImpl.java | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java
index 1a835d9..1bd805d 100755
--- 
a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java
@@ -217,8 +217,7 @@ public class 
JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
             return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(officeId)
                     .withTransactionId(transactionId).build();
         } catch (final DataIntegrityViolationException dve) {
-            handleJournalEntryDataIntegrityIssues(dve);
-            return null;
+            throw handleJournalEntryDataIntegrityIssues(dve);
         }
     }
 
@@ -539,7 +538,9 @@ public class 
JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
             String transactionId = 
AccountingProcessorHelper.SHARE_TRANSACTION_IDENTIFIER + 
shareTransactionId.longValue();
             List<JournalEntry> journalEntries = 
this.glJournalEntryRepository.findJournalEntries(transactionId,
                     PortfolioProductType.SHARES.getValue());
-            if (journalEntries == null || journalEntries.isEmpty()) continue;
+            if (journalEntries == null || journalEntries.isEmpty()) {
+                continue;
+            }
             final Long officeId = journalEntries.get(0).getOffice().getId();
             final String reversalTransactionId = 
generateTransactionId(officeId);
             for (final JournalEntry journalEntry : journalEntries) {
@@ -637,10 +638,10 @@ public class 
JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
         return transactionId;
     }
 
-    private void handleJournalEntryDataIntegrityIssues(final 
DataIntegrityViolationException dve) {
+    private PlatformDataIntegrityException 
handleJournalEntryDataIntegrityIssues(final DataIntegrityViolationException 
dve) {
         final Throwable realCause = dve.getMostSpecificCause();
         logger.error("Error occured.", dve);
-        throw new 
PlatformDataIntegrityException("error.msg.glJournalEntry.unknown.data.integrity.issue",
+        return new 
PlatformDataIntegrityException("error.msg.glJournalEntry.unknown.data.integrity.issue",
                 "Unknown data integrity issue with resource Journal Entry: " + 
realCause.getMessage());
     }
 
@@ -691,8 +692,7 @@ public class 
JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
             return new 
CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(officeId)
                     .withTransactionId(transactionId).build();
         } catch (final DataIntegrityViolationException dve) {
-            handleJournalEntryDataIntegrityIssues(dve);
-            return null;
+            throw handleJournalEntryDataIntegrityIssues(dve);
         }
     }
 
@@ -773,7 +773,9 @@ public class 
JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
 
         @Override
         public boolean equals(Object obj) {
-            if (!obj.getClass().equals(this.getClass())) return false;
+            if (!obj.getClass().equals(this.getClass())) {
+                return false;
+            }
             OfficeCurrencyKey copy = (OfficeCurrencyKey) obj;
             return Objects.equals(this.office.getId(), copy.office.getId()) && 
this.currency.equals(copy.currency);
         }

Reply via email to