forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent non-public classes of method params from breaking interceptor…
… handling Fixes: quarkusio#18477
- Loading branch information
Showing
9 changed files
with
186 additions
and
15 deletions.
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
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
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
10 changes: 10 additions & 0 deletions
10
...s/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/methodargs/CustomExecutor.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,10 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs; | ||
|
||
import io.quarkus.arc.test.interceptors.methodargs.base.BaseExecutor; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Simple | ||
public class CustomExecutor extends BaseExecutor { | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
.../arc/tests/src/test/java/io/quarkus/arc/test/interceptors/methodargs/ExampleResource.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,26 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs; | ||
|
||
import java.util.List; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Simple | ||
public class ExampleResource { | ||
|
||
public String create(List<String> strings) { | ||
return String.join(",", strings); | ||
} | ||
|
||
String otherCreate(PackagePrivate packagePrivate) { | ||
return packagePrivate.toString(); | ||
} | ||
|
||
static class PackagePrivate { | ||
|
||
@Override | ||
public String toString() { | ||
return "PackagePrivate{}"; | ||
} | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...src/test/java/io/quarkus/arc/test/interceptors/methodargs/MethodArgsInterceptionTest.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,38 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs; | ||
|
||
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.Counter; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
public class MethodArgsInterceptionTest { | ||
|
||
@RegisterExtension | ||
public ArcTestContainer container = new ArcTestContainer(Simple.class, SimpleInterceptor.class, ExampleResource.class, | ||
CustomExecutor.class, Counter.class); | ||
|
||
@Test | ||
public void testInterception() { | ||
ArcContainer container = Arc.container(); | ||
Counter counter = container.instance(Counter.class).get(); | ||
|
||
counter.reset(); | ||
ExampleResource exampleResource = container.instance(ExampleResource.class).get(); | ||
|
||
assertEquals("first,second", exampleResource.create(List.of("first", "second"))); | ||
assertEquals(1, counter.get()); | ||
|
||
assertEquals("PackagePrivate{}", exampleResource.otherCreate(new ExampleResource.PackagePrivate())); | ||
assertEquals(2, counter.get()); | ||
|
||
CustomExecutor customThreadExecutor = container.instance(CustomExecutor.class).get(); | ||
assertEquals("run", customThreadExecutor.run()); | ||
assertEquals(3, counter.get()); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/methodargs/Simple.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,18 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import javax.interceptor.InterceptorBinding; | ||
|
||
@Target({ TYPE, METHOD }) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@InterceptorBinding | ||
public @interface Simple { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...rc/tests/src/test/java/io/quarkus/arc/test/interceptors/methodargs/SimpleInterceptor.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,23 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs; | ||
|
||
import io.quarkus.arc.test.interceptors.Counter; | ||
import javax.annotation.Priority; | ||
import javax.inject.Inject; | ||
import javax.interceptor.AroundInvoke; | ||
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
@Simple | ||
@Priority(1) | ||
@Interceptor | ||
public class SimpleInterceptor { | ||
|
||
@Inject | ||
Counter counter; | ||
|
||
@AroundInvoke | ||
Object mySuperCoolAroundInvoke(InvocationContext ctx) throws Exception { | ||
counter.incrementAndGet(); | ||
return ctx.proceed(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...rc/tests/src/test/java/io/quarkus/arc/test/interceptors/methodargs/base/BaseExecutor.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,16 @@ | ||
package io.quarkus.arc.test.interceptors.methodargs.base; | ||
|
||
public class BaseExecutor { | ||
|
||
public String run() { | ||
return "run"; | ||
} | ||
|
||
protected void runWorker(Worker run) { | ||
|
||
} | ||
|
||
static class Worker { | ||
|
||
} | ||
} |