Conversation
| public interface RealmConfigurationSource { | ||
| RealmConfigurationSource EMPTY_CONFIG = (rc, name) -> null; | ||
|
|
||
| static RealmConfigurationSource global(Map<String, ?> config) { |
There was a problem hiding this comment.
| static RealmConfigurationSource global(Map<String, ?> config) { | |
| @VisibleForTesting | |
| static RealmConfigurationSource global(Map<String, ?> config) { |
?
| } else if (config.defaultValue() instanceof Double) { | ||
| return config.cast(Double.valueOf(String.valueOf(value))); | ||
| } else if (config.defaultValue() instanceof List<?>) { | ||
| return config.cast(new ArrayList<>((List<?>) value)); |
There was a problem hiding this comment.
Not new to this PR, but shouldn't this yield an immutable/non-modifiable list instead?
There was a problem hiding this comment.
Probably, but I did not want to mix pure refactoring with logic changes 😅
| } | ||
|
|
||
| if (config.defaultValue() instanceof Boolean) { | ||
| return config.cast(Boolean.valueOf(String.valueOf(value))); |
There was a problem hiding this comment.
Not new to this PR:
Looks like this function converts every value to a string and then parses that string even if the type matches, which feels overly expensive.
There was a problem hiding this comment.
I did not want to mix pure refactoring with logic changes 😅 This code was moved "as is".
There was a problem hiding this comment.
Yea - but I think it needs to be tackled in a follow-up.
Configurations are often used on hot code path.
Same for below.
8e18796 to
075a34c
Compare
| * @deprecated Use {@link RealmConfig}. | ||
| */ | ||
| @SuppressWarnings({"DeprecatedIsStillUsed", "removal"}) | ||
| @Deprecated(forRemoval = true) |
There was a problem hiding this comment.
Should the deprecation target the whole class?
| } | ||
| }, | ||
| (rc, name) -> | ||
| Map.of(INCLUDE_PRINCIPAL_NAME_IN_SUBSCOPED_CREDENTIAL.key(), "true").get(name), |
There was a problem hiding this comment.
nit: isn't this simpler?
| Map.of(INCLUDE_PRINCIPAL_NAME_IN_SUBSCOPED_CREDENTIAL.key(), "true").get(name), | |
| INCLUDE_PRINCIPAL_NAME_IN_SUBSCOPED_CREDENTIAL.key().equals(name) ? "true" : null, |
I've seen other similar occurrences in this PR.
There was a problem hiding this comment.
With our formatter, current code is 1 line, the proposed code will take 3 lines 😅
There was a problem hiding this comment.
Maybe, but Alex' way is clearer.
(Troll: Without a formatter, we could squeeze the whole file into a single line :P )
The existing `PolarisConfigurationStore` interface is a fixture of SPI methods providing config values from the environment and utility methods for various lookup parameter permutations and type casts. This change adds `RealmConfigurationSource` for the SPI part and moves lookup logic into `RealmConfigImpl`. Note that existing service code always accesses config via `RealmConfig`. The old `PolarisConfigurationStore` interface remain for backward compatibility and but redirects actual config lookup to `RealmConfigImpl`.
075a34c to
2d6a1ab
Compare
| @Nonnull RealmContext realmContext, | ||
| @Nonnull BasePersistence metaStore, | ||
| @Nonnull PolarisConfigurationStore configurationStore) { | ||
| @Nonnull org.apache.polaris.core.config.PolarisConfigurationStore configurationStore) { |
There was a problem hiding this comment.
note: avoiding imports because IntelliJ warns about deprecation on the import statement and that warning cannot be suppressed 🤷
There was a problem hiding this comment.
IntelliJ warns about deprecation on the import statement
This is strange, because that Java 8 legacy was removed via JEP 211.
| @Nonnull RealmContext realmContext, | ||
| @Nonnull BasePersistence metaStore, | ||
| @Nonnull PolarisConfigurationStore configurationStore) { | ||
| @Nonnull org.apache.polaris.core.config.PolarisConfigurationStore configurationStore) { |
There was a problem hiding this comment.
IntelliJ warns about deprecation on the import statement
This is strange, because that Java 8 legacy was removed via JEP 211.
| } | ||
|
|
||
| if (config.defaultValue() instanceof Boolean) { | ||
| return config.cast(Boolean.valueOf(String.valueOf(value))); |
There was a problem hiding this comment.
Yea - but I think it needs to be tackled in a follow-up.
Configurations are often used on hot code path.
Same for below.
| } | ||
| }, | ||
| (rc, name) -> | ||
| Map.of(INCLUDE_PRINCIPAL_NAME_IN_SUBSCOPED_CREDENTIAL.key(), "true").get(name), |
There was a problem hiding this comment.
Maybe, but Alex' way is clearer.
(Troll: Without a formatter, we could squeeze the whole file into a single line :P )
|
|
||
| @SuppressWarnings("removal") | ||
| @ApplicationScoped | ||
| public class PolarisConfigurationStoreBridge |
There was a problem hiding this comment.
What's the use case of this application-scoped bean?
I only see one usage in a test. Maybe refactor the test or move this type to testFixtures.
The existing
PolarisConfigurationStoreinterface is a fixture of SPI methods providing config values from the environment and utility methods for various lookup parameter permutations and type casts.This change adds
RealmConfigurationSourcefor the SPI part and moves lookup logic intoRealmConfigImpl.Note that existing service code always accesses config via
RealmConfig.The old
PolarisConfigurationStoreinterface remains for backward compatibility and but redirects actual config lookup toRealmConfigImpl.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)