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

yufei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new fac650af2 Replace CallContext with RealmConfig in 
enforceFeatureEnabledOrThrow (#2348)
fac650af2 is described below

commit fac650af2bd09a3c84791164b426d84a62cce47a
Author: Christopher Lambert <xn...@gmx.de>
AuthorDate: Fri Aug 15 00:35:30 2025 +0200

    Replace CallContext with RealmConfig in enforceFeatureEnabledOrThrow (#2348)
---
 .../java/org/apache/polaris/core/config/FeatureConfiguration.java    | 5 ++---
 .../java/org/apache/polaris/service/admin/PolarisAdminService.java   | 2 +-
 .../polaris/service/catalog/generic/GenericTableCatalogAdapter.java  | 2 +-
 .../polaris/service/catalog/iceberg/IcebergCatalogHandler.java       | 2 +-
 .../apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java  | 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java
index 05b7e0dec..fe5d6bc6a 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java
@@ -23,7 +23,6 @@ import java.util.Optional;
 import org.apache.polaris.core.admin.model.AuthenticationParameters;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
 import org.apache.polaris.core.connection.ConnectionType;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.persistence.cache.EntityWeigher;
 
 /**
@@ -48,8 +47,8 @@ public class FeatureConfiguration<T> extends 
PolarisConfiguration<T> {
    * we want to throw an UnsupportedOperationException if it's not enabled.
    */
   public static void enforceFeatureEnabledOrThrow(
-      CallContext callContext, FeatureConfiguration<Boolean> featureConfig) {
-    boolean enabled = callContext.getRealmConfig().getConfig(featureConfig);
+      RealmConfig realmConfig, FeatureConfiguration<Boolean> featureConfig) {
+    boolean enabled = realmConfig.getConfig(featureConfig);
     if (!enabled) {
       throw new UnsupportedOperationException("Feature not enabled: " + 
featureConfig.key());
     }
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
index b6c849985..1f47e4937 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
@@ -783,7 +783,7 @@ public class PolarisAdminService {
             .addKeyValue("catalogName", entity.getName())
             .log("Creating a federated catalog");
         FeatureConfiguration.enforceFeatureEnabledOrThrow(
-            callContext, FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
+            callContext.getRealmConfig(), 
FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
         Map<String, UserSecretReference> processedSecretReferences = Map.of();
         List<String> supportedAuthenticationTypes =
             callContext
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogAdapter.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogAdapter.java
index d1aa4fa8b..ddf6f7697 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogAdapter.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogAdapter.java
@@ -74,7 +74,7 @@ public class GenericTableCatalogAdapter
   private GenericTableCatalogHandler newHandlerWrapper(
       SecurityContext securityContext, String prefix) {
     FeatureConfiguration.enforceFeatureEnabledOrThrow(
-        callContext, FeatureConfiguration.ENABLE_GENERIC_TABLES);
+        callContext.getRealmConfig(), 
FeatureConfiguration.ENABLE_GENERIC_TABLES);
     validatePrincipal(securityContext);
 
     return new GenericTableCatalogHandler(
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
index 266ac11e4..4fff89a5c 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java
@@ -212,7 +212,7 @@ public class IcebergCatalogHandler extends CatalogHandler 
implements AutoCloseab
           .addKeyValue("remoteUrl", connectionConfigInfoDpo.getUri())
           .log("Initializing federated catalog");
       FeatureConfiguration.enforceFeatureEnabledOrThrow(
-          callContext, FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
+          callContext.getRealmConfig(), 
FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
 
       Catalog federatedCatalog;
       ConnectionType connectionType =
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java
index 751e34af8..9ac52cb1b 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java
@@ -74,7 +74,7 @@ public class PolicyCatalogAdapter implements 
PolarisCatalogPolicyApiService, Cat
 
   private PolicyCatalogHandler newHandlerWrapper(SecurityContext 
securityContext, String prefix) {
     FeatureConfiguration.enforceFeatureEnabledOrThrow(
-        callContext, FeatureConfiguration.ENABLE_POLICY_STORE);
+        callContext.getRealmConfig(), 
FeatureConfiguration.ENABLE_POLICY_STORE);
     validatePrincipal(securityContext);
 
     return new PolicyCatalogHandler(

Reply via email to