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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 4ac3da1  Improved:  Fix some bugs Spotbugs reports (OFBIZ-12386)
4ac3da1 is described below

commit 4ac3da10824ab0f2a4006fcaaa5201b7b39813b7
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Mon Nov 29 09:56:00 2021 +0100

    Improved:  Fix some bugs Spotbugs reports (OFBIZ-12386)
    
    If userLogin is null none of the blocks below makes sense
---
 .../apache/ofbiz/entityext/permission/EntityPermissionChecker.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
 
b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
index 9c89a03..d7ed327 100644
--- 
a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
+++ 
b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java
@@ -829,13 +829,15 @@ public class EntityPermissionChecker {
     public static List<String> getUserRoles(GenericValue entity, GenericValue 
userLogin, Delegator delegator) throws GenericEntityException {
 
         List<String> roles = new LinkedList<>();
-        if (entity == null) return roles;
+        if (entity == null || userLogin == null) {
+            return roles;
+        }
         String entityName = entity.getEntityName();
             // TODO: Need to use ContentManagementWorker.getAuthorContent first
 
 
         roles.remove("OWNER"); // always test with the owner of the current 
content
-        if (entity.get("createdByUserLogin") != null && userLogin != null) {
+        if (entity.get("createdByUserLogin") != null) {
             String userLoginId = (String) userLogin.get("userLoginId");
             String userLoginIdCB = (String) entity.get("createdByUserLogin");
             //if (Debug.infoOn()) Debug.logInfo("userLoginId:" + userLoginId + 
": userLoginIdCB:" + userLoginIdCB + ":", null);

Reply via email to