Skip to content

Introduce RealmConfigurationSource#3573

Open
dimas-b wants to merge 3 commits intoapache:mainfrom
dimas-b:realm-config-source
Open

Introduce RealmConfigurationSource#3573
dimas-b wants to merge 3 commits intoapache:mainfrom
dimas-b:realm-config-source

Conversation

@dimas-b
Copy link
Contributor

@dimas-b dimas-b commented Jan 27, 2026

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 remains for backward compatibility and but redirects actual config lookup to RealmConfigImpl.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

public interface RealmConfigurationSource {
RealmConfigurationSource EMPTY_CONFIG = (rc, name) -> null;

static RealmConfigurationSource global(Map<String, ?> config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static RealmConfigurationSource global(Map<String, ?> config) {
@VisibleForTesting
static RealmConfigurationSource global(Map<String, ?> config) {

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlined

} 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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new to this PR, but shouldn't this yield an immutable/non-modifiable list instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to mix pure refactoring with logic changes 😅 This code was moved "as is".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea - but I think it needs to be tackled in a follow-up.
Configurations are often used on hot code path.
Same for below.

@dimas-b dimas-b force-pushed the realm-config-source branch from 8e18796 to 075a34c Compare February 4, 2026 18:00
adutra
adutra previously approved these changes Feb 5, 2026
* @deprecated Use {@link RealmConfig}.
*/
@SuppressWarnings({"DeprecatedIsStillUsed", "removal"})
@Deprecated(forRemoval = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the deprecation target the whole class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

}
},
(rc, name) ->
Map.of(INCLUDE_PRINCIPAL_NAME_IN_SUBSCOPED_CREDENTIAL.key(), "true").get(name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: isn't this simpler?

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With our formatter, current code is 1 line, the proposed code will take 3 lines 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but Alex' way is clearer.

(Troll: Without a formatter, we could squeeze the whole file into a single line :P )

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Feb 5, 2026
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`.
@Nonnull RealmContext realmContext,
@Nonnull BasePersistence metaStore,
@Nonnull PolarisConfigurationStore configurationStore) {
@Nonnull org.apache.polaris.core.config.PolarisConfigurationStore configurationStore) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: avoiding imports because IntelliJ warns about deprecation on the import statement and that warning cannot be suppressed 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants