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

snazy 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 756e535fa Remove PolarisDiagnostics from json utils (#2176)
756e535fa is described below

commit 756e535fabe150eefdfe16f3c61c1207217d2e2f
Author: Christopher Lambert <xn...@gmx.de>
AuthorDate: Mon Jul 28 10:16:50 2025 +0200

    Remove PolarisDiagnostics from json utils (#2176)
    
    With transitive cleanups of, PolarisStorageConfigurationInfo, 
ConnectionConfigInfoDpo, BaseMetaStoreManager, PolarisObjectMapperUtil, 
CurrentContext
---
 .../jdbc/JdbcMetaStoreManagerFactory.java          |  7 ---
 .../core/connection/ConnectionConfigInfoDpo.java   | 11 ++---
 .../apache/polaris/core/entity/CatalogEntity.java  |  6 +--
 .../org/apache/polaris/core/entity/TaskEntity.java | 22 ++--------
 .../AtomicOperationMetaStoreManager.java           | 35 +++++++--------
 .../core/persistence/BaseMetaStoreManager.java     | 29 ++++---------
 .../LocalPolarisMetaStoreManagerFactory.java       |  7 ---
 .../core/persistence/PolarisObjectMapperUtil.java  | 50 +++++++---------------
 .../TransactionalMetaStoreManagerImpl.java         | 36 +++++++---------
 .../storage/PolarisStorageConfigurationInfo.java   | 14 ++----
 .../connection/ConnectionConfigInfoDpoTest.java    | 12 ++----
 .../core/persistence/cache/EntityWeigherTest.java  |  4 +-
 .../storage/cache/StorageCredentialCacheTest.java  |  4 +-
 .../BasePolarisMetaStoreManagerTest.java           | 14 +-----
 .../persistence/PolarisTestMetaStoreManager.java   | 22 +++-------
 .../quarkus/admin/ManagementServiceTest.java       | 16 -------
 .../quarkus/admin/PolarisAuthzTestBase.java        |  1 -
 .../catalog/AbstractIcebergCatalogTest.java        |  4 --
 .../service/quarkus/entity/CatalogEntityTest.java  |  1 -
 .../task/BatchFileCleanupTaskHandlerTest.java      |  4 --
 .../task/ManifestFileCleanupTaskHandlerTest.java   |  4 --
 .../catalog/iceberg/IcebergCatalogAdapter.java     |  3 --
 .../service/task/TableCleanupTaskHandler.java      |  2 +-
 .../polaris/service/task/TaskExecutorImpl.java     |  2 -
 24 files changed, 81 insertions(+), 229 deletions(-)

diff --git 
a/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java
 
b/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java
index 88fe2ab50..f57b158e9 100644
--- 
a/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java
+++ 
b/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java
@@ -33,7 +33,6 @@ import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
 import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.config.RealmConfig;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.PolarisEntityConstants;
 import org.apache.polaris.core.entity.PrincipalEntity;
@@ -232,9 +231,6 @@ public class JdbcMetaStoreManagerFactory implements 
MetaStoreManagerFactory {
     BasePersistence metaStore = 
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get();
     PolarisCallContext polarisContext =
         new PolarisCallContext(realmContext, metaStore, diagServices);
-    if (CallContext.getCurrentContext() == null) {
-      CallContext.setCurrentContext(polarisContext);
-    }
 
     Optional<PrincipalEntity> preliminaryRootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext);
@@ -270,9 +266,6 @@ public class JdbcMetaStoreManagerFactory implements 
MetaStoreManagerFactory {
     BasePersistence metaStore = 
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get();
     PolarisCallContext polarisContext =
         new PolarisCallContext(realmContext, metaStore, diagServices);
-    if (CallContext.getCurrentContext() == null) {
-      CallContext.setCurrentContext(polarisContext);
-    }
 
     Optional<PrincipalEntity> rootPrincipal = 
metaStoreManager.findRootPrincipal(polarisContext);
     if (rootPrincipal.isEmpty()) {
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java
index 4313ede12..fe4d18330 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpo.java
@@ -26,12 +26,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import jakarta.annotation.Nonnull;
-import jakarta.annotation.Nullable;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.Map;
-import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.admin.model.ConnectionConfigInfo;
 import org.apache.polaris.core.admin.model.HadoopConnectionConfigInfo;
 import org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo;
@@ -115,15 +113,12 @@ public abstract class ConnectionConfigInfoDpo implements 
IcebergCatalogPropertie
     }
   }
 
-  public static @Nullable ConnectionConfigInfoDpo deserialize(
-      @Nonnull PolarisDiagnostics diagnostics, final @Nonnull String jsonStr) {
+  public static ConnectionConfigInfoDpo deserialize(final @Nonnull String 
jsonStr) {
     try {
       return DEFAULT_MAPPER.readValue(jsonStr, ConnectionConfigInfoDpo.class);
-    } catch (JsonProcessingException exception) {
-      diagnostics.fail(
-          "fail_to_deserialize_connection_configuration", exception, 
"jsonStr={}", jsonStr);
+    } catch (JsonProcessingException ex) {
+      throw new RuntimeException("deserialize failed: " + ex.getMessage(), ex);
     }
-    return null;
   }
 
   /** Validates the remote URI. */
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java 
b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
index 1469f26c9..0de3c3daa 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import org.apache.iceberg.exceptions.BadRequestException;
-import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
 import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
 import org.apache.polaris.core.admin.model.AzureStorageConfigInfo;
 import org.apache.polaris.core.admin.model.Catalog;
@@ -195,8 +194,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
     String configStr =
         
getInternalPropertiesAsMap().get(PolarisEntityConstants.getStorageConfigInfoPropertyName());
     if (configStr != null) {
-      return PolarisStorageConfigurationInfo.deserialize(
-          new PolarisDefaultDiagServiceImpl(), configStr);
+      return PolarisStorageConfigurationInfo.deserialize(configStr);
     }
     return null;
   }
@@ -217,7 +215,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
         getInternalPropertiesAsMap()
             .get(PolarisEntityConstants.getConnectionConfigInfoPropertyName());
     if (configStr != null) {
-      return ConnectionConfigInfoDpo.deserialize(new 
PolarisDefaultDiagServiceImpl(), configStr);
+      return ConnectionConfigInfoDpo.deserialize(configStr);
     }
     return null;
   }
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/entity/TaskEntity.java 
b/polaris-core/src/main/java/org/apache/polaris/core/entity/TaskEntity.java
index 5a0add8d4..e60c8ec59 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/entity/TaskEntity.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/entity/TaskEntity.java
@@ -18,8 +18,6 @@
  */
 package org.apache.polaris.core.entity;
 
-import org.apache.polaris.core.PolarisCallContext;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.persistence.PolarisObjectMapperUtil;
 
 /**
@@ -40,17 +38,13 @@ public class TaskEntity extends PolarisEntity {
   }
 
   public <T> T readData(Class<T> klass) {
-    PolarisCallContext polarisCallContext = 
CallContext.getCurrentContext().getPolarisCallContext();
     return PolarisObjectMapperUtil.deserialize(
-        polarisCallContext, 
getPropertiesAsMap().get(PolarisTaskConstants.TASK_DATA), klass);
+        getPropertiesAsMap().get(PolarisTaskConstants.TASK_DATA), klass);
   }
 
   public AsyncTaskType getTaskType() {
-    PolarisCallContext polarisCallContext = 
CallContext.getCurrentContext().getPolarisCallContext();
     return PolarisObjectMapperUtil.deserialize(
-        polarisCallContext,
-        getPropertiesAsMap().get(PolarisTaskConstants.TASK_TYPE),
-        AsyncTaskType.class);
+        getPropertiesAsMap().get(PolarisTaskConstants.TASK_TYPE), 
AsyncTaskType.class);
   }
 
   public static class Builder extends PolarisEntity.BaseBuilder<TaskEntity, 
TaskEntity.Builder> {
@@ -66,20 +60,12 @@ public class TaskEntity extends PolarisEntity {
     }
 
     public Builder withTaskType(AsyncTaskType taskType) {
-      PolarisCallContext polarisCallContext =
-          CallContext.getCurrentContext().getPolarisCallContext();
-      properties.put(
-          PolarisTaskConstants.TASK_TYPE,
-          PolarisObjectMapperUtil.serialize(polarisCallContext, taskType));
+      properties.put(PolarisTaskConstants.TASK_TYPE, 
PolarisObjectMapperUtil.serialize(taskType));
       return this;
     }
 
     public Builder withData(Object data) {
-      PolarisCallContext polarisCallContext =
-          CallContext.getCurrentContext().getPolarisCallContext();
-      properties.put(
-          PolarisTaskConstants.TASK_DATA,
-          PolarisObjectMapperUtil.serialize(polarisCallContext, data));
+      properties.put(PolarisTaskConstants.TASK_DATA, 
PolarisObjectMapperUtil.serialize(data));
       return this;
     }
 
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
index 35d0098b3..52f1123b9 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java
@@ -246,8 +246,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
     // if it is a principal, we also need to drop the secrets
     if (entity.getType() == PolarisEntityType.PRINCIPAL) {
       // get internal properties
-      Map<String, String> properties =
-          this.deserializeProperties(callCtx, entity.getInternalProperties());
+      Map<String, String> properties = 
this.deserializeProperties(entity.getInternalProperties());
 
       // get client_id
       String clientId = 
properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -427,7 +426,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
     // validate input
     callCtx.getDiagServices().checkNotNull(catalog, "unexpected_null_catalog");
 
-    Map<String, String> internalProp = getInternalPropertyMap(callCtx, 
catalog);
+    Map<String, String> internalProp = getInternalPropertyMap(catalog);
     String integrationIdentifierOrId =
         
internalProp.get(PolarisEntityConstants.getStorageIntegrationIdentifierPropertyName());
     String storageConfigInfoStr =
@@ -442,8 +441,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
                   callCtx,
                   catalog.getCatalogId(),
                   catalog.getId(),
-                  PolarisStorageConfigurationInfo.deserialize(
-                      callCtx.getDiagServices(), storageConfigInfoStr));
+                  
PolarisStorageConfigurationInfo.deserialize(storageConfigInfoStr));
     } else {
       integration = null;
     }
@@ -754,7 +752,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
 
       // get internal properties
       Map<String, String> properties =
-          this.deserializeProperties(callCtx, 
refreshPrincipal.getInternalProperties());
+          this.deserializeProperties(refreshPrincipal.getInternalProperties());
 
       // get client_id
       String clientId = 
properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -800,14 +798,14 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
             .generateNewPrincipalSecrets(callCtx, principal.getName(), 
principal.getId());
 
     // generate properties
-    Map<String, String> internalProperties = getInternalPropertyMap(callCtx, 
principal);
+    Map<String, String> internalProperties = getInternalPropertyMap(principal);
     internalProperties.put(
         PolarisEntityConstants.getClientIdPropertyName(), 
principalSecrets.getPrincipalClientId());
 
     // remember client id
     PolarisBaseEntity updatedPrincipal =
         new PolarisBaseEntity.Builder(principal)
-            .internalProperties(this.serializeProperties(callCtx, 
internalProperties))
+            .internalProperties(this.serializeProperties(internalProperties))
             .build();
     // now create and persist new catalog entity
     EntityResult lowLevelResult = this.persistNewEntity(callCtx, ms, 
updatedPrincipal);
@@ -862,7 +860,6 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
     PolarisBaseEntity principal = loadEntityResult.getEntity();
     Map<String, String> internalProps =
         PolarisObjectMapperUtil.deserializeProperties(
-            callCtx,
             principal.getInternalProperties() == null ? "{}" : 
principal.getInternalProperties());
 
     boolean doReset =
@@ -881,14 +878,14 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
       internalProps.put(
           PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE, 
"true");
       principalBuilder.internalProperties(
-          PolarisObjectMapperUtil.serializeProperties(callCtx, internalProps));
+          PolarisObjectMapperUtil.serializeProperties(internalProps));
       principalBuilder.entityVersion(principal.getEntityVersion() + 1);
       ms.writeEntity(callCtx, principalBuilder.build(), true, principal);
     } else if (internalProps.containsKey(
         PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE)) {
       
internalProps.remove(PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE);
       principalBuilder.internalProperties(
-          PolarisObjectMapperUtil.serializeProperties(callCtx, internalProps));
+          PolarisObjectMapperUtil.serializeProperties(internalProps));
       principalBuilder.entityVersion(principal.getEntityVersion() + 1);
       ms.writeEntity(callCtx, principalBuilder.build(), true, principal);
     }
@@ -1228,10 +1225,10 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
       properties.put(
           PolarisTaskConstants.TASK_TYPE,
           String.valueOf(AsyncTaskType.ENTITY_CLEANUP_SCHEDULER.typeCode()));
-      properties.put("data", PolarisObjectMapperUtil.serialize(callCtx, 
refreshEntityToDrop));
+      properties.put("data", 
PolarisObjectMapperUtil.serialize(refreshEntityToDrop));
       PolarisBaseEntity.Builder taskEntityBuilder =
           new PolarisBaseEntity.Builder()
-              .properties(PolarisObjectMapperUtil.serializeProperties(callCtx, 
properties))
+              
.properties(PolarisObjectMapperUtil.serializeProperties(properties))
               .id(ms.generateNewId(callCtx))
               .catalogId(0L)
               .name("entityCleanup_" + entityToDrop.getId())
@@ -1240,7 +1237,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
               .createTimestamp(callCtx.getClock().millis());
       if (cleanupProperties != null) {
         taskEntityBuilder.internalProperties(
-            PolarisObjectMapperUtil.serializeProperties(callCtx, 
cleanupProperties));
+            PolarisObjectMapperUtil.serializeProperties(cleanupProperties));
       }
       // TODO: Add a way to create the task entities atomically with dropping 
the entity;
       // in the meantime, if the server fails partway through a dropEntity, 
it's possible that
@@ -1524,7 +1521,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
                   PolarisBaseEntity.Builder updatedTaskBuilder =
                       new PolarisBaseEntity.Builder(task);
                   Map<String, String> properties =
-                      PolarisObjectMapperUtil.deserializeProperties(callCtx, 
task.getProperties());
+                      
PolarisObjectMapperUtil.deserializeProperties(task.getProperties());
                   
properties.put(PolarisTaskConstants.LAST_ATTEMPT_EXECUTOR_ID, executorId);
                   properties.put(
                       PolarisTaskConstants.LAST_ATTEMPT_START_TIME,
@@ -1536,7 +1533,7 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
                                   
properties.getOrDefault(PolarisTaskConstants.ATTEMPT_COUNT, "0"))
                               + 1));
                   updatedTaskBuilder.properties(
-                      PolarisObjectMapperUtil.serializeProperties(callCtx, 
properties));
+                      PolarisObjectMapperUtil.serializeProperties(properties));
                   EntityResult result =
                       updateEntityPropertiesIfNotChanged(callCtx, null, 
updatedTaskBuilder.build());
                   if (result.getReturnStatus() == 
BaseResult.ReturnStatus.SUCCESS) {
@@ -1630,18 +1627,16 @@ public class AtomicOperationMetaStoreManager extends 
BaseMetaStoreManager {
   /**
    * Get the internal property map for an entity
    *
-   * @param callCtx the polaris call context
    * @param entity the target entity
    * @return a map of string representing the internal properties
    */
-  public Map<String, String> getInternalPropertyMap(
-      @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) {
+  public Map<String, String> getInternalPropertyMap(@Nonnull PolarisBaseEntity 
entity) {
     String internalPropStr = entity.getInternalProperties();
     Map<String, String> res = new HashMap<>();
     if (internalPropStr == null) {
       return res;
     }
-    return deserializeProperties(callCtx, internalPropStr);
+    return deserializeProperties(internalPropStr);
   }
 
   /** {@inheritDoc} */
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
index 5f70801a4..f166102de 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/BaseMetaStoreManager.java
@@ -20,7 +20,6 @@ package org.apache.polaris.core.persistence;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import jakarta.annotation.Nonnull;
 import java.util.Map;
@@ -40,8 +39,7 @@ public abstract class BaseMetaStoreManager implements 
PolarisMetaStoreManager {
   public static PolarisStorageConfigurationInfo extractStorageConfiguration(
       @Nonnull PolarisCallContext callCtx, PolarisBaseEntity reloadedEntity) {
     Map<String, String> propMap =
-        PolarisObjectMapperUtil.deserializeProperties(
-            callCtx, reloadedEntity.getInternalProperties());
+        
PolarisObjectMapperUtil.deserializeProperties(reloadedEntity.getInternalProperties());
     String storageConfigInfoStr =
         propMap.get(PolarisEntityConstants.getStorageConfigInfoPropertyName());
 
@@ -53,8 +51,7 @@ public abstract class BaseMetaStoreManager implements 
PolarisMetaStoreManager {
             "catalogId={}, entityId={}",
             reloadedEntity.getCatalogId(),
             reloadedEntity.getId());
-    return PolarisStorageConfigurationInfo.deserialize(
-        callCtx.getDiagServices(), storageConfigInfoStr);
+    return PolarisStorageConfigurationInfo.deserialize(storageConfigInfoStr);
   }
 
   /**
@@ -63,17 +60,13 @@ public abstract class BaseMetaStoreManager implements 
PolarisMetaStoreManager {
    * @param properties a map of key/value pairs
    * @return a String, the JSON representation of the map
    */
-  public String serializeProperties(PolarisCallContext callCtx, Map<String, 
String> properties) {
-
-    String jsonString = null;
+  public String serializeProperties(Map<String, String> properties) {
     try {
       // Deserialize the JSON string to a Map<String, String>
-      jsonString = MAPPER.writeValueAsString(properties);
+      return MAPPER.writeValueAsString(properties);
     } catch (JsonProcessingException ex) {
-      callCtx.getDiagServices().fail("got_json_processing_exception", "ex={}", 
ex);
+      throw new RuntimeException("serializeProperties failed: " + 
ex.getMessage(), ex);
     }
-
-    return jsonString;
   }
 
   /**
@@ -82,19 +75,13 @@ public abstract class BaseMetaStoreManager implements 
PolarisMetaStoreManager {
    * @param properties a JSON string representing the set of properties
    * @return a Map of string
    */
-  public Map<String, String> deserializeProperties(PolarisCallContext callCtx, 
String properties) {
-
-    Map<String, String> retProperties = null;
+  public Map<String, String> deserializeProperties(String properties) {
     try {
       // Deserialize the JSON string to a Map<String, String>
-      retProperties = MAPPER.readValue(properties, new TypeReference<>() {});
-    } catch (JsonMappingException ex) {
-      callCtx.getDiagServices().fail("got_json_mapping_exception", "ex={}", 
ex);
+      return MAPPER.readValue(properties, new TypeReference<>() {});
     } catch (JsonProcessingException ex) {
-      callCtx.getDiagServices().fail("got_json_processing_exception", "ex={}", 
ex);
+      throw new RuntimeException("deserializeProperties failed: " + 
ex.getMessage(), ex);
     }
-
-    return retProperties;
   }
 
   /**
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java
index bd6d13e40..43f6774b7 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java
@@ -28,7 +28,6 @@ import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
 import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.config.RealmConfig;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.PolarisEntityConstants;
 import org.apache.polaris.core.entity.PrincipalEntity;
@@ -186,9 +185,6 @@ public abstract class 
LocalPolarisMetaStoreManagerFactory<StoreType>
     BasePersistence metaStore = 
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get();
     PolarisCallContext polarisContext =
         new PolarisCallContext(realmContext, metaStore, diagServices);
-    if (CallContext.getCurrentContext() == null) {
-      CallContext.setCurrentContext(polarisContext);
-    }
 
     Optional<PrincipalEntity> preliminaryRootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext);
@@ -224,9 +220,6 @@ public abstract class 
LocalPolarisMetaStoreManagerFactory<StoreType>
     BasePersistence metaStore = 
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get();
     PolarisCallContext polarisContext =
         new PolarisCallContext(realmContext, metaStore, diagServices);
-    if (CallContext.getCurrentContext() == null) {
-      CallContext.setCurrentContext(polarisContext);
-    }
 
     Optional<PrincipalEntity> rootPrincipal = 
metaStoreManager.findRootPrincipal(polarisContext);
     if (rootPrincipal.isEmpty()) {
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisObjectMapperUtil.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisObjectMapperUtil.java
index 89b0c6429..f89bee358 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisObjectMapperUtil.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisObjectMapperUtil.java
@@ -24,20 +24,18 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.JsonToken;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import jakarta.annotation.Nullable;
 import java.io.IOException;
 import java.util.Map;
 import org.apache.iceberg.rest.RESTSerializers;
-import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.entity.PolarisBaseEntity;
 import org.apache.polaris.core.entity.PolarisTaskConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** A mapper to serialize/deserialize polaris objects. */
-public class PolarisObjectMapperUtil {
+public final class PolarisObjectMapperUtil {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(PolarisObjectMapperUtil.class);
 
   /** mapper, allows to serialize/deserialize properties to/from JSON */
@@ -50,42 +48,39 @@ public class PolarisObjectMapperUtil {
     return mapper;
   }
 
+  private PolarisObjectMapperUtil() {
+    // utility class
+  }
+
   /**
    * Given the internal property as a map of key/value pairs, serialize it to 
a String
    *
    * @param properties a map of key/value pairs
    * @return a String, the JSON representation of the map
    */
-  public static String serializeProperties(
-      PolarisCallContext callCtx, Map<String, String> properties) {
-
-    String jsonString = null;
+  public static String serializeProperties(Map<String, String> properties) {
     try {
       // Deserialize the JSON string to a Map<String, String>
-      jsonString = MAPPER.writeValueAsString(properties);
+      return MAPPER.writeValueAsString(properties);
     } catch (JsonProcessingException ex) {
-      callCtx.getDiagServices().fail("got_json_processing_exception", 
ex.getMessage());
+      throw new RuntimeException("serializeProperties failed: " + 
ex.getMessage(), ex);
     }
-
-    return jsonString;
   }
 
-  public static String serialize(PolarisCallContext callCtx, Object object) {
+  public static String serialize(Object object) {
     try {
       return MAPPER.writeValueAsString(object);
     } catch (JsonProcessingException e) {
-      callCtx.getDiagServices().fail("got_json_processing_exception", 
e.getMessage());
+      throw new RuntimeException("serialize failed: " + e.getMessage(), e);
     }
-    return "";
   }
 
-  public static <T> T deserialize(PolarisCallContext callCtx, String text, 
Class<T> klass) {
+  public static <T> T deserialize(String text, Class<T> klass) {
     try {
       return MAPPER.readValue(text, klass);
     } catch (JsonProcessingException e) {
-      callCtx.getDiagServices().fail("got_json_processing_exception", 
e.getMessage());
+      throw new RuntimeException("deserialize failed: " + e.getMessage(), e);
     }
-    return null;
   }
 
   /**
@@ -94,24 +89,13 @@ public class PolarisObjectMapperUtil {
    * @param properties a JSON string representing the set of properties
    * @return a Map of string
    */
-  public static Map<String, String> deserializeProperties(
-      PolarisCallContext callCtx, String properties) {
-
-    Map<String, String> retProperties = null;
+  public static Map<String, String> deserializeProperties(String properties) {
     try {
       // Deserialize the JSON string to a Map<String, String>
-      retProperties = MAPPER.readValue(properties, new TypeReference<>() {});
-    } catch (JsonMappingException ex) {
-      callCtx
-          .getDiagServices()
-          .fail("got_json_mapping_exception", "properties={}, ex={}", 
properties, ex);
+      return MAPPER.readValue(properties, new TypeReference<>() {});
     } catch (JsonProcessingException ex) {
-      callCtx
-          .getDiagServices()
-          .fail("got_json_processing_exception", "properties={}, ex={}", 
properties, ex);
+      throw new RuntimeException("deserializeProperties failed: " + 
ex.getMessage(), ex);
     }
-
-    return retProperties;
   }
 
   public static class TaskExecutionState {
@@ -187,8 +171,4 @@ public class PolarisObjectMapperUtil {
       return null;
     }
   }
-
-  long now() {
-    return 0;
-  }
 }
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
index 53d57ceb2..6d39df148 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java
@@ -233,8 +233,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
     // if it is a principal, we also need to drop the secrets
     if (entity.getType() == PolarisEntityType.PRINCIPAL) {
       // get internal properties
-      Map<String, String> properties =
-          this.deserializeProperties(callCtx, entity.getInternalProperties());
+      Map<String, String> properties = 
this.deserializeProperties(entity.getInternalProperties());
 
       // get client_id
       String clientId = 
properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -767,7 +766,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
 
       // get internal properties
       Map<String, String> properties =
-          this.deserializeProperties(callCtx, 
refreshPrincipal.getInternalProperties());
+          this.deserializeProperties(refreshPrincipal.getInternalProperties());
 
       // get client_id
       String clientId = 
properties.get(PolarisEntityConstants.getClientIdPropertyName());
@@ -824,14 +823,14 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
         ms.generateNewPrincipalSecretsInCurrentTxn(callCtx, 
principal.getName(), principal.getId());
 
     // generate properties
-    Map<String, String> internalProperties = getInternalPropertyMap(callCtx, 
principal);
+    Map<String, String> internalProperties = getInternalPropertyMap(principal);
     internalProperties.put(
         PolarisEntityConstants.getClientIdPropertyName(), 
principalSecrets.getPrincipalClientId());
 
     // remember client id
     PolarisBaseEntity updatedPrincipal =
         new PolarisBaseEntity.Builder(principal)
-            .internalProperties(this.serializeProperties(callCtx, 
internalProperties))
+            .internalProperties(this.serializeProperties(internalProperties))
             .build();
 
     // now create and persist new catalog entity
@@ -898,7 +897,6 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
     PolarisBaseEntity.Builder principalBuilder = new 
PolarisBaseEntity.Builder(principal);
     Map<String, String> internalProps =
         PolarisObjectMapperUtil.deserializeProperties(
-            callCtx,
             principal.getInternalProperties() == null ? "{}" : 
principal.getInternalProperties());
 
     boolean doReset =
@@ -916,14 +914,14 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
       internalProps.put(
           PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE, 
"true");
       principalBuilder.internalProperties(
-          PolarisObjectMapperUtil.serializeProperties(callCtx, internalProps));
+          PolarisObjectMapperUtil.serializeProperties(internalProps));
       principalBuilder.entityVersion(principal.getEntityVersion() + 1);
       ms.writeEntityInCurrentTxn(callCtx, principalBuilder.build(), true, 
principal);
     } else if (internalProps.containsKey(
         PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE)) {
       
internalProps.remove(PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE);
       principalBuilder.internalProperties(
-          PolarisObjectMapperUtil.serializeProperties(callCtx, internalProps));
+          PolarisObjectMapperUtil.serializeProperties(internalProps));
       principalBuilder.entityVersion(principal.getEntityVersion() + 1);
       ms.writeEntityInCurrentTxn(callCtx, principalBuilder.build(), true, 
principal);
     }
@@ -963,7 +961,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
     // get metastore we should be using
     TransactionalPersistence ms = ((TransactionalPersistence) 
callCtx.getMetaStore());
 
-    Map<String, String> internalProp = getInternalPropertyMap(callCtx, 
catalog);
+    Map<String, String> internalProp = getInternalPropertyMap(catalog);
     String integrationIdentifierOrId =
         
internalProp.get(PolarisEntityConstants.getStorageIntegrationIdentifierPropertyName());
     String storageConfigInfoStr =
@@ -977,8 +975,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
               callCtx,
               catalog.getCatalogId(),
               catalog.getId(),
-              PolarisStorageConfigurationInfo.deserialize(
-                  callCtx.getDiagServices(), storageConfigInfoStr));
+              
PolarisStorageConfigurationInfo.deserialize(storageConfigInfoStr));
     } else {
       integration = null;
     }
@@ -1432,7 +1429,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
       properties.put(
           PolarisTaskConstants.TASK_TYPE,
           String.valueOf(AsyncTaskType.ENTITY_CLEANUP_SCHEDULER.typeCode()));
-      properties.put("data", PolarisObjectMapperUtil.serialize(callCtx, 
refreshEntityToDrop));
+      properties.put("data", 
PolarisObjectMapperUtil.serialize(refreshEntityToDrop));
       PolarisBaseEntity.Builder taskEntityBuilder =
           new PolarisBaseEntity.Builder()
               .id(ms.generateNewIdInCurrentTxn(callCtx))
@@ -1441,10 +1438,10 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
               .typeCode(PolarisEntityType.TASK.getCode())
               .subTypeCode(PolarisEntitySubType.NULL_SUBTYPE.getCode())
               .createTimestamp(callCtx.getClock().millis())
-              .properties(PolarisObjectMapperUtil.serializeProperties(callCtx, 
properties));
+              
.properties(PolarisObjectMapperUtil.serializeProperties(properties));
       if (cleanupProperties != null) {
         taskEntityBuilder.internalProperties(
-            PolarisObjectMapperUtil.serializeProperties(callCtx, 
cleanupProperties));
+            PolarisObjectMapperUtil.serializeProperties(cleanupProperties));
       }
       PolarisBaseEntity taskEntity = taskEntityBuilder.build();
       createEntityIfNotExists(callCtx, ms, null, taskEntity);
@@ -1978,7 +1975,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
                 task -> {
                   PolarisBaseEntity.Builder updatedTask = new 
PolarisBaseEntity.Builder(task);
                   Map<String, String> properties =
-                      PolarisObjectMapperUtil.deserializeProperties(callCtx, 
task.getProperties());
+                      
PolarisObjectMapperUtil.deserializeProperties(task.getProperties());
                   
properties.put(PolarisTaskConstants.LAST_ATTEMPT_EXECUTOR_ID, executorId);
                   properties.put(
                       PolarisTaskConstants.LAST_ATTEMPT_START_TIME,
@@ -1989,8 +1986,7 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
                           Integer.parseInt(
                                   
properties.getOrDefault(PolarisTaskConstants.ATTEMPT_COUNT, "0"))
                               + 1));
-                  updatedTask.properties(
-                      PolarisObjectMapperUtil.serializeProperties(callCtx, 
properties));
+                  
updatedTask.properties(PolarisObjectMapperUtil.serializeProperties(properties));
                   EntityResult result =
                       updateEntityPropertiesIfNotChanged(callCtx, ms, null, 
updatedTask.build());
                   if (result.getReturnStatus() == 
BaseResult.ReturnStatus.SUCCESS) {
@@ -2078,18 +2074,16 @@ public class TransactionalMetaStoreManagerImpl extends 
BaseMetaStoreManager {
   /**
    * Get the internal property map for an entity
    *
-   * @param callCtx the polaris call context
    * @param entity the target entity
    * @return a map of string representing the internal properties
    */
-  public Map<String, String> getInternalPropertyMap(
-      @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) {
+  public Map<String, String> getInternalPropertyMap(@Nonnull PolarisBaseEntity 
entity) {
     String internalPropStr = entity.getInternalProperties();
     Map<String, String> res = new HashMap<>();
     if (internalPropStr == null) {
       return res;
     }
-    return deserializeProperties(callCtx, internalPropStr);
+    return deserializeProperties(internalPropStr);
   }
 
   /** {@link #loadResolvedEntityById(PolarisCallContext, long, long, 
PolarisEntityType)} */
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
index 26ccb062a..d039b1f61 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
@@ -37,7 +37,6 @@ import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.polaris.core.PolarisCallContext;
-import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.admin.model.Catalog;
 import org.apache.polaris.core.config.FeatureConfiguration;
 import org.apache.polaris.core.entity.CatalogEntity;
@@ -113,26 +112,22 @@ public abstract class PolarisStorageConfigurationInfo {
     try {
       return DEFAULT_MAPPER.writeValueAsString(this);
     } catch (JsonProcessingException e) {
-      throw new RuntimeException(e);
+      throw new RuntimeException("serialize failed: " + e.getMessage(), e);
     }
   }
 
   /**
    * Deserialize a json string into a PolarisStorageConfiguration object
    *
-   * @param diagnostics the diagnostics instance
    * @param jsonStr a json string
    * @return the PolarisStorageConfiguration object
    */
-  public static PolarisStorageConfigurationInfo deserialize(
-      @Nonnull PolarisDiagnostics diagnostics, final @Nonnull String jsonStr) {
+  public static PolarisStorageConfigurationInfo deserialize(final @Nonnull 
String jsonStr) {
     try {
       return DEFAULT_MAPPER.readValue(jsonStr, 
PolarisStorageConfigurationInfo.class);
-    } catch (JsonProcessingException exception) {
-      diagnostics.fail(
-          "fail_to_deserialize_storage_configuration", exception, 
"jsonStr={}", jsonStr);
+    } catch (JsonProcessingException e) {
+      throw new RuntimeException("deserialize failed: " + e.getMessage(), e);
     }
-    return null;
   }
 
   public static Optional<PolarisStorageConfigurationInfo> forEntityPath(
@@ -141,7 +136,6 @@ public abstract class PolarisStorageConfigurationInfo {
         .map(
             storageInfo ->
                 deserialize(
-                    callContext.getDiagServices(),
                     storageInfo
                         .getInternalPropertiesAsMap()
                         
.get(PolarisEntityConstants.getStorageConfigInfoPropertyName())))
diff --git 
a/polaris-core/src/test/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpoTest.java
 
b/polaris-core/src/test/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpoTest.java
index f2b461358..da1f4b3e6 100644
--- 
a/polaris-core/src/test/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpoTest.java
+++ 
b/polaris-core/src/test/java/org/apache/polaris/core/connection/ConnectionConfigInfoDpoTest.java
@@ -22,14 +22,11 @@ import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
-import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.admin.model.ConnectionConfigInfo;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 public class ConnectionConfigInfoDpoTest {
-  private static final PolarisDiagnostics polarisDiagnostics = new 
PolarisDefaultDiagServiceImpl();
   private static final ObjectMapper objectMapper = new ObjectMapper();
 
   static {
@@ -59,8 +56,7 @@ public class ConnectionConfigInfoDpoTest {
             + "    \"scopes\": [\"PRINCIPAL_ROLE:ALL\"]"
             + "  }"
             + "}";
-    ConnectionConfigInfoDpo connectionConfigInfoDpo =
-        ConnectionConfigInfoDpo.deserialize(polarisDiagnostics, json);
+    ConnectionConfigInfoDpo connectionConfigInfoDpo = 
ConnectionConfigInfoDpo.deserialize(json);
     Assertions.assertNotNull(connectionConfigInfoDpo);
     JsonNode tree1 = objectMapper.readTree(json);
     JsonNode tree2 = 
objectMapper.readTree(connectionConfigInfoDpo.serialize());
@@ -107,8 +103,7 @@ public class ConnectionConfigInfoDpoTest {
             + "    }"
             + "  }"
             + "}";
-    ConnectionConfigInfoDpo connectionConfigInfoDpo =
-        ConnectionConfigInfoDpo.deserialize(polarisDiagnostics, json);
+    ConnectionConfigInfoDpo connectionConfigInfoDpo = 
ConnectionConfigInfoDpo.deserialize(json);
     Assertions.assertNotNull(connectionConfigInfoDpo);
     JsonNode tree1 = objectMapper.readTree(json);
     JsonNode tree2 = 
objectMapper.readTree(connectionConfigInfoDpo.serialize());
@@ -145,8 +140,7 @@ public class ConnectionConfigInfoDpoTest {
             + "    \"authenticationTypeCode\": 3"
             + "  }"
             + "}";
-    ConnectionConfigInfoDpo connectionConfigInfoDpo =
-        ConnectionConfigInfoDpo.deserialize(polarisDiagnostics, json);
+    ConnectionConfigInfoDpo connectionConfigInfoDpo = 
ConnectionConfigInfoDpo.deserialize(json);
     Assertions.assertNotNull(connectionConfigInfoDpo);
     JsonNode tree1 = objectMapper.readTree(json);
     JsonNode tree2 = 
objectMapper.readTree(connectionConfigInfoDpo.serialize());
diff --git 
a/polaris-core/src/test/java/org/apache/polaris/core/persistence/cache/EntityWeigherTest.java
 
b/polaris-core/src/test/java/org/apache/polaris/core/persistence/cache/EntityWeigherTest.java
index ef04c5f88..16039e540 100644
--- 
a/polaris-core/src/test/java/org/apache/polaris/core/persistence/cache/EntityWeigherTest.java
+++ 
b/polaris-core/src/test/java/org/apache/polaris/core/persistence/cache/EntityWeigherTest.java
@@ -126,12 +126,10 @@ public class EntityWeigherTest {
 
   private static Map<String, String> getPropertiesMap(String properties) {
     if (properties == null || properties.isEmpty()) return new HashMap<>();
-    Map<String, String> propertiesMap;
     try {
-      propertiesMap = MAPPER.readValue(properties, new TypeReference<>() {});
+      return MAPPER.readValue(properties, new TypeReference<>() {});
     } catch (JsonProcessingException e) {
       throw new RuntimeException(e);
     }
-    return propertiesMap;
   }
 }
diff --git 
a/polaris-core/src/test/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheTest.java
 
b/polaris-core/src/test/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheTest.java
index 39095f08b..5364fa843 100644
--- 
a/polaris-core/src/test/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheTest.java
+++ 
b/polaris-core/src/test/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheTest.java
@@ -247,7 +247,7 @@ public class StorageCredentialCacheTest {
           PolarisEntityConstants.getStorageConfigInfoPropertyName(), 
"newStorageConfig");
       PolarisBaseEntity updateEntity =
           new PolarisBaseEntity.Builder(entity)
-              
.internalProperties(PolarisObjectMapperUtil.serializeProperties(callCtx, 
internalMap))
+              
.internalProperties(PolarisObjectMapperUtil.serializeProperties(internalMap))
               .build();
       storageCredentialCache.getOrGenerateSubScopeCreds(
           metaStoreManager,
@@ -287,7 +287,7 @@ public class StorageCredentialCacheTest {
           PolarisEntityConstants.getStorageConfigInfoPropertyName(), 
"newStorageConfig");
       PolarisBaseEntity updateEntity =
           new PolarisBaseEntity.Builder(entity)
-              
.internalProperties(PolarisObjectMapperUtil.serializeProperties(callCtx, 
internalMap))
+              
.internalProperties(PolarisObjectMapperUtil.serializeProperties(internalMap))
               .build();
       storageCredentialCache.getOrGenerateSubScopeCreds(
           metaStoreManager,
diff --git 
a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/BasePolarisMetaStoreManagerTest.java
 
b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/BasePolarisMetaStoreManagerTest.java
index cc1305c9f..1b57ad1b2 100644
--- 
a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/BasePolarisMetaStoreManagerTest.java
+++ 
b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/BasePolarisMetaStoreManagerTest.java
@@ -35,7 +35,6 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.polaris.core.PolarisCallContext;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.entity.AsyncTaskType;
 import org.apache.polaris.core.entity.EntityNameLookupRecord;
 import org.apache.polaris.core.entity.PolarisBaseEntity;
@@ -104,9 +103,6 @@ public abstract class BasePolarisMetaStoreManagerTest {
   @Test
   protected void testCreateEntities() {
     PolarisMetaStoreManager metaStoreManager = 
polarisTestMetaStoreManager.polarisMetaStoreManager;
-    if (CallContext.getCurrentContext() == null) {
-      
CallContext.setCurrentContext(polarisTestMetaStoreManager.polarisCallContext);
-    }
     TaskEntity task1 = createTask("task1", 100L);
     TaskEntity task2 = createTask("task2", 101L);
     List<PolarisBaseEntity> createdEntities =
@@ -153,9 +149,6 @@ public abstract class BasePolarisMetaStoreManagerTest {
   @Test
   protected void testCreateEntitiesAlreadyExisting() {
     PolarisMetaStoreManager metaStoreManager = 
polarisTestMetaStoreManager.polarisMetaStoreManager;
-    if (CallContext.getCurrentContext() == null) {
-      
CallContext.setCurrentContext(polarisTestMetaStoreManager.polarisCallContext);
-    }
     TaskEntity task1 = createTask("task1", 100L);
     TaskEntity task2 = createTask("task2", 101L);
     List<PolarisBaseEntity> createdEntities =
@@ -190,9 +183,6 @@ public abstract class BasePolarisMetaStoreManagerTest {
   @Test
   protected void testCreateEntitiesWithConflict() {
     PolarisMetaStoreManager metaStoreManager = 
polarisTestMetaStoreManager.polarisMetaStoreManager;
-    if (CallContext.getCurrentContext() == null) {
-      
CallContext.setCurrentContext(polarisTestMetaStoreManager.polarisCallContext);
-    }
     TaskEntity task1 = createTask("task1", 100L);
     TaskEntity task2 = createTask("task2", 101L);
     TaskEntity task3 = createTask("task3", 103L);
@@ -301,9 +291,7 @@ public abstract class BasePolarisMetaStoreManagerTest {
             entry ->
                 Assertions.assertThat(entry)
                     .extracting(
-                        e ->
-                            PolarisObjectMapperUtil.deserializeProperties(
-                                callCtx, e.getProperties()))
+                        e -> 
PolarisObjectMapperUtil.deserializeProperties(e.getProperties()))
                     .asInstanceOf(InstanceOfAssertFactories.map(String.class, 
String.class))
                     .containsEntry("lastAttemptExecutorId", executorId)
                     .containsEntry("attemptCount", "1"));
diff --git 
a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
 
b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
index 16ae65d26..f4aa7aa46 100644
--- 
a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
+++ 
b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
@@ -421,7 +421,6 @@ public class PolarisTestMetaStoreManager {
             .name(name)
             .internalProperties(
                 PolarisObjectMapperUtil.serializeProperties(
-                    this.polarisCallContext,
                     Map.of(
                         
PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE,
                         "true")))
@@ -468,7 +467,7 @@ public class PolarisTestMetaStoreManager {
 
     Map<String, String> internalProperties =
         PolarisObjectMapperUtil.deserializeProperties(
-            this.polarisCallContext, 
createPrincipalResult.getPrincipal().getInternalProperties());
+            createPrincipalResult.getPrincipal().getInternalProperties());
     Assertions.assertThat(
             internalProperties.get(
                 
PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE))
@@ -512,8 +511,7 @@ public class PolarisTestMetaStoreManager {
                 createPrincipalResult.getPrincipal().getType())
             .getEntity();
     internalProperties =
-        PolarisObjectMapperUtil.deserializeProperties(
-            this.polarisCallContext, reloadPrincipal.getInternalProperties());
+        
PolarisObjectMapperUtil.deserializeProperties(reloadPrincipal.getInternalProperties());
     Assertions.assertThat(
             internalProperties.get(
                 
PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE))
@@ -570,8 +568,7 @@ public class PolarisTestMetaStoreManager {
                 this.polarisCallContext, 0L, principalEntity.getId(), 
principalEntity.getType())
             .getEntity();
     internalProperties =
-        PolarisObjectMapperUtil.deserializeProperties(
-            this.polarisCallContext, newPrincipal.getInternalProperties());
+        
PolarisObjectMapperUtil.deserializeProperties(newPrincipal.getInternalProperties());
     Assertions.assertThat(
             internalProperties.get(
                 
PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE))
@@ -605,8 +602,7 @@ public class PolarisTestMetaStoreManager {
                 this.polarisCallContext, 0L, principalEntity.getId(), 
principalEntity.getType())
             .getEntity();
     internalProperties =
-        PolarisObjectMapperUtil.deserializeProperties(
-            this.polarisCallContext, finalPrincipal.getInternalProperties());
+        
PolarisObjectMapperUtil.deserializeProperties(finalPrincipal.getInternalProperties());
     Assertions.assertThat(
             internalProperties.get(
                 
PolarisEntityConstants.PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_STATE))
@@ -875,19 +871,15 @@ public class PolarisTestMetaStoreManager {
       
Assertions.assertThat(cleanupTask.getType()).isEqualTo(PolarisEntityType.TASK);
       Assertions.assertThat(cleanupTask.getInternalProperties()).isNotNull();
       Map<String, String> internalProperties =
-          PolarisObjectMapperUtil.deserializeProperties(
-              polarisCallContext, cleanupTask.getInternalProperties());
+          
PolarisObjectMapperUtil.deserializeProperties(cleanupTask.getInternalProperties());
       Assertions.assertThat(internalProperties).isEqualTo(cleanupProperties);
       Map<String, String> properties =
-          PolarisObjectMapperUtil.deserializeProperties(
-              polarisCallContext, cleanupTask.getProperties());
+          
PolarisObjectMapperUtil.deserializeProperties(cleanupTask.getProperties());
       Assertions.assertThat(properties).isNotNull();
       
Assertions.assertThat(properties.get(PolarisTaskConstants.TASK_DATA)).isNotNull();
       PolarisBaseEntity droppedEntity =
           PolarisObjectMapperUtil.deserialize(
-              polarisCallContext,
-              properties.get(PolarisTaskConstants.TASK_DATA),
-              PolarisBaseEntity.class);
+              properties.get(PolarisTaskConstants.TASK_DATA), 
PolarisBaseEntity.class);
       Assertions.assertThat(droppedEntity).isNotNull();
       Assertions.assertThat(droppedEntity.getId()).isEqualTo(entity.getId());
     }
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/ManagementServiceTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/ManagementServiceTest.java
index 4a4cad57b..4446652b0 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/ManagementServiceTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/ManagementServiceTest.java
@@ -25,7 +25,6 @@ import jakarta.annotation.Nonnull;
 import jakarta.ws.rs.core.Response;
 import jakarta.ws.rs.core.SecurityContext;
 import java.security.Principal;
-import java.time.Clock;
 import java.time.Instant;
 import java.util.HashSet;
 import java.util.List;
@@ -43,7 +42,6 @@ import org.apache.polaris.core.admin.model.StorageConfigInfo;
 import org.apache.polaris.core.admin.model.UpdateCatalogRequest;
 import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
 import org.apache.polaris.core.auth.PolarisAuthorizerImpl;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.PolarisBaseEntity;
 import org.apache.polaris.core.entity.PolarisEntity;
@@ -64,26 +62,12 @@ import org.apache.polaris.service.admin.PolarisAdminService;
 import org.apache.polaris.service.config.ReservedProperties;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
 
 public class ManagementServiceTest {
   private TestServices services;
 
   @BeforeEach
   public void setup() {
-    // Used to build a `CallContext` which then gets fed into the real 
`TestServices`
-    TestServices fakeServices =
-        TestServices.builder()
-            .config(Map.of("SUPPORTED_CATALOG_STORAGE_TYPES", List.of("S3", 
"GCS", "AZURE")))
-            .build();
-    PolarisCallContext polarisCallContext =
-        new PolarisCallContext(
-            fakeServices.realmContext(),
-            
fakeServices.metaStoreManagerFactory().getOrCreateSession(fakeServices.realmContext()),
-            fakeServices.polarisDiagnostics(),
-            fakeServices.configurationStore(),
-            Mockito.mock(Clock.class));
-    CallContext.setCurrentContext(polarisCallContext);
     services =
         TestServices.builder()
             .config(Map.of("SUPPORTED_CATALOG_STORAGE_TYPES", List.of("S3", 
"GCS", "AZURE")))
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisAuthzTestBase.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisAuthzTestBase.java
index 77770cd6b..f84471ca4 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisAuthzTestBase.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/admin/PolarisAuthzTestBase.java
@@ -241,7 +241,6 @@ public abstract class PolarisAuthzTestBase {
     this.entityManager = 
realmEntityManagerFactory.getOrCreateEntityManager(realmContext);
 
     callContext = polarisContext;
-    CallContext.setCurrentContext(callContext);
 
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java
index f891301e1..6596513ea 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/catalog/AbstractIcebergCatalogTest.java
@@ -293,10 +293,6 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
 
     entityManager = new PolarisEntityManager(metaStoreManager, 
resolverFactory);
 
-    // 
LocalPolarisMetaStoreManagerFactory.bootstrapServiceAndCreatePolarisPrincipalForRealm
 sets
-    // the CallContext.setCurrentContext() but never clears it, whereas the 
NoSQL one resets it.
-    CallContext.setCurrentContext(polarisContext);
-
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
     AuthenticatedPolarisPrincipal authenticatedRoot =
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/entity/CatalogEntityTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/entity/CatalogEntityTest.java
index fed6e3e20..d48a3ff8b 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/entity/CatalogEntityTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/entity/CatalogEntityTest.java
@@ -61,7 +61,6 @@ public class CatalogEntityTest {
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
     this.callContext = polarisCallContext;
-    CallContext.setCurrentContext(polarisCallContext);
   }
 
   @ParameterizedTest
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/BatchFileCleanupTaskHandlerTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/BatchFileCleanupTaskHandlerTest.java
index 9a3269138..2d9730c01 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/BatchFileCleanupTaskHandlerTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/BatchFileCleanupTaskHandlerTest.java
@@ -44,7 +44,6 @@ import org.apache.iceberg.inmemory.InMemoryFileIO;
 import org.apache.iceberg.io.FileIO;
 import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.AsyncTaskType;
 import org.apache.polaris.core.entity.TaskEntity;
@@ -184,7 +183,6 @@ public class BatchFileCleanupTaskHandlerTest {
             realmContext,
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
-    CallContext.setCurrentContext(polarisCallContext);
     FileIO fileIO = new InMemoryFileIO();
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
     BatchFileCleanupTaskHandler handler =
@@ -229,7 +227,6 @@ public class BatchFileCleanupTaskHandlerTest {
             realmContext,
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
-    CallContext.setCurrentContext(polarisCallContext);
     Map<String, AtomicInteger> retryCounter = new HashMap<>();
     FileIO fileIO =
         new InMemoryFileIO() {
@@ -281,7 +278,6 @@ public class BatchFileCleanupTaskHandlerTest {
     CompletableFuture<Void> future =
         CompletableFuture.runAsync(
             () -> {
-              CallContext.setCurrentContext(polarisCallContext);
               var newTask = addTaskLocation(task);
               assertThatPredicate(handler::canHandleTask).accepts(newTask);
               handler.handleTask(
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/ManifestFileCleanupTaskHandlerTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/ManifestFileCleanupTaskHandlerTest.java
index e3afedcb5..3584d98c5 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/ManifestFileCleanupTaskHandlerTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/quarkus/task/ManifestFileCleanupTaskHandlerTest.java
@@ -42,7 +42,6 @@ import org.apache.iceberg.io.OutputFile;
 import org.apache.iceberg.io.PositionOutputStream;
 import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.AsyncTaskType;
 import org.apache.polaris.core.entity.TaskEntity;
@@ -100,7 +99,6 @@ class ManifestFileCleanupTaskHandlerTest {
             realmContext,
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
-    CallContext.setCurrentContext(polarisCallContext);
     FileIO fileIO = new InMemoryFileIO();
     TableIdentifier tableIdentifier = TableIdentifier.of(Namespace.of("db1", 
"schema1"), "table1");
     ManifestFileCleanupTaskHandler handler =
@@ -129,7 +127,6 @@ class ManifestFileCleanupTaskHandlerTest {
             realmContext,
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
-    CallContext.setCurrentContext(polarisCallContext);
     FileIO fileIO =
         new InMemoryFileIO() {
           @Override
@@ -175,7 +172,6 @@ class ManifestFileCleanupTaskHandlerTest {
             realmContext,
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             new PolarisDefaultDiagServiceImpl());
-    CallContext.setCurrentContext(polarisCallContext);
     Map<String, AtomicInteger> retryCounter = new HashMap<>();
     FileIO fileIO =
         new InMemoryFileIO() {
diff --git 
a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
 
b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
index ea84ca11e..482e891c2 100644
--- 
a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
+++ 
b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java
@@ -169,9 +169,6 @@ public class IcebergCatalogAdapter
     this.prefixParser = prefixParser;
     this.reservedProperties = reservedProperties;
     this.catalogHandlerUtils = catalogHandlerUtils;
-
-    // FIXME: This is a hack to set the current context for downstream calls.
-    CallContext.setCurrentContext(callContext);
   }
 
   /**
diff --git 
a/service/common/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java
 
b/service/common/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java
index db74cbcab..679b14f70 100644
--- 
a/service/common/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java
+++ 
b/service/common/src/main/java/org/apache/polaris/service/task/TableCleanupTaskHandler.java
@@ -133,7 +133,7 @@ public class TableCleanupTaskHandler implements TaskHandler 
{
             .log(
                 "Successfully queued tasks to delete manifests, previous 
metadata, and statistics files - deleting table metadata file");
         for (PolarisBaseEntity createdTask : createdTasks) {
-          taskExecutor.addTaskHandlerContext(createdTask.getId(), 
CallContext.getCurrentContext());
+          taskExecutor.addTaskHandlerContext(createdTask.getId(), 
polarisCallContext);
         }
 
         fileIO.deleteFile(tableEntity.getMetadataLocation());
diff --git 
a/service/common/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java
 
b/service/common/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java
index c1c775bf4..54ddf8fbb 100644
--- 
a/service/common/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java
+++ 
b/service/common/src/main/java/org/apache/polaris/service/task/TaskExecutorImpl.java
@@ -122,8 +122,6 @@ public class TaskExecutorImpl implements TaskExecutor {
 
     boolean success = false;
     try {
-      // set the call context INSIDE the async task
-      CallContext.setCurrentContext(ctx);
       LOGGER.info("Handling task entity id {}", taskEntityId);
       PolarisMetaStoreManager metaStoreManager =
           
metaStoreManagerFactory.getOrCreateMetaStoreManager(ctx.getRealmContext());

Reply via email to