adutra commented on code in PR #1816:
URL: https://github.com/apache/polaris/pull/1816#discussion_r2129064473
##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java:
##########
@@ -94,4 +94,17 @@ public RealmContext getRealmContext() {
public PolarisCallContext getPolarisCallContext() {
return this;
}
+
+ @Override
+ public CallContext copy() {
+ // The realm context is a request scoped bean injected by CDI,
+ // which will be closed after the http request. This copy is currently
+ // only used by TaskExecutor right before the task is handled, since the
+ // task is executed outside the active request scope, we need to make a
+ // copy of the RealmContext to ensure the access during the task executor.
+ String realmId = this.realmContext.getRealmIdentifier();
+ RealmContext realmContext = () -> realmId;
+ return new PolarisCallContext(
+ realmContext, this.metaStore, this.diagServices,
this.configurationStore, this.clock);
Review Comment:
> Those objects are quite usable (via latent references) even after the
associated request context is destroyed.
I am not entirely sure: if the bean is `@ApplicationScoped` then a proxy is
created for it. This means that calling `RealmContext.getRealmIdentifier()`
will fail if the context has been destroyed.
If however the bean is `@Singleton`, I believe that yes, the bean would
remain usable after the context is destroyed, because there is no proxy created
for it.
This begs the question: should we use `@Singleton` whenever possible?
--
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]