-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
IllegalStateException "The current thread cannot be blocked: vert.x-eventloop-thread-1" in kafka topic message processing while invoking SecurityIdentity.getPrincipal() #13835
Comments
/cc @sberyozkin |
Are you using Reactive Messaging? |
yes, this is part of a @incoming method. |
Does the problem not go away if you add |
Adding |
Not a bother at all! @sberyozkin should we document somewhere that |
If we can't get the principal without blocking, I think we have an issue :) /cc @cescoffier |
Why? |
Hi Georgios @geoand, Guillaume @gsmet I agree here with Guillaume, |
Though due to the proxification it is not going directly to it, not sure why it has to go through the internal thread local map; well - because it is a thread safe proxy :-) |
@geoand my guess is that you will need the principal as soon as you're dealing with security. So if you can't get it without blocking, that means any secure endpoint will need to be blocking. Now I have no idea how you deal with this when your users are stored in a database. |
By the time the endpoint is invoked |
@sberyozkin You should not use |
This is because of the changes around lazy authentication. Basically lots of places that were using SecurityIdentity are now using Uni, as there is a chance that authentication has not actually happened yet, and subscribing to the Uni would trigger the authentication attempt. When proactive auth is in use (the default) await will never block. I should be able to fix this, but the resulting code won't be quite as clean. |
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
Hey Clement @cescoffier I promise I can repeat it if someone wakes me up at night and asks, what you should not do with |
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
This will no longer wrap the Identity in a Uni if proactive auth is in use. This also resolves a problem with setting the current SecurityIdentity via a CDI event, which is not compatible with lazy authentication. Note that the problem can still occur if using lazy auth from the IO thread, which is expected. To get the identity in this situation you need to use CurrentIdentityAssociation#getDeferredIdentity and subscribe to the result. Fixes quarkusio#13835
A bug causes authentication checks to fail when performed from inside a reactive operation: quarkusio/quarkus#13835 To avoid such a reactive operation, we now render the HTML template eagerly even in NewsletterResource#register, which is otherwise a reactive implementation. Change-Id: I26d6c1cc76eaa041a04c106b7cf06f024a0cded3
Describe the bug
Using Quarkus 1.9.2 the very same code was working fine which is now failing with 1.10.3. I found a similar issue "OIDC 1.10.0.CR1 - event loop thread blocked #13249" but it was closed so I am not sure whether it is really the same problem.
We implemented a process which is receiving a message from a kafka topic and in that process we try to retrieve the name of the user if there is one with the following snippet (I mean, in this case there is no user, but in other cases where the code is used we have a user, and this class does more than just retrieving the name).
Quarkus started to throw an exception with 1.10 release:
Expected behavior
getPrincipal() should return null in case no user can be retrieved.
Actual behavior
Exception is thrown
To Reproduce
In above mentioned issue you are describing that all await need to be removed. I checked this SecurityIdentityAssociation class, there are still some awaits. So I feel that maybe a reproducer might not be required as maybe the issue is clear. But if this is a different problem I can work on a reproducer, please let me know.
Environment (please complete the following information):
Output of uname -a or ver: Microsoft Windows [Version 10.0.17763.1282]
Output of java -version: openjdk version "11" 2018-09-25
GraalVM version (if different from Java):
Quarkus version or git rev: 1.10.3.Final
Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
The text was updated successfully, but these errors were encountered: