-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid locking the lazy provider when the value is cached #519
Conversation
Why do that? This is changing the semantics? |
I'm getting null pointer exceptions when trying to use a provider within a Beanscope. |
due to certain peculiarities with re-authenticating mongo I'm trying to register a
Example Code: class MyRepoImpl {
final Provider<MongoCollection> cProv;
MongoCollection coll;
RepoImpl(Provider<MongoCollection> cProv){
this.cProv = cProv;
coll = cProv.get(); // dies here
}
getRotatedMongo() {
coll = cProv.get();
}
someOperation() {
//if some Auth Error
getRotatedMongo()
}
} |
Well ok but I think that means we need 2 separate PRs. We need to document the NPE bug as a bug with ideally a stack trace that folks might be able to find etc. Plus we need the history as people read it via the PR titles to reasonably reflect the change (and so currently the title does not reflect anything about a NPE bug). So yeah, I think we need to split this into 2 PRs for those reasons. |
Technically the get is being called during wiring. That is the constructor is called during wiring (and wiring has not completed yet and this is why the NPE). I think the expectation would have been to use a |
Note that with `Supplier<T>` its a little different than `Provider<T>` in that `Provider<T>` is used to support circular dependency wiring so its a way to delay the wiring (until after all the constructors are called). We don't have that limitation with Supplier.
My thought is that instead of In this way the |
Note that with `Supplier<T>` its a little different than `Provider<T>` in that `Provider<T>` is used to support circular dependency wiring so its a way to delay the wiring (until after all the constructors are called). We don't have that limitation with Supplier.
Pull request was closed
ProviderPromise
to retrieve the provider from the bean map whenget
is called