dimas-b commented on code in PR #1505:
URL: https://github.com/apache/polaris/pull/1505#discussion_r2098576019
##########
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())
{
Review Comment:
I believe `realmContextInstance != null` is always true. CDI does not inject
`null`, AFAIK.
##########
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) {
Review Comment:
`ctx` is no longer used, right? Why not remove?
##########
quarkus/service/src/test/java/org/apache/polaris/service/quarkus/config/DefaultConfigurationStoreTest.java:
##########
@@ -94,107 +97,34 @@ public void before(TestInfo testInfo) {
@Test
public void testGetConfiguration() {
- DefaultConfigurationStore defaultConfigurationStore =
- new DefaultConfigurationStore(Map.of("key1", 1, "key2", "value"));
- InMemoryPolarisMetaStoreManagerFactory metastoreFactory =
- new InMemoryPolarisMetaStoreManagerFactory();
- PolarisCallContext callCtx =
- new PolarisCallContext(
- metastoreFactory.getOrCreateSessionSupplier(() -> "realm1").get(),
- new PolarisDefaultDiagServiceImpl());
- Object value = defaultConfigurationStore.getConfiguration(callCtx,
"missingKeyWithoutDefault");
+ Object value = configurationStore.getConfiguration(polarisContext,
"missingKeyWithoutDefault");
assertThat(value).isNull();
Object defaultValue =
- defaultConfigurationStore.getConfiguration(
- callCtx, "missingKeyWithDefault", "defaultValue");
+ configurationStore.getConfiguration(
+ polarisContext, "missingKeyWithDefault", "defaultValue");
assertThat(defaultValue).isEqualTo("defaultValue");
- Integer keyOne = defaultConfigurationStore.getConfiguration(callCtx,
"key1");
- assertThat(keyOne).isEqualTo(1);
- String keyTwo = defaultConfigurationStore.getConfiguration(callCtx,
"key2");
- assertThat(keyTwo).isEqualTo("value");
+
+ assertThat((Boolean) configurationStore.getConfiguration(polarisContext,
falseByDefaultKey))
+ .isTrue();
Review Comment:
Please add comments explaining why the expected value is not the default.
##########
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:
Is this a normal case in runtime? When does it happen?
--
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]