mneethiraj commented on code in PR #1068:
URL: https://github.com/apache/ranger/pull/1068#discussion_r3633851473


##########
agents-common/src/main/java/org/apache/ranger/plugin/policyengine/PolicyEngine.java:
##########
@@ -563,12 +563,21 @@ private void normalizeServiceDefs(ServicePolicies 
servicePolicies) {
         RangerServiceDef serviceDef = servicePolicies.getServiceDef();
 
         if (serviceDef != null) {
-            ServiceDefUtil.normalize(serviceDef);
+            RangerServiceDef normalizedServiceDef = 
ServiceDefUtil.normalizeCopiedServiceDef(serviceDef);

Review Comment:
   This method, `normalizeServiceDefs()` is called only from the constructor; 
so this issue can occur only when miltiple `PolicyEngine` instances are created 
from the same `ServicePolicies` instance; this in turn is possible only when 
multiple `RangerPolicyAdminImpl` instances are created with the same time with 
the same `ServicePolicies` instance, from 
`RangerPolicyAdminCache.addPolicyAdmin()`. I suggest to consider updating this 
method as below:
   
   ```
   private RangerPolicyAdmin addPolicyAdmin(ServicePolicies policies, 
RangerRoles roles, RangerPolicyEngineOptions options) {
       synchronized(policies) {
           RangerServiceDef    serviceDef          = policies.getServiceDef();
           String              serviceType         = (serviceDef != null) ? 
serviceDef.getName() : "";
           RangerPluginContext rangerPluginContext = new 
RangerPluginContext(new RangerPluginConfig(serviceType, null, "ranger-admin", 
null, null, options));
   
           return new RangerPolicyAdminImpl(policies, rangerPluginContext, 
roles);
       }
   }
   
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to