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

mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new 5db205cd64 Fixed: createFuturePeriod() crashes with 
NullPointerException when CustomTimePeriod SystemProperty config is missing 
(OFBIZ-13604)
5db205cd64 is described below

commit 5db205cd6424b4438284f13a4d842a9266ac5ea3
Author: Mridul Pathak <[email protected]>
AuthorDate: Sat Sep 19 20:27:00 2026 +0530

    Fixed: createFuturePeriod() crashes with NullPointerException when 
CustomTimePeriod SystemProperty config is missing (OFBIZ-13604)
    
    createFuturePeriod() looked up the "CustomTimePeriod.create" SystemProperty
    and accessed .systemPropertyValue on the result with no null check. That
    SystemProperty row only exists in 
framework/common/data/CommonSystemPropertyData.xml,
    whose <entity-resource> is commented out in ofbiz-component.xml 
("multitenant"
    opt-in), so on a standard install with no such row configured this threw a
    NullPointerException instead of gracefully treating "not configured" as
    "nothing to do." createFuturePeriod is registered as a recurring scheduled
    job (JobSandbox jobId=FUTURE_PERIOD, running the 1st and 15th of every
    month), so this crashed that job indefinitely on any install with at least
    one PartyAcctgPreference.enableAccounting='Y' row and no explicit
    SystemProperty configured -- the default, out-of-the-box state. The same
    gap existed one line later for the CustomTimePeriod.applType lookup.
    
    Fixed with safe-navigation on both lookups. Verified with a temporary
    RED/GREEN test; full accounting component suite passes.
---
 .../main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
index 18b0170bd0..3ca91c175d 100644
--- 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
+++ 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
@@ -370,11 +370,11 @@ Map createFuturePeriod() {
         parameters.organizationPartyId = party.partyId
         createCustomTimePeriod = from('SystemProperty')
                 .where('systemResourceId', 'general', 'systemPropertyId', 
'CustomTimePeriod.create').queryOne()
-        if (createCustomTimePeriod.systemPropertyValue == 'Y') {
+        if (createCustomTimePeriod?.systemPropertyValue == 'Y') {
             // get list of CustomTypePeriod types
             applTypes = from('SystemProperty')
                     .where('systemResourceId', 'general', 'systemPropertyId', 
'CustomTimePeriod.applType').queryOne()
-            List types = 
Arrays.asList(applTypes.systemPropertyValue.split('\\s*,\\s*'))
+            List types = applTypes?.systemPropertyValue ? 
Arrays.asList(applTypes.systemPropertyValue.split('\\s*,\\s*')) : []
             types.each { periodTypeId ->
                 Calendar periodCal = Calendar.getInstance()
                 systemPropertyId = 'CustomTimePeriod.' + periodTypeId + 
'.intermediate'

Reply via email to