vyommani commented on code in PR #729:
URL: https://github.com/apache/ranger/pull/729#discussion_r2512822713
##########
agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java:
##########
@@ -98,7 +98,7 @@ public class RangerBasePlugin {
private final List<RangerChainedPlugin> chainedPlugins;
private final boolean dedupStrings;
private PolicyRefresher refresher;
- private RangerPolicyEngine policyEngine;
+ private volatile RangerPolicyEngine policyEngine;
private RangerAuthContext currentAuthContext;
Review Comment:
@mneethiraj I've analyzed the code and agree with your points:
1-> currentAuthContext should be volatile since it's updated in
setPolicies() and read in getTagEnricher().
2-> roles is updated in setRoles(), a public method, so making it volatile
is a good idea for defensive programming, even if it's mostly initialized or
updated via admin operations.
3-> serviceConfigs is updated in setPolicies() and read in other threads, so
volatile is necessary for visibility guarantees.
Given the negligible cost of volatile, I agree it's a good practice to make
all three fields volatile for API safety and to avoid potential issues.
Your thoughts?
--
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]