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

Filters mixed-up between multiple apps #4615

Closed
martin-sladecek opened this issue Jul 26, 2022 · 7 comments · Fixed by #4786
Closed

Filters mixed-up between multiple apps #4615

martin-sladecek opened this issue Jul 26, 2022 · 7 comments · Fixed by #4786
Assignees
Labels
bug Something isn't working jax-rs JAX-RS and Jersey related issues P1
Projects

Comments

@martin-sladecek
Copy link
Contributor

martin-sladecek commented Jul 26, 2022

Environment Details

  • Helidon Version: 2.5.1
  • Helidon MP
  • JDK version: 17
  • OS: Linux
  • Docker version (if applicable):

Problem Description

Seems like an filter from a different jersey application is sometimes applied.

Steps to reproduce

Run the test in the attached project.
quickstart-mp2.zip

@github-actions github-actions bot added this to Triage in Backlog Jul 26, 2022
@spericas
Copy link
Member

As you know the basic Application isolation provided by Helidon relies on the set of classes returned by getClasses. In this example, isolation is seeked by dynamically attempting to register filters using a feature. All that part is controlled by Jersey and completely outside of Helidon's control. Jersey is likely registering all filters in the same injection manager, and thus provides no isolation.

If the getClasses form of isolation is not sufficient (because it needs to be more dynamic) then you'd need to inspect the context of an individual ServerRequest and avoid running the logic depending on which application is "active". You can @Context-inject ServerRequest and then inspect the context as follows:

        Application app = serverRequest.context().get(Application.class).get();

There's not much else for us to do at this time.

@martin-sladecek
Copy link
Contributor Author

Unfortunately, this does not solve our problem. We have a complex set of libraries, where we want to trigger certain flags dynamically in a Feature, to be read by some filters.
We could workaround this limitation by accessing an Application object in a Feature.
Is there a way to access it or is it possible to implement one?

@m0mus m0mus added bug Something isn't working P2 jax-rs JAX-RS and Jersey related issues labels Aug 4, 2022
@m0mus m0mus moved this from Triage to Sprint Scope in Backlog Aug 4, 2022
@mkuchtiak
Copy link

mkuchtiak commented Aug 11, 2022

I found a workaround for the attached application, to set:
server.single-injection-manager=true
in resources/META-INF/microprofile-config.properties

When this is set, the test in attached application is passing fine.

but, however, this is not recommended setting, right ?

@spericas
Copy link
Member

spericas commented Aug 16, 2022

Can you confirm that this new access would cover your use case?

    public boolean configure(FeatureContext context) {
        Application app = Contexts.context().flatMap(c -> c.get(Application.class)).orElse(null);
        System.out.println("app = " + app);

        // ...
        return true;
    }

Note that this is using Helidon's context, not the feature's context or any other class from JAX-RS.

@martin-sladecek
Copy link
Contributor Author

Yes, I think this should be sufficient. Will the same apply to AutoDiscoverable?

@spericas spericas added P1 and removed P2 labels Aug 18, 2022
@spericas
Copy link
Member

PR #4745

@spericas
Copy link
Member

Closing this issue at this time. We have found a workaround that uses the feature in PR #4745 (targeted for 2.5.3).

Backlog automation moved this from Sprint Scope to Closed Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jax-rs JAX-RS and Jersey related issues P1
Projects
Backlog
  
Closed
4 participants