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 e1f053eb32 Fix the NullPointerException when a grid or form extends a 
missing parent in the same file
e1f053eb32 is described below

commit e1f053eb328294d53e9b0806c01ba31e172a07a7
Author: Mridul Pathak <[email protected]>
AuthorDate: Wed Oct 28 16:24:33 2026 +0530

    Fix the NullPointerException when a grid or form extends a missing parent 
in the same file
    
    When a grid or form extends a name that is neither a grid nor a form in the 
same file, the fallback lookup of the other widget type called orElseGet with a 
null supplier and threw a NullPointerException, so the widget failed to load 
instead of logging that the parent was not found and continuing without one. 
Use orElse(null) in ModelGrid and ModelSingleForm.
---
 .../widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java   | 2 +-
 .../src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java
index 8c19ebe642..82af584485 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelGrid.java
@@ -104,7 +104,7 @@ public class ModelGrid extends ModelForm {
                     gridElements = UtilXml.childElementList(rootElement, 
"form");
                     Element parentElement = gridElements.stream()
                             .filter(form -> 
form.getAttribute("name").equals(parentGrid))
-                            .findFirst().orElseGet(null);
+                            .findFirst().orElse(null);
                     if (UtilValidate.isNotEmpty(parentElement)) {
                         parentModel = 
FormFactory.createModelForm(parentElement, entityModelReader, visualTheme,
                                 dispatchContext, parentResource, parentGrid);
diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java
 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java
index d41524e5a9..0b62df968d 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelSingleForm.java
@@ -106,7 +106,7 @@ public class ModelSingleForm extends ModelForm {
                     formElements = UtilXml.childElementList(rootElement, 
"grid");
                     Element parentElement = formElements.stream()
                             .filter(grid -> 
grid.getAttribute("name").equals(parentForm))
-                            .findFirst().orElseGet(null);
+                            .findFirst().orElse(null);
                     if (UtilValidate.isNotEmpty(parentElement)) {
                         parent = GridFactory.createModelGrid(parentElement, 
entityModelReader, visualTheme,
                                 dispatchContext, parentResource, parentForm);

Reply via email to