You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "Satish11012007 (via GitHub)" <gi...@apache.org> on 2026/02/06 13:15:46 UTC
[PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Satish11012007 opened a new pull request, #5454:
URL: https://github.com/apache/fineract/pull/5454
This PR fixes a potential NullPointerException in
determineInterestPostingPeriods by safely handling null inputs.
The project builds successfully.
<img width="1902" height="964" alt="image" src="https://github.com/user-attachments/assets/0cd7ffd5-3f46-4475-8a58-37991aa9a805" />
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "airajena (via GitHub)" <gi...@apache.org>.
airajena commented on PR #5454:
URL: https://github.com/apache/fineract/pull/5454#issuecomment-3873042129
@Satish11012007 , please sign your commit and also fix the PR title.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266: Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #5454:
URL: https://github.com/apache/fineract/pull/5454
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5454:
URL: https://github.com/apache/fineract/pull/5454#discussion_r2816553890
##########
.gitignore:
##########
Review Comment:
What did you change here?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "Satish11012007 (via GitHub)" <gi...@apache.org>.
Satish11012007 commented on PR #5454:
URL: https://github.com/apache/fineract/pull/5454#issuecomment-3860484280
This PR fixes one of the potential NPE scenarios related to FINERACT-932.
Other cases tracked under the parent issue may still remain.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266: Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #5454:
URL: https://github.com/apache/fineract/pull/5454#issuecomment-3914172340
@Satish11012007 Please squash your commits and make sure the commit message is correct. THe 1st commit message are missing the : after the `FINERACT-1266` part.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "Satish11012007 (via GitHub)" <gi...@apache.org>.
Satish11012007 closed pull request #5454: FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods
URL: https://github.com/apache/fineract/pull/5454
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5454:
URL: https://github.com/apache/fineract/pull/5454#discussion_r2816550376
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -40,96 +41,128 @@ public final class SavingsHelper {
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
+ private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
@Autowired
public SavingsHelper(AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
}
- private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
+ // FIXED METHOD (FINERACT-1266)
Review Comment:
Please remove the AI generated, useless comments!
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -40,96 +41,128 @@ public final class SavingsHelper {
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
+ private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
@Autowired
public SavingsHelper(AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
}
- private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
+ // FIXED METHOD (FINERACT-1266)
+
- public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
- final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType,
- final Integer financialYearBeginningMonth, List<LocalDate> postInterestAsOn) {
+ public List<LocalDateInterval> determineInterestPostingPeriods(
+ final LocalDate startInterestCalculationLocalDate,
+ final LocalDate interestPostingUpToDate,
+ final SavingsPostingInterestPeriodType postingPeriodType,
+ final Integer financialYearBeginningMonth,
+ List<LocalDate> postInterestAsOn) {
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
if (startInterestCalculationLocalDate == null || interestPostingUpToDate == null) {
return postingPeriods;
}
+ // 🔐 Null-safe list
Review Comment:
Please remove the AI generated, useless comments!
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -40,96 +41,128 @@ public final class SavingsHelper {
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
+ private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
@Autowired
public SavingsHelper(AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
}
- private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
+ // FIXED METHOD (FINERACT-1266)
+
- public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
- final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType,
- final Integer financialYearBeginningMonth, List<LocalDate> postInterestAsOn) {
+ public List<LocalDateInterval> determineInterestPostingPeriods(
+ final LocalDate startInterestCalculationLocalDate,
+ final LocalDate interestPostingUpToDate,
+ final SavingsPostingInterestPeriodType postingPeriodType,
+ final Integer financialYearBeginningMonth,
+ List<LocalDate> postInterestAsOn) {
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
if (startInterestCalculationLocalDate == null || interestPostingUpToDate == null) {
return postingPeriods;
}
+ // 🔐 Null-safe list
+ if (postInterestAsOn == null) {
+ postInterestAsOn = Collections.emptyList();
+ }
+
+ // 🔐 Null-safe posting period
Review Comment:
Please remove the AI generated, useless comments!
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -40,96 +41,128 @@ public final class SavingsHelper {
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
+ private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
@Autowired
public SavingsHelper(AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
}
- private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
+ // FIXED METHOD (FINERACT-1266)
+
- public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
- final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType,
- final Integer financialYearBeginningMonth, List<LocalDate> postInterestAsOn) {
+ public List<LocalDateInterval> determineInterestPostingPeriods(
+ final LocalDate startInterestCalculationLocalDate,
+ final LocalDate interestPostingUpToDate,
+ final SavingsPostingInterestPeriodType postingPeriodType,
+ final Integer financialYearBeginningMonth,
+ List<LocalDate> postInterestAsOn) {
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
if (startInterestCalculationLocalDate == null || interestPostingUpToDate == null) {
return postingPeriods;
}
+ // 🔐 Null-safe list
+ if (postInterestAsOn == null) {
+ postInterestAsOn = Collections.emptyList();
+ }
+
+ // 🔐 Null-safe posting period
+ final SavingsPostingInterestPeriodType safePostingPeriodType =
+ postingPeriodType != null ? postingPeriodType : SavingsPostingInterestPeriodType.INVALID;
+
LocalDate periodStartDate = startInterestCalculationLocalDate;
LocalDate periodEndDate = periodStartDate;
LocalDate actualPeriodStartDate = periodStartDate;
- while (!DateUtils.isAfter(periodStartDate, interestPostingUpToDate) && !DateUtils.isAfter(periodEndDate, interestPostingUpToDate)) {
- final LocalDate interestPostingLocalDate = determineInterestPostingPeriodEndDateFrom(periodStartDate, postingPeriodType,
- interestPostingUpToDate, financialYearBeginningMonth);
+ while (!DateUtils.isAfter(periodStartDate, interestPostingUpToDate)
+ && !DateUtils.isAfter(periodEndDate, interestPostingUpToDate)) {
+
+ final LocalDate interestPostingLocalDate =
+ determineInterestPostingPeriodEndDateFrom(
+ periodStartDate,
+ safePostingPeriodType,
+ interestPostingUpToDate,
+ financialYearBeginningMonth);
periodEndDate = interestPostingLocalDate.minusDays(1);
- if (!postInterestAsOn.isEmpty()) {
- for (LocalDate transactiondate : postInterestAsOn) {
- if (DateUtils.isAfter(transactiondate, periodStartDate) && !DateUtils.isAfter(transactiondate, periodEndDate)) {
- periodEndDate = transactiondate.minusDays(1);
- actualPeriodStartDate = periodEndDate;
- break;
- }
+ for (LocalDate transactionDate : postInterestAsOn) {
+ if (DateUtils.isAfter(transactionDate, periodStartDate)
+ && !DateUtils.isAfter(transactionDate, periodEndDate)) {
+ periodEndDate = transactionDate.minusDays(1);
+ actualPeriodStartDate = periodEndDate;
+ break;
}
}
postingPeriods.add(LocalDateInterval.create(periodStartDate, periodEndDate));
if (DateUtils.isEqual(actualPeriodStartDate, periodEndDate)) {
- periodEndDate = actualPeriodStartDate.plusDays(1);
periodStartDate = actualPeriodStartDate.plusDays(1);
+ periodEndDate = actualPeriodStartDate.plusDays(1);
} else {
- periodEndDate = interestPostingLocalDate;
periodStartDate = interestPostingLocalDate;
+ periodEndDate = interestPostingLocalDate;
}
}
return postingPeriods;
}
- private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate periodStartDate,
- final SavingsPostingInterestPeriodType interestPostingPeriodType, final LocalDate interestPostingUpToDate,
+
+ // FIXED HELPER METHOD
Review Comment:
Please remove the AI generated, useless comments!
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "airajena (via GitHub)" <gi...@apache.org>.
airajena commented on PR #5454:
URL: https://github.com/apache/fineract/pull/5454#issuecomment-3890510487
@Satish11012007 please squash your commits into one commit and also please sign your commit.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #5454:
URL: https://github.com/apache/fineract/pull/5454#issuecomment-3883687237
@Satish11012007 Please rebase this PR with latest develop branch!
Also it seems licence headers are missing from the newly created files:
```
* What went wrong:
Execution failed for task ':rat'.
> A failure occurred while executing org.nosphere.apache.rat.RatWork
> Apache Rat audit failure - 1 unapproved license
See file:///home/runner/work/fineract/fineract/build/reports/rat/index.html
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266 Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5454:
URL: https://github.com/apache/fineract/pull/5454#discussion_r2816551711
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -40,96 +41,128 @@ public final class SavingsHelper {
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
+ private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
@Autowired
public SavingsHelper(AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
}
- private static final CompoundInterestHelper COMPOUND_INTEREST_HELPER = new CompoundInterestHelper();
+
+ // FIXED METHOD (FINERACT-1266)
+
- public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
- final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType,
- final Integer financialYearBeginningMonth, List<LocalDate> postInterestAsOn) {
+ public List<LocalDateInterval> determineInterestPostingPeriods(
+ final LocalDate startInterestCalculationLocalDate,
+ final LocalDate interestPostingUpToDate,
+ final SavingsPostingInterestPeriodType postingPeriodType,
+ final Integer financialYearBeginningMonth,
+ List<LocalDate> postInterestAsOn) {
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
if (startInterestCalculationLocalDate == null || interestPostingUpToDate == null) {
return postingPeriods;
}
+ // 🔐 Null-safe list
+ if (postInterestAsOn == null) {
+ postInterestAsOn = Collections.emptyList();
+ }
+
+ // 🔐 Null-safe posting period
+ final SavingsPostingInterestPeriodType safePostingPeriodType =
+ postingPeriodType != null ? postingPeriodType : SavingsPostingInterestPeriodType.INVALID;
+
LocalDate periodStartDate = startInterestCalculationLocalDate;
LocalDate periodEndDate = periodStartDate;
LocalDate actualPeriodStartDate = periodStartDate;
- while (!DateUtils.isAfter(periodStartDate, interestPostingUpToDate) && !DateUtils.isAfter(periodEndDate, interestPostingUpToDate)) {
- final LocalDate interestPostingLocalDate = determineInterestPostingPeriodEndDateFrom(periodStartDate, postingPeriodType,
- interestPostingUpToDate, financialYearBeginningMonth);
+ while (!DateUtils.isAfter(periodStartDate, interestPostingUpToDate)
+ && !DateUtils.isAfter(periodEndDate, interestPostingUpToDate)) {
+
+ final LocalDate interestPostingLocalDate =
+ determineInterestPostingPeriodEndDateFrom(
+ periodStartDate,
+ safePostingPeriodType,
+ interestPostingUpToDate,
+ financialYearBeginningMonth);
periodEndDate = interestPostingLocalDate.minusDays(1);
- if (!postInterestAsOn.isEmpty()) {
- for (LocalDate transactiondate : postInterestAsOn) {
- if (DateUtils.isAfter(transactiondate, periodStartDate) && !DateUtils.isAfter(transactiondate, periodEndDate)) {
- periodEndDate = transactiondate.minusDays(1);
- actualPeriodStartDate = periodEndDate;
- break;
- }
+ for (LocalDate transactionDate : postInterestAsOn) {
+ if (DateUtils.isAfter(transactionDate, periodStartDate)
+ && !DateUtils.isAfter(transactionDate, periodEndDate)) {
+ periodEndDate = transactionDate.minusDays(1);
+ actualPeriodStartDate = periodEndDate;
+ break;
}
}
postingPeriods.add(LocalDateInterval.create(periodStartDate, periodEndDate));
if (DateUtils.isEqual(actualPeriodStartDate, periodEndDate)) {
- periodEndDate = actualPeriodStartDate.plusDays(1);
periodStartDate = actualPeriodStartDate.plusDays(1);
+ periodEndDate = actualPeriodStartDate.plusDays(1);
} else {
- periodEndDate = interestPostingLocalDate;
periodStartDate = interestPostingLocalDate;
+ periodEndDate = interestPostingLocalDate;
}
}
return postingPeriods;
}
- private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate periodStartDate,
- final SavingsPostingInterestPeriodType interestPostingPeriodType, final LocalDate interestPostingUpToDate,
+
+ // FIXED HELPER METHOD
+
+
+ private LocalDate determineInterestPostingPeriodEndDateFrom(
+ final LocalDate periodStartDate,
+ final SavingsPostingInterestPeriodType interestPostingPeriodType,
+ final LocalDate interestPostingUpToDate,
Integer financialYearBeginningMonth) {
+ // 🔐 Null-safe fallback
Review Comment:
Please remove the AI generated, useless comments!
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-1266: Fix potential NPE in determineInterestPostingPeriods [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5454:
URL: https://github.com/apache/fineract/pull/5454#discussion_r2816563359
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -138,11 +171,11 @@ private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate peri
break;
}
}
-
if (!isEndDateSet) {
- periodEndDate = quarterlyDates.get(0).plusYears(1).with(TemporalAdjusters.lastDayOfMonth());
Review Comment:
why did you removed this?
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsHelper.java:
##########
@@ -151,38 +184,47 @@ private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate peri
break;
}
}
-
if (!isEndDateSet) {
- periodEndDate = biannualDates.get(0).plusYears(1).with(TemporalAdjusters.lastDayOfMonth());
Review Comment:
why did you removed this?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org