Skip to content

Refactor PolarisConfigurationStore to streamline value typing#3324

Closed
dimas-b wants to merge 2 commits intoapache:mainfrom
dimas-b:more-config-types
Closed

Refactor PolarisConfigurationStore to streamline value typing#3324
dimas-b wants to merge 2 commits intoapache:mainfrom
dimas-b:more-config-types

Conversation

@dimas-b
Copy link
Contributor

@dimas-b dimas-b commented Dec 24, 2025

  • Avoid generic return types when the value type is not certain

  • Add new method to be overridden by implementation that returns Object to avoid arbitrary casts to T

  • Type casts are performed only when the expected value type is known.

  • This change is backward-compatible with older implementations of PolarisConfigurationStore

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)

Comment on lines 42 to 45
* <p>This method is meant to be overridden by concrete configuration store implementations. This
* method is not meant to be calls by code that needs access to configuration values.
* Configuration consumers should call typed methods that take a {@link PolarisConfiguration}
* parameter instead.
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
* <p>This method is meant to be overridden by concrete configuration store implementations. This
* method is not meant to be calls by code that needs access to configuration values.
* Configuration consumers should call typed methods that take a {@link PolarisConfiguration}
* parameter instead.
* <p>This method is meant to be overridden by concrete configuration store implementations.
* Prefer the typed functions that take a {@link PolarisConfiguration} parameter instead of a {@code String}.

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 reformatted the javadoc, hoping to emphasize the need to use typed methods.

TBH, I'm not sure whether the "prefer" suggestion is targeting callers or implementors 🤔 WDYT?

* Avoid generic return types when the value type is not certain

* Add new method to be overridden by implementation that returns `Object` to avoid arbitrary casts to `T`

* Type casts are performed only when the expected value type is known.

* This change is backward-compatible with older implementations of `PolarisConfigurationStore`
@dimas-b dimas-b force-pushed the more-config-types branch from 53dc814 to a71fbcb Compare January 5, 2026 16:15
/**
* Retrieve the current value for a configuration key for a given realm. May be null if not set.
*
* <p>This method is meant to be overridden by concrete configuration store implementations.
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I wonder whether this function and the getConfiguration functions should have a default implementation at all. Wouldn't it be cleaner to move that to the actual implementation? Mean, this interface isn't really an interface but rather a not-really abstract 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. I've been thinking about splitting this into an API/SPI pair too, but I thought it might be too intrusive... Let me actually try that refactoring and see what's impacted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prerequisite refactoring: #3412

dimas-b added a commit to dimas-b/polaris that referenced this pull request Jan 10, 2026
* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with apache#3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in apache#3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.
@dimas-b dimas-b marked this pull request as draft January 10, 2026 02:50
dimas-b added a commit to dimas-b/polaris that referenced this pull request Jan 14, 2026
* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with apache#3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in apache#3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.
dimas-b added a commit to dimas-b/polaris that referenced this pull request Jan 14, 2026
* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with apache#3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in apache#3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.
dimas-b added a commit that referenced this pull request Jan 19, 2026
* Use injected RealmConfig in JdbcMetaStoreManagerFactory

* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with #3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in #3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.
evindj pushed a commit to evindj/polaris that referenced this pull request Jan 26, 2026
* Use injected RealmConfig in JdbcMetaStoreManagerFactory

* Improve code isolation by using `RealmConfig` (like most other code)
  instead of the lower-level `PolarisConfigurationStore`

* This also enabled proper CDI request-scoped injection in concert with apache#3411

* Additionally, this enables further code cleanup in `PolarisConfigurationStore`
  as discussed in apache#3324 with the goal of using this interface for the backend
  configuration code, while `RealmConfig` becomes the corresponding frontend
  interface.

* Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from
  its dependencies (not from `CallContext`) to avoid cycles in CDI.
@dimas-b
Copy link
Contributor Author

dimas-b commented Jan 27, 2026

Closing in favour of #3573

@dimas-b dimas-b closed this Jan 27, 2026
@github-project-automation github-project-automation bot moved this from PRs In Progress to Done in Basic Kanban Board Jan 27, 2026
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.

2 participants