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.
Merge pull request quarkusio#41609 from geoand/default-method
Fix bytecode recording issue when default method is used as a getter
- Loading branch information
Showing
8 changed files
with
140 additions
and
3 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
20 changes: 20 additions & 0 deletions
20
...ployment/src/main/java/io/quarkus/extest/deployment/ControllerConfigurationBuildStep.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,20 @@ | ||
package io.quarkus.extest.deployment; | ||
|
||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.extest.runtime.def.ControllerConfigurationProducer; | ||
import io.quarkus.extest.runtime.def.ControllerConfigurationRecorder; | ||
import io.quarkus.extest.runtime.def.QuarkusControllerConfiguration; | ||
|
||
public class ControllerConfigurationBuildStep { | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
public void record(ControllerConfigurationRecorder recorder, BuildProducer<AdditionalBeanBuildItem> producer) { | ||
producer.produce(AdditionalBeanBuildItem.builder().addBeanClasses(ControllerConfigurationProducer.class).build()); | ||
recorder.setControllerConfiguration(new QuarkusControllerConfiguration("test1", "test2")); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ension/extension/deployment/src/test/java/io/quarkus/def/ControllerConfigurationTest.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,35 @@ | ||
package io.quarkus.def; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.extest.runtime.def.ControllerConfiguration; | ||
import io.quarkus.extest.runtime.def.QuarkusControllerConfiguration; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ControllerConfigurationTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withEmptyApplication(); | ||
|
||
@Inject | ||
ControllerConfiguration controllerConfiguration; | ||
|
||
@Test | ||
public void test() { | ||
assertThat(controllerConfiguration).isInstanceOfSatisfying(QuarkusControllerConfiguration.class, | ||
quarkusControllerConfiguration -> { | ||
assertThat(quarkusControllerConfiguration.getName()).isEqualTo("test1"); | ||
assertThat(quarkusControllerConfiguration.getResourceTypeName()).isEqualTo("test2"); | ||
assertThat(controllerConfiguration.getNamespaces()).containsOnly("foo", "bar"); | ||
assertThat(controllerConfiguration.getInformerListLimit()).isEmpty(); | ||
}); | ||
|
||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...xtension/runtime/src/main/java/io/quarkus/extest/runtime/def/ControllerConfiguration.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,8 @@ | ||
package io.quarkus.extest.runtime.def; | ||
|
||
public interface ControllerConfiguration extends ResourceConfiguration { | ||
|
||
default String getName() { | ||
return "name"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../runtime/src/main/java/io/quarkus/extest/runtime/def/ControllerConfigurationProducer.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.extest.runtime.def; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
public class ControllerConfigurationProducer { | ||
|
||
@Singleton | ||
public ControllerConfiguration produce() { | ||
return ControllerConfigurationRecorder.controllerConfiguration; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../runtime/src/main/java/io/quarkus/extest/runtime/def/ControllerConfigurationRecorder.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,13 @@ | ||
package io.quarkus.extest.runtime.def; | ||
|
||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class ControllerConfigurationRecorder { | ||
|
||
public static volatile ControllerConfiguration controllerConfiguration; | ||
|
||
public void setControllerConfiguration(QuarkusControllerConfiguration controllerConfiguration) { | ||
ControllerConfigurationRecorder.controllerConfiguration = controllerConfiguration; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...n/runtime/src/main/java/io/quarkus/extest/runtime/def/QuarkusControllerConfiguration.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,24 @@ | ||
package io.quarkus.extest.runtime.def; | ||
|
||
import io.quarkus.runtime.annotations.RecordableConstructor; | ||
|
||
public class QuarkusControllerConfiguration implements ControllerConfiguration { | ||
|
||
private final String name; | ||
private final String resourceTypeName; | ||
|
||
@RecordableConstructor | ||
public QuarkusControllerConfiguration(String name, String resourceTypeName) { | ||
this.name = name; | ||
this.resourceTypeName = resourceTypeName; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getResourceTypeName() { | ||
return resourceTypeName; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../extension/runtime/src/main/java/io/quarkus/extest/runtime/def/ResourceConfiguration.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,19 @@ | ||
package io.quarkus.extest.runtime.def; | ||
|
||
import java.util.HashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public interface ResourceConfiguration { | ||
|
||
default Set<String> getNamespaces() { | ||
HashSet<String> set = new HashSet<>(); | ||
set.add("foo"); | ||
set.add("bar"); | ||
return set; | ||
} | ||
|
||
default Optional<Long> getInformerListLimit() { | ||
return Optional.empty(); | ||
} | ||
} |