Skip to content
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

Dynamically registered Provider classes create thousands of ServiceLocators #4063

Closed
mpfz0r opened this issue Feb 19, 2019 · 2 comments
Closed
Labels
notabug not a bug, will not be fixed

Comments

@mpfz0r
Copy link

mpfz0r commented Feb 19, 2019

While tracking down a performance problem (Graylog2/graylog2-server#5669)
I noticed that Jersey was creating thousands of ServiceLocators in our application.
Since we are creating a GuiceBridge for each Locator, a lot of time is spent filling the cache
of the GuiceToHk2JitResolver.

The root of the problem is that Jersey creates a ServiceLocator for each Resource
in case of a dynamically registered Provider class:
https://github.com/eclipse-ee4j/jersey/blob/master/core-server/src/main/java/org/glassfish/jersey/server/model/ResourceMethodInvoker.java#L229

What's the reason behind this? Why do we need a separate DI context in this case?

I also build a small demo app that exposes the problem:
https://github.com/mpfz0r/jersey-di-issue

@senivam
Copy link
Contributor

senivam commented Feb 21, 2019

Jersey acts so per JAX-RS specification (https://download.oracle.com/javaee-archive/jax-rs-spec.java.net/jsr339-experts/att-3593/spec.pdf): chapter 3, paragraphs 3.1.1 Lifecycle and Environment and 3.1.2 Constructors

Closing the issue as expected behavior.

@senivam senivam closed this as completed Feb 21, 2019
@senivam senivam added the notabug not a bug, will not be fixed label Feb 21, 2019
@mpfz0r
Copy link
Author

mpfz0r commented Feb 27, 2019

Jersey acts so per JAX-RS specification (https://download.oracle.com/javaee-archive/jax-rs-spec.java.net/jsr339-experts/att-3593/spec.pdf): chapter 3, paragraphs 3.1.1 Lifecycle and Environment and 3.1.2 Constructors

Thanks,
after reading this, I still fail to understand why each Resource needs a separate ServiceLocator.
Even if this is not a bug, the current implementation has a huge performance impact in the use case
I described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notabug not a bug, will not be fixed
Projects
None yet
Development

No branches or pull requests

2 participants