-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix loading BuildServices for OSGi #616
Conversation
Signed-off-by: Arjan Tijms <[email protected]>
Looks good to me, but I'd sleep better if I knew why the same change isn't necessary to load |
I'm a little unsure on this. Generally the TCCL is used to access application classes and we don't want the user providing their own @Ladicek |
Second thought, it might at least be worth checking our own classloader before the TCCL to avoid the risk of implementations which aren't using OSGi service loader mediation finding an implementation provided by the application. |
I feel this is a guessing exercise regarding which classloader to use. Does it make sense to pass in the classloader instead? In MP Config, we have this approach, which allows the implementors to pass in the classloader they want to use. |
Hi @Emily-Jiang , how can that approach be used if the method is private? Didn't you rather mean using the setInstance method, which can be called before any call to This is the approach in MicroProfile Config in short:
MP Config doesn't rely on the thread-context classloader because the same effect can be achieved by the call to setInstance method and it's enough to do it once in the beginning. With a thread context classloader solution, thread context classloader would have to be set each time an application can potentially trigger initialization of the SPI, which is an overhead for some implementations that don't normally use thread-context classloader. |
@OndroMih you were right. Open Liberty uses setInstance() and IIRC Payara also uses that. It might be easier to have the similar approach introduced for BuildServicesResolve. All I suggest is not to keep on guessing which classloader to use for OSGi environment espeically. |
I agree |
Might be indeed. Shall we close this PR then? Or does anyone think an attempt to use the context class loader still has merit? |
I personally think that a thread-context classloader still has some value, it allows to initialize the BuildServices instance only if the application needs it. So I'd recommend supporting it too, because it's very simple code and some implementations might find it more convenient than using the setter. But I would also add a setter so that the following alogorithm is used:
Such a solution is still very simple and provides enough flexibility for implementors to hook their own provider into the API. |
I'd rather keep |
The underlying issue was instead resolved by #617 |
Fixes #615
Signed-off-by: Arjan Tijms [email protected]