-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC: fix the situation when a framework bean uses an application deco…
…rator ArC-generated classes for framework beans are by default _not_ application classes. This causes problems in hierarchical classloader environments (dev/test mode) when there is an application decorator that applies to the framework bean. This commit fixes that issue by turning the ArC-generated classes for framework beans into application classes whenever an application decorator applies. This makes package access impossible, which is an unfortunate downside. The problem doesn't exist in a flat classloading environment, such as prod mode. (cherry picked from commit f9b2164)
- Loading branch information
Showing
9 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...c/deployment/src/test/java/io/quarkus/arc/test/decorator/DecoratorOfExternalBeanTest.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,49 @@ | ||
package io.quarkus.arc.test.decorator; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.decorator.Decorator; | ||
import jakarta.decorator.Delegate; | ||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.test.supplement.SomeBeanInExternalLibrary; | ||
import io.quarkus.arc.test.supplement.SomeInterfaceInExternalLibrary; | ||
import io.quarkus.builder.Version; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DecoratorOfExternalBeanTest { | ||
// the test includes an _application_ decorator (in the Runtime CL) that applies | ||
// to a bean that is _outside_ of the application (in the Base Runtime CL) | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot(jar -> jar.addClass(MyDecorator.class)) | ||
// we need a non-application archive, so cannot use `withAdditionalDependency()` | ||
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-arc-test-supplement", Version.getVersion()))); | ||
|
||
@Inject | ||
SomeBeanInExternalLibrary bean; | ||
|
||
@Test | ||
public void test() { | ||
assertEquals("Delegated: Hello", bean.hello()); | ||
} | ||
|
||
@Decorator | ||
public static class MyDecorator implements SomeInterfaceInExternalLibrary { | ||
@Inject | ||
@Delegate | ||
SomeInterfaceInExternalLibrary delegate; | ||
|
||
@Override | ||
public String hello() { | ||
return "Delegated: " + delegate.hello(); | ||
} | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...st-supplement/src/main/java/io/quarkus/arc/test/supplement/SomeBeanInExternalLibrary.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,11 @@ | ||
package io.quarkus.arc.test.supplement; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
@Dependent | ||
public class SomeBeanInExternalLibrary implements SomeInterfaceInExternalLibrary { | ||
@Override | ||
public String hello() { | ||
return "Hello"; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...pplement/src/main/java/io/quarkus/arc/test/supplement/SomeInterfaceInExternalLibrary.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,5 @@ | ||
package io.quarkus.arc.test.supplement; | ||
|
||
public interface SomeInterfaceInExternalLibrary { | ||
String hello(); | ||
} |
Empty file.
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
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