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 61addfb7db Fixed: setCommEventRoleToRead and 
setCommunicationEventRoleStatus throw NPE when no role exists (OFBIZ-13591)
61addfb7db is described below

commit 61addfb7db2cdeef8f5a2de73117776191ab941d
Author: Mridul Pathak <[email protected]>
AuthorDate: Wed Sep 16 12:03:44 2026 +0530

    Fixed: setCommEventRoleToRead and setCommunicationEventRoleStatus throw NPE 
when no role exists (OFBIZ-13591)
    
    - setCommEventRoleToRead dereferenced eventRole.roleTypeId without checking 
eventRole for null first, throwing an NPE whenever no matching 
CommunicationEventRole was found for the given communicationEventId/partyId
    - setCommunicationEventRoleStatus dereferenced 
communicationEventRole.statusId the same way, with the same NPE risk
    
    Both are auth-callable services reachable when a caller checks status or 
marks read for a party that isn't a role participant. The original minilang's 
dotted-field access degraded gracefully to null in that case instead of 
crashing, making a missing role a silent no-op; both methods now guard against 
a null lookup result to restore that behavior.
    
    Both fixes were verified against the original minilang and covered by a 
temporary RED/GREEN test before removal, and the party component's test suite 
passes unchanged.
---
 .../party/communication/CommunicationEventServicesScript.groovy      | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
 
b/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
index 57eda7116b..a9f8c25a08 100644
--- 
a/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
+++ 
b/applications/party/src/main/groovy/org/apache/ofbiz/party/communication/CommunicationEventServicesScript.groovy
@@ -575,7 +575,7 @@ Map setCommEventRoleToRead() {
                 .where(communicationEventId: parameters.communicationEventId,
                        partyId: parameters.partyId)
                 .queryFirst()
-        parameters.roleTypeId = eventRole.roleTypeId
+        parameters.roleTypeId = eventRole?.roleTypeId
     }
 
     if (eventRole
@@ -596,6 +596,9 @@ Map setCommunicationEventRoleStatus() {
     GenericValue communicationEventRole = from('CommunicationEventRole')
             .where(parameters)
             .queryOne()
+    if (!communicationEventRole) {
+        return success()
+    }
 
     String oldStatusId = communicationEventRole.statusId
     if (parameters.statusId != oldStatusId) {

Reply via email to