This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch ranger-2.8
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/ranger-2.8 by this push:
new b75e78db9 RANGER-4247: initialize RangerPolicyRepository members
before logging (#258)
b75e78db9 is described below
commit b75e78db94621986393b5061c8d8191b9d25cf76
Author: Yubi Lee <[email protected]>
AuthorDate: Fri Jan 2 23:13:51 2026 -0800
RANGER-4247: initialize RangerPolicyRepository members before logging (#258)
Signed-off-by: Madhan Neethiraj <[email protected]>
(cherry picked from commit 1b142ac1d9cdf79d51c41a4eab06f7b530f80430)
---
.../plugin/policyengine/RangerPolicyEngineOptions.java | 6 +++++-
.../plugin/policyengine/RangerPolicyRepository.java | 15 ++++++---------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineOptions.java
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineOptions.java
index 0828949a4..d0398724a 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineOptions.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineOptions.java
@@ -51,6 +51,10 @@ public class RangerPolicyEngineOptions {
public RangerPolicyEngineOptions() {}
public RangerPolicyEngineOptions(final RangerPolicyEngineOptions other)
{
+ this(other, null);
+ }
+
+ public RangerPolicyEngineOptions(final RangerPolicyEngineOptions other,
RangerServiceDefHelper serviceDefHelper) {
this.disableContextEnrichers = other.disableContextEnrichers;
this.disableCustomConditions = other.disableCustomConditions;
this.disableTagPolicyEvaluation =
other.disableTagPolicyEvaluation;
@@ -65,7 +69,7 @@ public RangerPolicyEngineOptions(final
RangerPolicyEngineOptions other) {
this.enableResourceMatcherReuse =
other.enableResourceMatcherReuse;
this.optimizeTrieForRetrieval = other.optimizeTrieForRetrieval;
this.disableRoleResolution = other.disableRoleResolution;
- this.serviceDefHelper = null;
+ this.serviceDefHelper = serviceDefHelper;
this.optimizeTrieForSpace = other.optimizeTrieForSpace;
this.optimizeTagTrieForRetrieval =
other.optimizeTagTrieForRetrieval;
this.optimizeTagTrieForSpace = other.optimizeTagTrieForSpace;
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
index d466fe93e..7bb4611bd 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyRepository.java
@@ -191,7 +191,7 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
this.componentServiceDef = this.serviceDef =
ServiceDefUtil.normalize(servicePolicies.getServiceDef());
this.zoneName = zoneName;
this.appId = pluginContext.getConfig().getAppId();
- this.options = new
RangerPolicyEngineOptions(pluginContext.getConfig().getPolicyEngineOptions());
+ this.options = new
RangerPolicyEngineOptions(pluginContext.getConfig().getPolicyEngineOptions(),
new RangerServiceDefHelper(serviceDef, false));
this.pluginContext = pluginContext;
if (StringUtils.isEmpty(zoneName)) {
@@ -230,8 +230,6 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
LOG.debug("RangerPolicyRepository : building policy-repository for
service[" + serviceName + "], and zone:[" + zoneName + "] with auditMode[" +
auditModeEnum + "]");
}
- init(options);
-
if (StringUtils.isEmpty(zoneName)) {
this.contextEnrichers = buildContextEnrichers(options);
this.auditPolicyEvaluators =
buildAuditPolicyEvaluators(servicePolicies.getServiceConfig());
@@ -240,6 +238,8 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
this.auditPolicyEvaluators = Collections.emptyList();
}
+ init(options);
+
if (options.disableTrieLookupPrefilter) {
policyResourceTrie = null;
dataMaskResourceTrie = null;
@@ -263,7 +263,7 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
this.serviceDef =
ServiceDefUtil.normalizeAccessTypeDefs(ServiceDefUtil.normalize(tagPolicies.getServiceDef()),
componentServiceDef.getName());
this.componentServiceDef = componentServiceDef;
this.appId = pluginContext.getConfig().getAppId();
- this.options = new
RangerPolicyEngineOptions(pluginContext.getConfig().getPolicyEngineOptions());
+ this.options = new
RangerPolicyEngineOptions(pluginContext.getConfig().getPolicyEngineOptions(),
new RangerServiceDefHelper(serviceDef, false));
this.pluginContext = pluginContext;
this.policies =
normalizeAndPrunePolicies(tagPolicies.getPolicies(),
componentServiceDef.getName());
this.policyVersion = tagPolicies.getPolicyVersion() != null ?
tagPolicies.getPolicyVersion() : -1;
@@ -284,8 +284,6 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
LOG.debug("RangerPolicyRepository : building tag-policy-repository
for tag service:[" + serviceName +"], with auditMode[" + auditModeEnum +"]");
}
- init(options);
-
if (StringUtils.isEmpty(zoneName)) {
this.contextEnrichers = buildContextEnrichers(options);
this.auditPolicyEvaluators =
buildAuditPolicyEvaluators(tagPolicies.getServiceConfig());
@@ -294,6 +292,8 @@ public RangerPolicyRepository(ServicePolicies
servicePolicies, RangerPluginConte
this.auditPolicyEvaluators = Collections.emptyList();
}
+ init(options);
+
if (options.disableTrieLookupPrefilter) {
policyResourceTrie = null;
dataMaskResourceTrie = null;
@@ -904,9 +904,6 @@ private static boolean
skipBuildingPolicyEvaluator(RangerPolicy policy, RangerPo
}
private void init(RangerPolicyEngineOptions options) {
- RangerServiceDefHelper serviceDefHelper = new
RangerServiceDefHelper(serviceDef, false);
- options.setServiceDefHelper(serviceDefHelper);
-
List<RangerPolicyEvaluator> policyEvaluators = new ArrayList<>();
List<RangerPolicyEvaluator> dataMaskPolicyEvaluators = new
ArrayList<>();
List<RangerPolicyEvaluator> rowFilterPolicyEvaluators = new
ArrayList<>();