-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Intercepted subclasses generation - fix evaluation of skipped methods #21781
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...c/test/java/io/quarkus/arc/test/interceptors/nonpublicparams/NonPublicParametersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.quarkus.arc.test.interceptors.nonpublicparams; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.arc.ArcContainer; | ||
import io.quarkus.arc.test.ArcTestContainer; | ||
import io.quarkus.arc.test.interceptors.Simple; | ||
import io.quarkus.arc.test.interceptors.nonpublicparams.charlie.Charlie; | ||
import javax.annotation.Priority; | ||
import javax.inject.Singleton; | ||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class NonPublicParametersTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Simple.class, SimpleBean.class, | ||
SimpleInterceptor.class); | ||
|
||
@Test | ||
public void testInterception() { | ||
ArcContainer arc = Arc.container(); | ||
SimpleBean simpleBean = arc.instance(SimpleBean.class).get(); | ||
assertEquals("FOO", | ||
simpleBean.foo(null, new Bar(), new Baz(), null)); | ||
} | ||
|
||
@Singleton | ||
static class SimpleBean extends Charlie { | ||
|
||
@Simple | ||
String foo(Foo foo, Bar bar, Baz baz, CharlieParam charlie) { | ||
return "foo"; | ||
} | ||
|
||
@Simple | ||
String fooArray(Foo[] foo, boolean isOk) { | ||
return "foo"; | ||
} | ||
|
||
private static class Foo { | ||
} | ||
|
||
} | ||
|
||
static class Bar { | ||
|
||
} | ||
|
||
protected static class Baz { | ||
|
||
} | ||
|
||
@Simple | ||
@Priority(1) | ||
@Interceptor | ||
public static class SimpleInterceptor { | ||
|
||
@AroundInvoke | ||
Object mySuperCoolAroundInvoke(InvocationContext ctx) throws Exception { | ||
return ctx.proceed().toString().toUpperCase(); | ||
} | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...tests/src/test/java/io/quarkus/arc/test/interceptors/nonpublicparams/charlie/Charlie.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.quarkus.arc.test.interceptors.nonpublicparams.charlie; | ||
|
||
public class Charlie { | ||
|
||
protected class CharlieParam { | ||
|
||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this should be an error rather than a warning. We have seen cases where security interceptors are not applied even though the user was expecting them to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but the problem is that if you annotate a class with an interceptor binding then all methods (incl. inherited ones) should be intercepted and sometimes you need to extend a class from a different package which you don't control. Such an extended class may declare e.g. a package-private method that accepts a private param type. And since you're not able to modify the extended class you'd be screwed. An example from the original issue is
java.util.concurrent.ThreadPoolExecutor
andThreadPoolExecutor.runWorker(Worker)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this PR. @stuartwdouglas if you really think that the current behavior is wrong (actually, before this PR the method is ignored and no warning is logged) then pls file a new issue.