gh-yzou commented on code in PR #1505:
URL: https://github.com/apache/polaris/pull/1505#discussion_r2099051098


##########
service/common/src/main/java/org/apache/polaris/service/config/DefaultConfigurationStore.java:
##########
@@ -56,13 +59,26 @@ public DefaultConfigurationStore(
 
   @Override
   public <T> @Nullable T getConfiguration(@Nonnull PolarisCallContext ctx, 
String configName) {
-    String realm = 
CallContext.getCurrentContext().getRealmContext().getRealmIdentifier();
+    if (realmContextInstance != null && !realmContextInstance.isUnsatisfied()) 
{
+      RealmContext realmContext = realmContextInstance.get();
+      String realm = realmContext.getRealmIdentifier();
+      LOGGER.debug("Get configuration value for {} with realm {}", configName, 
realm);
+      @SuppressWarnings("unchecked")
+      T confgValue =
+          (T)
+              Optional.ofNullable(realmOverrides.getOrDefault(realm, 
Map.of()).get(configName))
+                  .orElseGet(() -> getDefaultConfiguration(configName));
+      return confgValue;
+    } else {
+      LOGGER.debug(
+          "No RealmContext is injected when lookup value for configuration {} 
", configName);

Review Comment:
   This will happen if the ConfigurationStore is accessed outside of request 
scope. I am not so sure if we have any access like this in the code, but 
logically that is correct, since ConfigurationStore is an ApplicationScoped 
class, there is no guarantee that the request scoped class is available during 
access.
   If we are sure there is only request scoped access, we probably should 
change DefaultConfigurationStore to request scoped instead to be clear, 
however, i would like to keep this as a separate discussion.



-- 
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