id
int64
0
10.2k
text_id
stringlengths
17
67
repo_owner
stringclasses
232 values
repo_name
stringclasses
295 values
issue_url
stringlengths
39
89
pull_url
stringlengths
37
87
comment_url
stringlengths
37
94
links_count
int64
1
2
link_keyword
stringclasses
12 values
issue_title
stringlengths
7
197
issue_body
stringlengths
45
21.3k
base_sha
stringlengths
40
40
head_sha
stringlengths
40
40
diff_url
stringlengths
120
170
diff
stringlengths
478
132k
changed_files
stringlengths
47
2.6k
changed_files_exts
stringclasses
22 values
changed_files_count
int64
1
22
java_changed_files_count
int64
1
22
kt_changed_files_count
int64
0
0
py_changed_files_count
int64
0
0
code_changed_files_count
int64
1
22
repo_symbols_count
int64
32.6k
242M
repo_tokens_count
int64
6.59k
49.2M
repo_lines_count
int64
992
6.2M
repo_files_without_tests_count
int64
12
28.1k
changed_symbols_count
int64
0
36.1k
changed_tokens_count
int64
0
6.5k
changed_lines_count
int64
0
561
changed_files_without_tests_count
int64
1
17
issue_symbols_count
int64
45
21.3k
issue_words_count
int64
2
1.39k
issue_tokens_count
int64
13
4.47k
issue_lines_count
int64
1
325
issue_links_count
int64
0
19
issue_code_blocks_count
int64
0
31
pull_create_at
timestamp[s]
repo_stars
int64
10
44.3k
repo_language
stringclasses
8 values
repo_languages
stringclasses
296 values
repo_license
stringclasses
2 values
2,530
quarkusio/quarkus/22917/22911
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22911
https://github.com/quarkusio/quarkus/pull/22917
https://github.com/quarkusio/quarkus/pull/22917
1
resolves
CLI cannot remove registry from the list
### Describe the bug Registries added to cli cannot be removed ### Expected behavior Attempts to remove registries from config should be successfull ### Actual behavior Attempt to remove a registry from the list leads to error `Can only remove registries from an existing configuration. The specified config file does not exist: null` ### How to Reproduce? 1. `quarkus registry add quarkus.example.com` 2. Check the list: ``` $ quarkus registry Configured Quarkus extension registries: registry.quarkus.io quarkus.example.com (Config source: file: ~/.quarkus/config.yaml) ``` 2. `$ quarkus registry remove quarkus.example.com` ### Output of `uname -a` or `ver` OS name: "linux", version: "5.15.6-100.fc34.x86_64" ### Output of `java -version` 11.0.13, vendor: Eclipse Adoptium ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.6.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
0ab516441721f5b4eab72acabf2afd3817d84326
1827376df1afc4d543ace1a12673bab00219d892
https://github.com/quarkusio/quarkus/compare/0ab516441721f5b4eab72acabf2afd3817d84326...1827376df1afc4d543ace1a12673bab00219d892
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java index 7ce770d8546..284b57a0c63 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java @@ -7,6 +7,7 @@ import io.quarkus.cli.registry.BaseRegistryCommand; import io.quarkus.registry.config.RegistriesConfig; +import io.quarkus.registry.config.RegistryConfig; import picocli.CommandLine; @CommandLine.Command(name = "add", sortOptions = false, showDefaultValues = true, mixinStandardHelpOptions = false, header = "Add a Quarkus extension registry", description = "%n" @@ -30,7 +31,6 @@ public Integer call() throws Exception { existingConfig = Files.exists(configYaml); } - registryClient.refreshRegistryCache(output); final RegistriesConfig.Mutable config; if (configYaml != null && !existingConfig) { // we're creating a new configuration for a new file @@ -38,6 +38,7 @@ public Integer call() throws Exception { } else { config = registryClient.resolveConfig().mutable(); } + registryClient.refreshRegistryCache(output); boolean persist = false; for (String registryId : registryIds) { @@ -45,6 +46,10 @@ public Integer call() throws Exception { } if (persist) { + output.printText("Configured registries:"); + for (RegistryConfig rc : config.getRegistries()) { + output.printText("- " + rc.getId()); + } if (configYaml != null) { config.persist(configYaml); } else { diff --git a/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java index 27b27916167..b98aa196299 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java @@ -7,6 +7,7 @@ import io.quarkus.cli.registry.BaseRegistryCommand; import io.quarkus.registry.config.RegistriesConfig; +import io.quarkus.registry.config.RegistryConfig; import picocli.CommandLine; @CommandLine.Command(name = "remove", sortOptions = false, showDefaultValues = true, mixinStandardHelpOptions = false, header = "Remove a Quarkus extension registry", description = "%n" @@ -31,18 +32,13 @@ public Integer call() throws Exception { } final RegistriesConfig.Mutable config; - if (existingConfig) { - registryClient.refreshRegistryCache(output); - config = registryClient.resolveConfig().mutable(); - if (config.getSource().getFilePath() == null) { - output.error("Can only modify file-based configuration. Config source is " + config.getSource().describe()); - return CommandLine.ExitCode.SOFTWARE; - } + if (configYaml != null && !existingConfig) { + // we're creating a new configuration for a new file + config = RegistriesConfig.builder(); } else { - output.error("Can only remove registries from an existing configuration. The specified config file does not exist: " - + configYaml); - return CommandLine.ExitCode.SOFTWARE; + config = registryClient.resolveConfig().mutable(); } + registryClient.refreshRegistryCache(output); boolean persist = false; for (String registryId : registryIds) { @@ -50,7 +46,15 @@ public Integer call() throws Exception { } if (persist) { - config.persist(); + output.printText("Configured registries:"); + for (RegistryConfig rc : config.getRegistries()) { + output.printText("- " + rc.getId()); + } + if (configYaml != null) { + config.persist(configYaml); + } else { + config.persist(); + } } return CommandLine.ExitCode.OK; } diff --git a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java index 402dcc83643..27047474844 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java @@ -12,7 +12,6 @@ import picocli.CommandLine; import picocli.CommandLine.Help.ColorScheme; import picocli.CommandLine.Model.CommandSpec; -import picocli.CommandLine.Spec; public class OutputOptionMixin implements MessageWriter { @@ -83,7 +82,7 @@ public boolean isAnsiEnabled() { return CommandLine.Help.Ansi.AUTO.enabled(); } - public void printText(String[] text) { + public void printText(String... text) { for (String line : text) { out().println(colorScheme().ansi().new Text(line, colorScheme())); }
['devtools/cli/src/main/java/io/quarkus/cli/RegistryRemoveCommand.java', 'devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java', 'devtools/cli/src/main/java/io/quarkus/cli/common/OutputOptionMixin.java']
{'.java': 3}
3
3
0
0
3
19,362,941
3,750,666
493,403
4,772
1,812
327
36
3
1,072
142
274
48
0
1
1970-01-01T00:27:22
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,502
quarkusio/quarkus/23620/23602
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23602
https://github.com/quarkusio/quarkus/pull/23620
https://github.com/quarkusio/quarkus/pull/23620
1
fixes
Using Mongo ChangeStreamDocument in Native Image Fails Decoding On Update
### Describe the bug Using the Mongo ChangeStream fails in native mode when receiving notification of a database update with the following error: ```posh Change Stream Subscription Error: org.bson.codecs.configuration.CodecConfigurationException: Failed to decode 'ChangeStreamDocument'. Decoding 'updateDescription' errored with: Cannot find a public constructor for 'UpdateDescription'. event-publishing-eventPublisher-1 | at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:206) event-publishing-eventPublisher-1 | at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:179) event-publishing-eventPublisher-1 | at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:103) event-publishing-eventPublisher-1 | at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:107) event-publishing-eventPublisher-1 | at com.mongodb.client.model.changestream.ChangeStreamDocumentCodec.decode(ChangeStreamDocumentCodec.java:63) event-publishing-eventPublisher-1 | at com.mongodb.client.model.changestream.ChangeStreamDocumentCodec.decode(ChangeStreamDocumentCodec.java:35) event-publishing-eventPublisher-1 | at org.bson.RawBsonDocument.decode(RawBsonDocument.java:161) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.ChangeStreamBatchCursor.convertAndProduceLastId(ChangeStreamBatchCursor.java:185) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor$2.onResult(AsyncChangeStreamBatchCursor.java:201) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor$2.onResult(AsyncChangeStreamBatchCursor.java:194) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncQueryBatchCursor.next(AsyncQueryBatchCursor.java:163) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor$1.apply(AsyncChangeStreamBatchCursor.java:83) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor.resumeableOperation(AsyncChangeStreamBatchCursor.java:194) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.AsyncChangeStreamBatchCursor.next(AsyncChangeStreamBatchCursor.java:79) event-publishing-eventPublisher-1 | at com.mongodb.reactivestreams.client.internal.BatchCursor.lambda$next$0(BatchCursor.java:35) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoPeek.subscribe(MonoPeek.java:67) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoPeek.subscribe(MonoPeek.java:67) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) event-publishing-eventPublisher-1 | at reactor.core.publisher.Mono.subscribe(Mono.java:3873) event-publishing-eventPublisher-1 | at reactor.core.publisher.Mono.subscribeWith(Mono.java:3979) event-publishing-eventPublisher-1 | at reactor.core.publisher.Mono.subscribe(Mono.java:3758) event-publishing-eventPublisher-1 | at com.mongodb.reactivestreams.client.internal.BatchCursorFlux.recurseCursor(BatchCursorFlux.java:104) event-publishing-eventPublisher-1 | at com.mongodb.reactivestreams.client.internal.BatchCursorFlux.lambda$subscribe$0(BatchCursorFlux.java:56) event-publishing-eventPublisher-1 | at reactor.core.publisher.LambdaMonoSubscriber.onNext(LambdaMonoSubscriber.java:137) event-publishing-eventPublisher-1 | at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) event-publishing-eventPublisher-1 | at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1643) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:241) event-publishing-eventPublisher-1 | at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192) event-publishing-eventPublisher-1 | at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:156) event-publishing-eventPublisher-1 | at com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.lambda$sinkToCallback$30(MongoOperationPublisher.java:549) event-publishing-eventPublisher-1 | at com.mongodb.reactivestreams.client.internal.OperationExecutorImpl.lambda$execute$2(OperationExecutorImpl.java:78) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.ChangeStreamOperation$2$1.call(ChangeStreamOperation.java:347) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.OperationHelper.withAsyncConnectionSource(OperationHelper.java:727) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.OperationHelper.access$100(OperationHelper.java:69) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.OperationHelper$AsyncCallableWithSourceCallback.onResult(OperationHelper.java:706) event-publishing-eventPublisher-1 | at com.mongodb.internal.operation.OperationHelper$AsyncCallableWithSourceCallback.onResult(OperationHelper.java:696) event-publishing-eventPublisher-1 | at com.mongodb.internal.async.ErrorHandlingResultCallback.onResult(ErrorHandlingResultCallback.java:48) event-publishing-eventPublisher-1 | at com.mongodb.internal.async.client.ClientSessionBinding$WrappingCallback.onResult(ClientSessionBinding.java:267) event-publishing-eventPublisher-1 | at com.mongodb.internal.async.client.ClientSessionBinding$WrappingCallback.onResult(ClientSessionBinding.java:255) event-publishing-eventPublisher-1 | at com.mongodb.internal.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:119) event-publishing-eventPublisher-1 | at com.mongodb.internal.binding.AsyncClusterBinding$1.onResult(AsyncClusterBinding.java:113) event-publishing-eventPublisher-1 | at com.mongodb.internal.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:430) event-publishing-eventPublisher-1 | at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:294) event-publishing-eventPublisher-1 | at com.mongodb.internal.connection.BaseCluster.selectServerAsync(BaseCluster.java:155) event-publishing-eventPublisher-1 | at com.mongodb.internal.connection.SingleServerCluster.selectServerAsync(SingleServerCluster.java:41) ``` This works fine in jvm mode, suggesting some classes may need registering for reflection ### Expected behavior Expect document unmarshalled correctly. ### Actual behavior _No response_ ### How to Reproduce? https://github.com/luke-gee/monog-changestream-reproducer Added steps in the readme ### Output of `uname -a` or `ver` Microsoft Windows [Version 10.0.19042.1466] ### Output of `java -version` openjdk version "16.0.2" 2021-07-20 OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 16.0.2+7-jvmci-21.2-b08) OpenJDK 64-Bit Server VM GraalVM CE 21.2.0 (build 16.0.2+7-jvmci-21.2-b08, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) mvn ### Additional information Image build in container, not using the java env above.
8a6287ca678fc59d37f7a76d32f232718e26a088
4ff6eb085eecbce555e74cb5cd4c3873cd674abf
https://github.com/quarkusio/quarkus/compare/8a6287ca678fc59d37f7a76d32f232718e26a088...4ff6eb085eecbce555e74cb5cd4c3873cd674abf
diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java index 333a38bea82..962c20e2709 100644 --- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java +++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java @@ -26,6 +26,7 @@ import com.mongodb.client.MongoClient; import com.mongodb.client.model.changestream.ChangeStreamDocument; +import com.mongodb.client.model.changestream.UpdateDescription; import com.mongodb.event.CommandListener; import com.mongodb.event.ConnectionPoolListener; @@ -151,6 +152,7 @@ List<ReflectiveClassBuildItem> addExtensionPointsToNative(CodecProviderBuildItem .collect(Collectors.toCollection(ArrayList::new)); // ChangeStreamDocument needs to be registered for reflection with its fields. reflectiveClass.add(new ReflectiveClassBuildItem(true, true, true, ChangeStreamDocument.class.getName())); + reflectiveClass.add(new ReflectiveClassBuildItem(true, true, false, UpdateDescription.class.getName())); return reflectiveClass; }
['extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java']
{'.java': 1}
1
1
0
0
1
19,704,325
3,814,274
501,613
4,842
178
33
2
1
7,492
346
1,754
94
1
1
1970-01-01T00:27:24
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,501
quarkusio/quarkus/23625/23573
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23573
https://github.com/quarkusio/quarkus/pull/23625
https://github.com/quarkusio/quarkus/pull/23625
1
fixes
Confusing, if not downright wrong, warning message
### Describe the bug I run my app in dev mode. I change a build time property in `application.properties` and the application properly restarts but I get the following warning in the console: ```java 2022-02-10 09:57:08,244 WARN [io.qua.run.con.ConfigRecorder] (Quarkus Main Thread) Build time property cannot be changed at runtime: - quarkus.operator-sdk.crd.apply was 'true' at build time and is now 'false' ``` What is this message trying to tell me? What is the state of my property, i.e. is it `true` or is it `false`? ### Expected behavior A clear message as to what happened. ### Actual behavior The currently ambiguous or wrong message. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
a75b6db3ed6867d37ed605417944bd2154c85202
f2f37f8ad8372e6ffa7f59ef48f970b85b260094
https://github.com/quarkusio/quarkus/compare/a75b6db3ed6867d37ed605417944bd2154c85202...f2f37f8ad8372e6ffa7f59ef48f970b85b260094
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java index 5b39842d77f..aaec129f11e 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java @@ -34,9 +34,9 @@ public void handleConfigChange(Map<String, String> buildTimeConfig) { if (mismatches == null) { mismatches = new ArrayList<>(); } - mismatches.add( - " - " + entry.getKey() + " was '" + entry.getValue() + "' at build time and is now '" + val.get() - + "'"); + mismatches.add(" - " + entry.getKey() + " is set to '" + entry.getValue() + + "' but it is build time fixed to '" + val.get() + "'. Did you change the property " + + entry.getKey() + " after building the application?"); } } }
['core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java']
{'.java': 1}
1
1
0
0
1
19,708,657
3,815,251
501,731
4,842
503
94
6
1
1,021
158
260
47
0
1
1970-01-01T00:27:24
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,500
quarkusio/quarkus/23648/23646
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23646
https://github.com/quarkusio/quarkus/pull/23648
https://github.com/quarkusio/quarkus/pull/23648
1
fix
quarkus:info/update doesn't handle modules defined in activeByDefault profile
### Describe the bug quarkus:info/update doesn't handle modules defined in activeByDefault profile `mvn quarkus:info` works if `mvn clean install` is executed before the command (and thus the module defined in profile gets into local maven repository. When running `mvn clean test` the module defined in activeByDefault profile gets picked, but running `mvn quarkus:info` command ends with `[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.7.1.Final:info (default-cli) on project module-c: Failed to resolve the Quarkus application model for project org.acme:module-c::pom:1.0.0-SNAPSHOT: Failed to resolve artifact org.acme:module-c:pom:1.0.0-SNAPSHOT: Could not find artifact org.acme:module-c:pom:1.0.0-SNAPSHOT -> [Help 1]` part of the stacktrace when using `mvn -e ...` ``` Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.acme:module-c:pom:1.0.0-SNAPSHOT at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:414) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact (DefaultRepositorySystem.java:262) at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolveInternal (MavenArtifactResolver.java:164) at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolve (MavenArtifactResolver.java:158) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolve (BootstrapAppModelResolver.java:323) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.doResolveModel (BootstrapAppModelResolver.java:195) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveManagedModel (BootstrapAppModelResolver.java:166) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveModel (BootstrapAppModelResolver.java:149) at io.quarkus.maven.QuarkusProjectStateMojoBase.resolveApplicationModel (QuarkusProjectStateMojoBase.java:69) at io.quarkus.maven.InfoMojo.processProjectState (InfoMojo.java:33) at io.quarkus.maven.QuarkusProjectStateMojoBase.doExecute (QuarkusProjectStateMojoBase.java:56) at io.quarkus.maven.QuarkusProjectMojoBase.execute (QuarkusProjectMojoBase.java:111) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) ``` @aloubyansky ### Expected behavior quarkus:info/update executed properly on modules defined in activeByDefault profile ### Actual behavior quarkus:info/update is not executed properly on modules defined in activeByDefault profile, ends with failure to resolve artifact ### How to Reproduce? - clone https://github.com/rsvoboda/code-with-quarkus-multi (module-c is defined in profile that is activatedByDefault) - run `mvn quarkus:info` ### Output of `uname -a` or `ver` macOS ### Output of `java -version` Java 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.1 ### Additional information _No response_
cb23550e66fddbe3b62c921ce4c27134d3e4aaf8
d351f25981eab3e2c907b343e46c55886f669c54
https://github.com/quarkusio/quarkus/compare/cb23550e66fddbe3b62c921ce4c27134d3e4aaf8...d351f25981eab3e2c907b343e46c55886f669c54
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java index 94d93a29de7..8ab8dd01203 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java @@ -50,11 +50,20 @@ public void doExecute(QuarkusProject quarkusProject, MessageWriter log) throws M throw new MojoExecutionException("This goal requires a Quarkus extension registry client to be enabled"); } + // to support profiles + final String emb = System.getProperty("quarkus.bootstrap.effective-model-builder"); + System.setProperty("quarkus.bootstrap.effective-model-builder", "true"); + final Collection<Path> createdDirs = ensureResolvable(new DefaultArtifact(project.getGroupId(), project.getArtifactId(), ArtifactCoords.TYPE_POM, project.getVersion())); try { processProjectState(quarkusProject); } finally { + if (emb == null) { + System.clearProperty("quarkus.bootstrap.effective-model-builder"); + } else { + System.setProperty("quarkus.bootstrap.effective-model-builder", emb); + } for (Path p : createdDirs) { IoUtils.recursiveDelete(p); }
['devtools/maven/src/main/java/io/quarkus/maven/QuarkusProjectStateMojoBase.java']
{'.java': 1}
1
1
0
0
1
19,715,010
3,816,520
501,892
4,843
448
83
9
1
3,384
255
833
67
1
1
1970-01-01T00:27:24
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,499
quarkusio/quarkus/23664/23661
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23661
https://github.com/quarkusio/quarkus/pull/23664
https://github.com/quarkusio/quarkus/pull/23664
1
fixes
Micrometer JSON registry uses a non-blocking route
### Describe the bug ... so if there are gauges which require a blocking operation to get the value, then the call to `/metrics` fails ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? Use `quarkus.micrometer.export.json.enabled=true` and register a gauge that requires a blocking operation to retrieve the value, and then request a JSON export from `/metrics` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information see discussion https://github.com/quarkusio/quarkus/discussions/23605
8d8a13d51626ab499f5f881bf6716519f9a45941
30ccd52ec0643726340448d7c26f6cb7e54c40a9
https://github.com/quarkusio/quarkus/compare/8d8a13d51626ab499f5f881bf6716519f9a45941...30ccd52ec0643726340448d7c26f6cb7e54c40a9
diff --git a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/export/JsonRegistryProcessor.java b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/export/JsonRegistryProcessor.java index 6b0ce9ad374..d97cf11de29 100644 --- a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/export/JsonRegistryProcessor.java +++ b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/export/JsonRegistryProcessor.java @@ -45,6 +45,7 @@ public void initializeJsonRegistry(MicrometerConfig config, routes.produce(nonApplicationRootPathBuildItem.routeBuilder() .routeFunction(config.export.json.path, recorder.route()) .handler(recorder.getHandler()) + .blockingRoute() .build()); log.debug("Initialized a JSON meter registry on path="
['extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/export/JsonRegistryProcessor.java']
{'.java': 1}
1
1
0
0
1
19,784,461
3,830,369
503,386
4,854
33
5
1
1
837
114
191
39
1
0
1970-01-01T00:27:24
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,480
quarkusio/quarkus/24106/23727
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23727
https://github.com/quarkusio/quarkus/pull/24106
https://github.com/quarkusio/quarkus/pull/24106
1
fixes
Odd class format error
### Describe the bug Only The `LicensedPracticalNurse` class triggers this error at startup while the other classes work fine (removing it fixes the problem). The snippet below is the entire application. ```kotlin @Path("/api/list") class ReactiveGreetingResource { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/lpn") fun lpn() = LicensedPracticalNurse.listAll() @GET @Produces(MediaType.APPLICATION_JSON) @Path("/all") fun all() = NursingStaffMember.listAll() @GET @Produces(MediaType.APPLICATION_JSON) @Path("/rn") fun rn() = RegisteredNurse.listAll() @GET @Produces(MediaType.APPLICATION_JSON) @Path("/cna") fun cna() = CertifiedNursingAssisant.listAll() } enum class JobTitle { CNA, RN , LPN } @MappedSuperclass abstract class AbstractStaffMember : PanacheEntity() { @Column(name = "staff_id") lateinit var staffId: String @Column(name = "first_name") lateinit var firstName: String @Column(name = "last_name") lateinit var lastName: String @Column(name = "full_name") lateinit var fullName: String @Enumerated(EnumType.STRING) @Column(name = "job_title") lateinit var jobTitle: JobTitle } @Entity @Table(name = "LICENSED_PRACTICAL_NURSE") class LicensedPracticalNurse : AbstractStaffMember() { companion object : PanacheCompanion<LicensedPracticalNurse> } @Entity @Table(name = "REGISTERED_NURSE") class RegisteredNurse : AbstractStaffMember() { companion object : PanacheCompanion<RegisteredNurse> } @Entity @Table(name = "CERTIFIED_NURSING_ASSISTANT") class CertifiedNursingAssisant : AbstractStaffMember() { companion object : PanacheCompanion<CertifiedNursingAssisant> } ``` ### Expected behavior _No response_ ### Actual behavior ```posh 2022-02-15 09:01:57,346 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.ExceptionInInitializerError at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) at java.base/java.lang.Class.newInstance(Class.java:645) at io.quarkus.runtime.Quarkus.run(Quarkus.java:66) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runtime.Quarkus.run(Quarkus.java:120) at io.quarkus.runner.GeneratedMain.main(Unknown Source) ... 6 more Caused by: java.lang.RuntimeException: Failed to start quarkus at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source) ... 17 more Caused by: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion" at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:454) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:414) at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297) at java.base/java.lang.Class.getDeclaredFields(Class.java:2371) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredFieldProperties(JavaXClass.java:84) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:113) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:108) at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:258) at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:771) at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282) at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:354) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40) at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:69) at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:70) at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy_0(Unknown Source) at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy(Unknown Source) ... 18 more 2022-02-15 09:01:57,376 INFO [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final 2022-02-15 09:01:57,425 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion" at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51) at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122) at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:144) at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:455) at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:66) at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150) at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106) at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132) at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62) Caused by: java.lang.ClassFormatError: Field "this" in class LicensedPracticalNurse$Companion has illegal signature "LicensedPracticalNurse$Companion" at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:454) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:414) at java.base/java.lang.Class.getDeclaredFields0(Native Method) at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297) at java.base/java.lang.Class.getDeclaredFields(Class.java:2371) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredFieldProperties(JavaXClass.java:84) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:113) at org.hibernate.annotations.common.reflection.java.JavaXClass.getDeclaredProperties(JavaXClass.java:108) at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:258) at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:211) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:771) at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282) at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:354) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73) at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40) at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:69) at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:70) at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy_0(Unknown Source) at io.quarkus.deployment.steps.ArcProcessor$generateResources686947423.deploy(Unknown Source) at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) at java.base/java.lang.Class.newInstance(Class.java:645) at io.quarkus.runtime.Quarkus.run(Quarkus.java:66) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runtime.Quarkus.run(Quarkus.java:120) at io.quarkus.runner.GeneratedMain.main(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103) at java.base/java.lang.Thread.run(Thread.java:833) ``` ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` Darwin Kernel Version 21.3. ### Output of `java -version` openjdk version "17.0.2" 2022-01-18 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 ### Additional information _No response_
8cdad730bd93c5e912b6f657336319f78b07f330
b7ba58b7f05a44d3702c6be5cbb6fc604bbbd597
https://github.com/quarkusio/quarkus/compare/8cdad730bd93c5e912b6f657336319f78b07f330...b7ba58b7f05a44d3702c6be5cbb6fc604bbbd597
diff --git a/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java b/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java index c2f035b45ae..038f51ee624 100644 --- a/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java +++ b/extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java @@ -237,8 +237,7 @@ private void collectMethods(ClassInfo classInfo) { private String desc(String name) { String s = name.replace(".", "/"); - s = s.startsWith("L") || s.startsWith("[") ? s : "L" + s + ";"; - return s; + return s.startsWith("[") ? s : "L" + s + ";"; } private void descriptors(MethodInfo method, StringJoiner joiner) {
['extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/visitors/KotlinPanacheClassOperationGenerationVisitor.java']
{'.java': 1}
1
1
0
0
1
19,993,493
3,869,169
508,243
4,885
146
45
3
1
12,328
517
2,742
210
0
2
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,479
quarkusio/quarkus/24142/24008
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/24008
https://github.com/quarkusio/quarkus/pull/24142
https://github.com/quarkusio/quarkus/pull/24142
1
fix
Apicurio Registry DevService cannot be used by multiple Quarkus services
### Describe the bug Currently I'm trying to connect two simple Quarkus services using the default DevServices as Kafka broker and schema registry. According to the logs both services can successfully find the DevServices, which are automatically started by Quarkus. However, by trying to send a first message into the configured topic the following error occurs: ``` ERROR [io.sma.rea.mes.kafka] (smallrye-kafka-producer-thread-0) SRMSG18260: Unable to recover from the serialization failure (topic: movies), configure a SerializationFailureHandler to recover from errors.: io.vertx.core.VertxException: Invalid url: localhost:64263/apis/registry/v2/groups/default/artifacts?ifExists=RETURN_OR_UPDATE&canonical=false at io.vertx.core.http.RequestOptions.parseUrl(RequestOptions.java:357) at io.vertx.core.http.RequestOptions.setAbsoluteURI(RequestOptions.java:370) at io.apicurio.rest.client.VertxHttpClient.sendRequest(VertxHttpClient.java:74) at io.apicurio.registry.rest.client.impl.RegistryClientImpl.createArtifact(RegistryClientImpl.java:236) at io.apicurio.registry.rest.client.RegistryClient.createArtifact(RegistryClient.java:139) at io.apicurio.registry.serde.DefaultSchemaResolver.lambda$handleAutoCreateArtifact$2(DefaultSchemaResolver.java:174) at io.apicurio.registry.serde.ERCache.lambda$getValue$0(ERCache.java:132) at io.apicurio.registry.serde.ERCache.retry(ERCache.java:171) at io.apicurio.registry.serde.ERCache.getValue(ERCache.java:131) at io.apicurio.registry.serde.ERCache.getByContent(ERCache.java:116) at io.apicurio.registry.serde.DefaultSchemaResolver.handleAutoCreateArtifact(DefaultSchemaResolver.java:172) at io.apicurio.registry.serde.DefaultSchemaResolver.resolveSchema(DefaultSchemaResolver.java:82) at io.apicurio.registry.serde.AbstractKafkaSerializer.serialize(AbstractKafkaSerializer.java:92) at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.lambda$serialize$1(SerializerWrapper.java:56) at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.wrapSerialize(SerializerWrapper.java:81) at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.serialize(SerializerWrapper.java:56) at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:945) at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:905) at io.smallrye.reactive.messaging.kafka.impl.ReactiveKafkaProducer.lambda$send$3(ReactiveKafkaProducer.java:111) at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21) at io.smallrye.mutiny.operators.uni.builders.UniCreateWithEmitter.subscribe(UniCreateWithEmitter.java:22) at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36) at io.smallrye.mutiny.operators.uni.UniRunSubscribeOn.lambda$subscribe$0(UniRunSubscribeOn.java:27) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.net.MalformedURLException: unknown protocol: localhost at java.base/java.net.URL.<init>(URL.java:652) at java.base/java.net.URL.<init>(URL.java:541) at java.base/java.net.URL.<init>(URL.java:488) at io.vertx.core.http.RequestOptions.parseUrl(RequestOptions.java:355) ... 25 more ``` This error only occurs on the Quarkus service (consumer or producer), which connects to an already existing Apicurio Registry started as Devservice. ### Expected behavior Multiple Quarkus Services in Dev mode can connect to an existing Apicurio Registry DevService automatically started by one of them ### Actual behavior The configured URL to an Apicurio Registry DevService contains no protocol for those services, which try to connect an existing instance of the DevService ### How to Reproduce? Using following consumer and producer services: https://github.com/sombraglez/quarkus-kafka-avro-schema-consumer https://github.com/sombraglez/quarkus-kafka-avro-schema-producer 1. Start consumer `quarkus-kafka-avro-schema-consumer` in Dev mode `mvn quarkus:dev` 2. Start producer `quarkus-kafka-avro-schema-producer` in Dev mode `mvn quarkus:dev` 3. Access consumer REST-EndPoint `http://localhost:8081/consumed-movies` 4. Produce a message via POST at `http://localhost:8080/movies` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` openjdk 11.0.14 2022-01-18 LTS ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.2 ### Additional information _No response_
f8b96e930afa8985fab62c18d7c91f67d8059eab
cf8fe1d2687b306424b3f4a03ced41a977544ef2
https://github.com/quarkusio/quarkus/compare/f8b96e930afa8985fab62c18d7c91f67d8059eab...cf8fe1d2687b306424b3f4a03ced41a977544ef2
diff --git a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/DevServicesApicurioRegistryProcessor.java b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/DevServicesApicurioRegistryProcessor.java index f5401c50c39..7456b684a2e 100644 --- a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/DevServicesApicurioRegistryProcessor.java +++ b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/DevServicesApicurioRegistryProcessor.java @@ -158,8 +158,10 @@ private RunningDevService startApicurioRegistry(ApicurioRegistryDevServiceCfg co // Starting the broker return apicurioRegistryContainerLocator.locateContainer(config.serviceName, config.shared, launchMode.getLaunchMode()) - .map(containerAddress -> new RunningDevService(Feature.APICURIO_REGISTRY_AVRO.getName(), - containerAddress.getId(), null, REGISTRY_URL_CONFIG, getRegistryUrlConfig(containerAddress.getUrl()))) + .map(address -> new RunningDevService(Feature.APICURIO_REGISTRY_AVRO.getName(), + address.getId(), null, REGISTRY_URL_CONFIG, + // address does not have the URL Scheme - just the host:port, so prepend http:// + getRegistryUrlConfig("http://" + address.getUrl()))) .orElseGet(() -> { ApicurioRegistryContainer container = new ApicurioRegistryContainer( DockerImageName.parse(config.imageName), config.fixedExposedPort,
['extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/DevServicesApicurioRegistryProcessor.java']
{'.java': 1}
1
1
0
0
1
19,993,457
3,869,158
508,242
4,885
583
106
6
1
4,990
319
1,186
88
4
1
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,157
quarkusio/quarkus/34024/33993
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/33993
https://github.com/quarkusio/quarkus/pull/34024
https://github.com/quarkusio/quarkus/pull/34024
1
fixes
Quarkus startup hangs in OidcRecorder
### Describe the bug In some context (I'm still figuring out when) the server startup hangs indefinitely in OidcRecorder.java L143. It's only happening in production unfortunately. I managed to get this jstack: ``` "main" #1 prio=5 os_prio=0 cpu=2263.87ms elapsed=692.56s tid=0x00007f5c40024ec0 nid=0x3f waiting on condition [0x00007f5c472d1000] java.lang.Thread.State: WAITING (parking) at jdk.internal.misc.Unsafe.park(java.base@17.0.7/Native Method) - parking to wait for <0x00000000f14a1d18> (a java.util.concurrent.CountDownLatch$Sync) at java.util.concurrent.locks.LockSupport.park(java.base@17.0.7/LockSupport.java:211) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@17.0.7/AbstractQueuedSynchronizer.java:715) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(java.base@17.0.7/AbstractQueuedSynchronizer.java:1047) at java.util.concurrent.CountDownLatch.await(java.base@17.0.7/CountDownLatch.java:230) at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:67) at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65) at io.smallrye.mutiny.groups.UniAwait.indefinitely(UniAwait.java:46) at io.quarkus.oidc.runtime.OidcRecorder.createStaticTenantContext(OidcRecorder.java:143) at io.quarkus.oidc.runtime.OidcRecorder.setup(OidcRecorder.java:64) at io.quarkus.deployment.steps.OidcBuildStep$setup635434700.deploy_0(Unknown Source) at io.quarkus.deployment.steps.OidcBuildStep$setup635434700.deploy(Unknown Source) at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) at io.quarkus.runtime.Application.start(Application.java:101) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111) at io.quarkus.runtime.Quarkus.run(Quarkus.java:71) at io.quarkus.runtime.Quarkus.run(Quarkus.java:44) at io.quarkus.runtime.Quarkus.run(Quarkus.java:124) at io.quarkus.runner.GeneratedMain.main(Unknown Source) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@17.0.7/Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@17.0.7/NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@17.0.7/DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(java.base@17.0.7/Method.java:568) at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:61) at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:32) ``` I think there should be a log at least, possibly a timeout or even this should be deferred to later to avoid a network call on startup. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 3.1.0 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
5c2df5112331ef170c0b0ad83c84c6f853c2d5d6
61805454010a39fabcdf9e3e7fe3be019951da98
https://github.com/quarkusio/quarkus/compare/5c2df5112331ef170c0b0ad83c84c6f853c2d5d6...61805454010a39fabcdf9e3e7fe3be019951da98
diff --git a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java index 4d3015c4363..4915d298d23 100644 --- a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java +++ b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java @@ -87,7 +87,7 @@ public OidcClients get() { protected static OidcClient createOidcClient(OidcClientConfig oidcConfig, String oidcClientId, TlsConfig tlsConfig, Supplier<Vertx> vertx) { - return createOidcClientUni(oidcConfig, oidcClientId, tlsConfig, vertx).await().indefinitely(); + return createOidcClientUni(oidcConfig, oidcClientId, tlsConfig, vertx).await().atMost(oidcConfig.connectionTimeout); } protected static Uni<OidcClient> createOidcClientUni(OidcClientConfig oidcConfig, String oidcClientId, diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java index 3f10ffc72b0..1a77ace20ff 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java @@ -140,7 +140,7 @@ public TenantConfigContext apply(Throwable t) { throw new OIDCException(t); } }) - .await().indefinitely(); + .await().atMost(oidcConfig.getConnectionTimeout()); } private static Throwable logTenantConfigContextFailure(Throwable t, String tenantId) {
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java', 'extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientRecorder.java']
{'.java': 2}
2
2
0
0
2
26,855,520
5,297,179
682,001
6,289
339
84
4
2
3,295
205
866
71
0
1
1970-01-01T00:28:06
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,158
quarkusio/quarkus/34020/34005
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/34005
https://github.com/quarkusio/quarkus/pull/34020
https://github.com/quarkusio/quarkus/pull/34020
1
fixes
Panache tries to (and fails to) transform classes even if disabled
### Describe the bug Panache seems to perform some class transformations regardless of whether Panache is enabled, leading to exceptions when running tests. ### Expected behavior Panache should not try to do anything if Panache is disabled. ### Actual behavior ``` [error]: Build step io.quarkus.deployment.steps.ClassTransformingBuildStep#handleClassTransformation threw an exception: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Could not find indexed method: Lorg/acme/Person;.updateFirstnameStatic_orig with descriptor (Ljava/lang/String;)V and arg types [java.lang.String] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:918) at io.quarkus.builder.BuildContext.run(BuildContext.java:281) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Could not find indexed method: Lorg/acme/Person;.updateFirstnameStatic_orig with descriptor (Ljava/lang/String;)V and arg types [java.lang.String] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at io.quarkus.deployment.steps.ClassTransformingBuildStep.handleClassTransformation(ClassTransformingBuildStep.java:267) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909) ... 6 more Caused by: java.lang.IllegalStateException: Could not find indexed method: Lorg/acme/Person;.updateFirstnameStatic_orig with descriptor (Ljava/lang/String;)V and arg types [java.lang.String] at io.quarkus.panache.common.deployment.visitors.PanacheEntityClassOperationGenerationVisitor.visitMethod(PanacheEntityClassOperationGenerationVisitor.java:99) at org.objectweb.asm.ClassVisitor.visitMethod(ClassVisitor.java:384) at io.quarkus.arc.deployment.staticmethods.InterceptedStaticMethodsProcessor$InterceptedStaticMethodsClassVisitor.visitMethod(InterceptedStaticMethodsProcessor.java:449) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1353) at org.objectweb.asm.ClassReader.accept(ClassReader.java:744) at org.objectweb.asm.ClassReader.accept(ClassReader.java:424) at io.quarkus.deployment.steps.ClassTransformingBuildStep.transformClass(ClassTransformingBuildStep.java:361) at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:232) at io.quarkus.deployment.steps.ClassTransformingBuildStep$2.call(ClassTransformingBuildStep.java:219) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ... 5 more ``` ### How to Reproduce? 1. Clone https://github.com/yrodiere/quarkus-resteasy-postgres/tree/panache-hibernate-disabled 2. Run `mvn clean verify` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
210b2a332e855aee3a73f71f7cdb7d10a3467c6f
0a6d90945ef528d30dbe0800f28b08c81f87d347
https://github.com/quarkusio/quarkus/compare/210b2a332e855aee3a73f71f7cdb7d10a3467c6f...0a6d90945ef528d30dbe0800f28b08c81f87d347
diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java index 7edb7fcddba..82ff8080397 100644 --- a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java +++ b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java @@ -21,6 +21,7 @@ import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.deployment.ValidationPhaseBuildItem; +import io.quarkus.arc.deployment.staticmethods.InterceptedStaticMethodsTransformersRegisteredBuildItem; import io.quarkus.builder.BuildException; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -92,6 +93,7 @@ void collectEntityClasses(CombinedIndexBuildItem index, BuildProducer<PanacheEnt @BuildStep @Consume(HibernateEnhancersRegisteredBuildItem.class) + @Consume(InterceptedStaticMethodsTransformersRegisteredBuildItem.class) void build( CombinedIndexBuildItem index, BuildProducer<BytecodeTransformerBuildItem> transformers, diff --git a/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java b/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java index 194f123bf06..68a4e402578 100644 --- a/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java +++ b/extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java @@ -18,6 +18,7 @@ import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.deployment.ValidationPhaseBuildItem; +import io.quarkus.arc.deployment.staticmethods.InterceptedStaticMethodsTransformersRegisteredBuildItem; import io.quarkus.builder.BuildException; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -90,6 +91,7 @@ void collectEntityClasses(CombinedIndexBuildItem index, BuildProducer<PanacheEnt @BuildStep @Consume(HibernateEnhancersRegisteredBuildItem.class) + @Consume(InterceptedStaticMethodsTransformersRegisteredBuildItem.class) void build(CombinedIndexBuildItem index, BuildProducer<BytecodeTransformerBuildItem> transformers, List<PanacheEntityClassBuildItem> entityClasses, diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java index 199f8fae507..f99d26b3418 100644 --- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java +++ b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java @@ -30,11 +30,13 @@ import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.deployment.ValidationPhaseBuildItem; +import io.quarkus.arc.deployment.staticmethods.InterceptedStaticMethodsTransformersRegisteredBuildItem; import io.quarkus.bootstrap.classloading.ClassPathElement; import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.builder.BuildException; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.Consume; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.bean.JavaBeanUtil; @@ -76,6 +78,7 @@ public abstract class BasePanacheMongoResourceProcessor { public static final String BSON_PACKAGE = "org.bson."; @BuildStep + @Consume(InterceptedStaticMethodsTransformersRegisteredBuildItem.class) public void buildImperative(CombinedIndexBuildItem index, BuildProducer<BytecodeTransformerBuildItem> transformers, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, @@ -94,6 +97,7 @@ public void buildImperative(CombinedIndexBuildItem index, } @BuildStep + @Consume(InterceptedStaticMethodsTransformersRegisteredBuildItem.class) public void buildReactive(CombinedIndexBuildItem index, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, diff --git a/extensions/panache/panache-hibernate-common/deployment/src/main/java/io/quarkus/panache/common/deployment/PanacheHibernateCommonResourceProcessor.java b/extensions/panache/panache-hibernate-common/deployment/src/main/java/io/quarkus/panache/common/deployment/PanacheHibernateCommonResourceProcessor.java index 82cf77985d5..656c2c1e3a8 100644 --- a/extensions/panache/panache-hibernate-common/deployment/src/main/java/io/quarkus/panache/common/deployment/PanacheHibernateCommonResourceProcessor.java +++ b/extensions/panache/panache-hibernate-common/deployment/src/main/java/io/quarkus/panache/common/deployment/PanacheHibernateCommonResourceProcessor.java @@ -14,6 +14,7 @@ import org.jboss.jandex.DotName; import org.jboss.jandex.FieldInfo; +import io.quarkus.arc.deployment.staticmethods.InterceptedStaticMethodsTransformersRegisteredBuildItem; import io.quarkus.bootstrap.classloading.ClassPathElement; import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.deployment.annotations.BuildProducer; @@ -81,6 +82,7 @@ void findEntityClasses(CombinedIndexBuildItem index, @BuildStep @Consume(HibernateEnhancersRegisteredBuildItem.class) + @Consume(InterceptedStaticMethodsTransformersRegisteredBuildItem.class) void replaceFieldAccesses(CombinedIndexBuildItem index, ApplicationArchivesBuildItem applicationArchivesBuildItem, Optional<HibernateMetamodelForFieldAccessBuildItem> modelInfoBuildItem,
['extensions/panache/panache-hibernate-common/deployment/src/main/java/io/quarkus/panache/common/deployment/PanacheHibernateCommonResourceProcessor.java', 'extensions/panache/hibernate-reactive-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/panache/common/deployment/PanacheHibernateResourceProcessor.java', 'extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheHibernateResourceProcessor.java', 'extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java']
{'.java': 4}
4
4
0
0
4
26,855,520
5,297,179
682,001
6,289
852
180
10
4
4,022
218
883
72
1
1
1970-01-01T00:28:06
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,159
quarkusio/quarkus/33971/33961
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/33961
https://github.com/quarkusio/quarkus/pull/33971
https://github.com/quarkusio/quarkus/pull/33971
1
fixes
:dev terminal test commands don't work anymore (testSupport.include is null)
### Describe the bug When invoking the terminal (`:`) while in `:dev` mode, the options to set the `test pattern` for includes and excludes don't seem to work (anymore). Maybe I'm missing something but I don't seem to be able to include and exclude patterns once the dev mode has been started. Example: ``` : $ test pattern exclude .*UITest java.lang.NullPointerException: Cannot invoke "java.util.regex.Pattern.pattern()" because "testSupport.include" is null ``` If I look into the source code of `io.quarkus.deployment.dev.testing.TestSupport`, then indeed `include` and `exclude` are `null`. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? 1. Have a project with different test naming strategies (e.g. `...Test`, `...UITest`, `...APITest`). 2. Run `mvn quarkus:dev` 3. Start the terminal (`:`) 4. Try to set the exclude and include patterns (maybe multiple times) ### Output of `uname -a` or `ver` Linux squarelinux 6.1.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 18 Jan 2023 19:54:38 +0000 x86_64 GNU/Linux ### Output of `java -version` OpenJDK Runtime Environment Temurin-18.0.1+10 (build 18.0.1+10) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 3.1.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 ### Additional information _No response_
35e0f9c21c1e0a7f994d5b4fd590280a23693600
7206ac0ba8156f5e0f23642457b4999bc6e5c586
https://github.com/quarkusio/quarkus/compare/35e0f9c21c1e0a7f994d5b4fd590280a23693600...7206ac0ba8156f5e0f23642457b4999bc6e5c586
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java index d72622e78dc..8ff20a9bcf9 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java @@ -298,7 +298,7 @@ protected String configKey() { @Override protected void configure(TestSupport testSupport) { - testSupport.setPatterns(pattern, testSupport.exclude.pattern()); + testSupport.setPatterns(pattern, testSupport.exclude != null ? testSupport.exclude.pattern() : null); } } @@ -320,7 +320,7 @@ protected String configKey() { @Override protected void configure(TestSupport testSupport) { - testSupport.setPatterns(testSupport.include.pattern(), pattern); + testSupport.setPatterns(testSupport.include != null ? testSupport.include.pattern() : null, pattern); } }
['core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestTracingProcessor.java']
{'.java': 1}
1
1
0
0
1
26,830,597
5,292,355
681,383
6,279
385
66
4
1
1,416
200
389
55
0
1
1970-01-01T00:28:06
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,533
quarkusio/quarkus/22816/20492
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/20492
https://github.com/quarkusio/quarkus/pull/22816
https://github.com/quarkusio/quarkus/pull/22816
1
fixes
Class PostgreSQL10Dialect not found on Quarkus in Google App Engine java11?
### Describe the bug I wanted to deploy my quarkus application including hibernate panache to GCP app engine standard and got the error: Class PostgreSQL10Dialect not found on Quarkus ### Expected behavior Successful startup of quarkus on GCP app engine standard ### Actual behavior I've set up my quarkus application regarding to https://quarkus.io/guides/deploying-to-google-cloud Created a Cloud SQL instance. And happily deployed the java11 app the first time to GAE. :-) But - on startup quarkus fails with this reason: ``` Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.PostgreSQL10Dialect at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:398) at io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService.classForName(FlatClassLoaderService.java:36) ``` Looking at the jar: ``` $ jar tvf foodie-1.0-SNAPSHOT-runner.jar | fgrep PostgreSQL10Dialect 1184 Tue Sep 28 20:12:07 CEST 2021 io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL10Dialect.class 990 Tue Sep 28 20:12:08 CEST 2021 org/hibernate/dialect/PostgreSQL10Dialect.class ``` Any hints how to proceed? application.properties: ``` quarkus.package.type=uber-jar quarkus.datasource.db-kind=other %dev.quarkus.datasource.jdbc.url=jdbc:postgresql:///quarkus quarkus.datasource.jdbc.url=jdbc:postgresql:///quarkus quarkus.datasource.jdbc.driver=org.postgresql.Driver quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=addlogic-foodiefnf-1:europe-west3:quarkus quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.postgres.SocketFactory quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect ``` Extract from pom.xml: ``` <maven.compiler.target>11</maven.compiler.target> <quarkus-plugin.version>2.2.3.Final</quarkus-plugin.version> <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> <quarkus.platform.version>2.2.3.Final</quarkus.platform.version> <postgres-socket-factory.version>1.3.3</postgres-socket-factory.version> [...] <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-postgresql</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-hibernate-orm-panache</artifactId> </dependency> <dependency> <groupId>com.google.cloud.sql</groupId> <artifactId>postgres-socket-factory</artifactId> <version>${postgres-socket-factory.version}</version> </dependency> ``` Sidenote on deployment? ---------------------------- How to investigate this warning on ´mvn clean package appengine:deploy´? ``` [INFO] Staging the application to: D:\\eclipse\\eclipse-workspace\\code-with-quarkus\\target\\appengine-staging [INFO] Detected App Engine app.yaml based application. Okt. 01, 2021 8:08:38 AM com.google.cloud.tools.appengine.operations.AppYamlProjectStaging copyArtifactJarClasspath WARNING: Could not copy 'Class-Path' jar: D:\\eclipse\\eclipse-workspace\\code-with-quarkus\\target referenced in MANIFEST.MF ``` Just a sidenote as deployment with `gcloud app deploy target/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar` gives no WARNINFS and has same effects. Alternative with mysql is functioning ===================================== I've tried an alternative with mysql, which is functioning in the same MCVE and another testing project which I have set up. pom.xml ``` <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-mysql</artifactId> </dependency> <dependency> <groupId>com.google.cloud.sql</groupId> <artifactId>mysql-socket-factory-connector-j-8</artifactId> <version>1.3.3</version> </dependency> ``` application.properties ``` # https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/blob/main/docs/jdbc-mysql.md quarkus.datasource.db-kind=other quarkus.datasource.jdbc.url=jdbc:mysql:///quarkus quarkus.datasource.jdbc.driver=com.mysql.cj.jdbc.Driver quarkus.datasource.username=root quarkus.datasource.password=quarkus quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=addlogic-foodiefnf-1:europe-west3:quarkusmysql quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.mysql.SocketFactory quarkus.hibernate-orm.dialect=org.hibernate.dialect.MySQL8Dialect ``` ***So this makes me more curious why it is not working with PostgreSQL.*** ### How to Reproduce? An MCVE reproducer project can be found at `git@gitlab.com:addlogic/code-with-quarkus.git#` See README for reproduction steps. ### Output of `uname -a` or `ver` CYGWIN_NT-10.0 levante2b 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin ### Output of `java -version` $ java -version java version "11.0.11" 2021-04-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.2.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) apache-maven-3.8.1 ### Additional information _No response_
376d631081852877d8781a20b4666e8220057360
bfabc1c06609c99115cb4dc78a73c96c6f3c2df9
https://github.com/quarkusio/quarkus/compare/376d631081852877d8781a20b4666e8220057360...bfabc1c06609c99115cb4dc78a73c96c6f3c2df9
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java index 33e03cd274b..cd1436fca8e 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java @@ -19,10 +19,20 @@ public class CharsetConverter implements Converter<Charset>, Serializable { @Override public Charset convert(String value) { + if (value == null) { + return null; + } + + String trimmedCharset = value.trim(); + + if (trimmedCharset.isEmpty()) { + return null; + } + try { - return Charset.forName(value); + return Charset.forName(trimmedCharset); } catch (Exception e) { - throw new IllegalArgumentException("Unable to create Charset from: '" + value + "'", e); + throw new IllegalArgumentException("Unable to create Charset from: '" + trimmedCharset + "'", e); } } } diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/TrimmedStringConverter.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/TrimmedStringConverter.java index 4588db6b50e..f0f8eabbedf 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/TrimmedStringConverter.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/TrimmedStringConverter.java @@ -10,8 +10,15 @@ public TrimmedStringConverter() { @Override public String convert(String s) { if (s == null) { - return s; + return null; } - return s.trim(); + + String trimmedString = s.trim(); + + if (trimmedString.isEmpty()) { + return null; + } + + return trimmedString; } } diff --git a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcBuildTimeConfig.java b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcBuildTimeConfig.java index 2b9c324b2a2..6d5e3877ac7 100644 --- a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcBuildTimeConfig.java +++ b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcBuildTimeConfig.java @@ -4,6 +4,8 @@ import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; +import io.quarkus.runtime.configuration.TrimmedStringConverter; @ConfigGroup public class DataSourceJdbcBuildTimeConfig { @@ -18,6 +20,7 @@ public class DataSourceJdbcBuildTimeConfig { * The datasource driver class name */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> driver = Optional.empty(); /** diff --git a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourceRuntimeConfig.java b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourceRuntimeConfig.java index 82c9f351e8c..d22a84034e5 100644 --- a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourceRuntimeConfig.java +++ b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourceRuntimeConfig.java @@ -4,6 +4,8 @@ import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; +import io.quarkus.runtime.configuration.TrimmedStringConverter; @ConfigGroup public class DataSourceRuntimeConfig { @@ -24,6 +26,7 @@ public class DataSourceRuntimeConfig { * The credentials provider name */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> credentialsProvider = Optional.empty(); /** @@ -35,5 +38,6 @@ public class DataSourceRuntimeConfig { * For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> credentialsProviderName = Optional.empty(); } diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java index b7e4ad913de..c0018f9e2ab 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java @@ -14,6 +14,8 @@ import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; +import io.quarkus.runtime.configuration.TrimmedStringConverter; @ConfigGroup public class HibernateOrmConfigPersistenceUnit { @@ -23,11 +25,13 @@ public class HibernateOrmConfigPersistenceUnit { * <p> * If undefined, it will use the default datasource. */ + @ConvertWith(TrimmedStringConverter.class) public Optional<String> datasource; /** * The packages in which the entities affected to this persistence unit are located. */ + @ConvertWith(TrimmedStringConverter.class) public Optional<Set<String>> packages; /** @@ -71,6 +75,7 @@ public class HibernateOrmConfigPersistenceUnit { */ // @formatter:on @ConfigItem(defaultValueDocumentation = "import.sql in DEV, TEST ; no-file otherwise") + @ConvertWith(TrimmedStringConverter.class) public Optional<List<String>> sqlLoadScript; /** @@ -103,6 +108,7 @@ public class HibernateOrmConfigPersistenceUnit { * Class name of the Hibernate PhysicalNamingStrategy implementation */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> physicalNamingStrategy; /** @@ -111,6 +117,7 @@ public class HibernateOrmConfigPersistenceUnit { * Class name of the Hibernate ImplicitNamingStrategy implementation */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> implicitNamingStrategy; /** @@ -130,6 +137,7 @@ public class HibernateOrmConfigPersistenceUnit { * @asciidoclet */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> metadataBuilderContributor; /** @@ -139,6 +147,7 @@ public class HibernateOrmConfigPersistenceUnit { * Pass `no-file` to force Hibernate ORM to ignore `META-INF/orm.xml`. */ @ConfigItem(defaultValueDocumentation = "META-INF/orm.xml if it exists; no-file otherwise") + @ConvertWith(TrimmedStringConverter.class) public Optional<Set<String>> mappingFiles; /** @@ -201,6 +210,7 @@ public class HibernateOrmConfigPersistenceUnit { * @asciidoclet */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> multitenant; /** @@ -208,6 +218,7 @@ public class HibernateOrmConfigPersistenceUnit { * if not set. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> multitenantSchemaDatasource; /** @@ -259,6 +270,7 @@ public static class HibernateOrmConfigPersistenceUnitDialect { // TODO should it be dialects //TODO should it be shortcuts like "postgresql" "h2" etc @ConfigItem(name = ConfigItem.PARENT) + @ConvertWith(TrimmedStringConverter.class) public Optional<String> dialect; /** @@ -269,6 +281,7 @@ public static class HibernateOrmConfigPersistenceUnitDialect { * @asciidoclet */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> storageEngine; public boolean isAnyPropertySet() { @@ -342,6 +355,7 @@ public static class HibernateOrmConfigPersistenceUnitJdbc { * The time zone pushed to the JDBC driver. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> timezone; /** diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java index b3676ba8270..98bb49330d9 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java @@ -5,6 +5,8 @@ import io.quarkus.runtime.annotations.ConfigDocSection; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConvertWith; +import io.quarkus.runtime.configuration.TrimmedStringConverter; @ConfigGroup public class HibernateOrmRuntimeConfigPersistenceUnit { @@ -49,12 +51,14 @@ public static class HibernateOrmConfigPersistenceUnitDatabase { * The default catalog to use for the database objects. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> defaultCatalog; /** * The default schema to use for the database objects. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> defaultSchema; public boolean isAnyPropertySet() { @@ -92,6 +96,7 @@ public static class HibernateOrmConfigPersistenceUnitDatabaseGeneration { * Accepted values: `none`, `create`, `drop-and-create`, `drop`, `update`, `validate`. */ @ConfigItem(name = ConfigItem.PARENT, defaultValue = "none") + @ConvertWith(TrimmedStringConverter.class) public String generation = "none"; /** @@ -122,18 +127,21 @@ public static class HibernateOrmConfigPersistenceUnitScriptGeneration { * Accepted values: `none`, `create`, `drop-and-create`, `drop`, `update`, `validate`. */ @ConfigItem(name = ConfigItem.PARENT, defaultValue = "none") + @ConvertWith(TrimmedStringConverter.class) public String generation = "none"; /** * Filename or URL where the database create DDL file should be generated. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> createTarget = Optional.empty(); /** * Filename or URL where the database drop DDL file should be generated. */ @ConfigItem + @ConvertWith(TrimmedStringConverter.class) public Optional<String> dropTarget = Optional.empty(); public boolean isAnyPropertySet() {
['extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DataSourceRuntimeConfig.java', 'core/runtime/src/main/java/io/quarkus/runtime/configuration/TrimmedStringConverter.java', 'extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/HibernateOrmRuntimeConfigPersistenceUnit.java', 'core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java', 'extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java', 'extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcBuildTimeConfig.java']
{'.java': 6}
6
6
0
0
6
19,187,854
3,716,799
489,203
4,748
2,245
446
54
6
5,610
392
1,528
147
2
7
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,534
quarkusio/quarkus/22809/22792
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22792
https://github.com/quarkusio/quarkus/pull/22809
https://github.com/quarkusio/quarkus/pull/22809
1
fixes
Continuous testing fails when `@QuarkusMainTest` and a `@ConfigMapping` are involved
### Describe the bug Running a test annotated with `@QuarkusMainTest` in continuous testing mode where another test tests a config mapping defined by `@ConfigMapping` causes the test to fail with a `ClassCastException`: ``` Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253) at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) ``` It is important that the test testing the `@ConfigMapping` is run before the `@QuarkusMainTest`. The other way round the behavior couldn't be observed. The tests pass when run with `./mvnw clean verify` ### Expected behavior Tests passing when run with `./mvnw clean verify` also pass when run in continuous testing mode. ### Actual behavior When a test using an injected `@ConfigMapping` is run before a `@QuarkusMainTest` the `@QuarkusMainTest` fails with a class cast exception: ``` Caused by: java.lang.ClassCastException: class io.quarkus.test.junit.RunningAppConfigResolver$1 cannot be cast to class io.smallrye.config.SmallRyeConfig (io.quarkus.test.junit.RunningAppConfigResolver$1 and io.smallrye.config.SmallRyeConfig are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6c85b253) at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:241) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:887) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) ``` ### How to Reproduce? 1. Download the demo at tag [QuarkusMainTestFailWithConfigMapping](https://github.com/itbh-at/quarkus-main-test/releases/tag/QuarkusMainTestFailWithConfigMapping) 2. Run `quarkus dev` 3. Start tests -> fail 4. Remove the `@QuarkusMainTest` -> pass 5. Add again the `@QuarkusMainTest` and remove `ConfigurationTest` -> pass 6. Add `ConfigurationTest` again 7. Rename `ConfigurationTest.java` to `GreetingConfigurationTest.java` to ensure it is run after the `@QuarkusMainTest` in `GreetingCommandTest.java` 8. Run the test in `quarkus dev` -> fail, but not because of the `ClassCastException` but because of what is described in #22790 8. Make sure the app looks the same as after the download and exit `quarkus dev` 9. Run `./mvnw clean verify` -> pass ### Output of `uname -a` or `ver` Darwin cdh 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64 ### Output of `java -version` java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.6.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: ~/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1 Java version: 17, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home Default locale: de_AT, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "aarch64", family: "mac" ### Additional information _No response_
d31c534d288497b71f363b4b0f8e22100184fabe
76842aefc2bfd0023fbbc19829d433388ce7201f
https://github.com/quarkusio/quarkus/compare/d31c534d288497b71f363b4b0f8e22100184fabe...76842aefc2bfd0023fbbc19829d433388ce7201f
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java index 0793c514d43..0d5f07a2337 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java @@ -72,7 +72,6 @@ import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; import io.smallrye.config.ConfigSourceFactory; import io.smallrye.config.PropertiesLocationConfigSourceFactory; -import io.smallrye.config.SmallRyeConfig; public class ConfigGenerationBuildStep { @@ -238,7 +237,7 @@ public void setupConfigOverride( public void watchConfigFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> watchedFiles) { List<String> configWatchedFiles = new ArrayList<>(); - SmallRyeConfig config = (SmallRyeConfig) ConfigProvider.getConfig(); + Config config = ConfigProvider.getConfig(); String userDir = System.getProperty("user.dir"); // Main files
['core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java']
{'.java': 1}
1
1
0
0
1
19,185,807
3,716,434
489,156
4,747
173
36
3
1
5,307
417
1,389
85
1
2
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,535
quarkusio/quarkus/22769/22699
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22699
https://github.com/quarkusio/quarkus/pull/22769
https://github.com/quarkusio/quarkus/pull/22769
1
fixes
2.6 - Error with config locations
### Describe the bug I have an `application.yaml` that gets used for all projects (containing things like `ignored-split-packages`). With the `ConfigGenerationBuildStep` changes in 2.6 I now get an exception during builds because of the following lines in my `build.gradle` file. ```groovy build { // Shared Quarkus configuration applied to all projects def shareConfig = rootProject.projectDir.toURI().toString() + "/conf/quarkus" System.setProperty("quarkus.config.locations", "${shareConfig}") } ``` It looks like `ConfigGenerationBuildStep` doesn't seem to like the URI string format (see exception below). I also tried `toAbsolutePath()` instead of `toURI().toString()`, but then it pushed the error to `bstractLocationConfigSourceLoader`, which didn't like the drive letter when in Windows (see exception below). ### Expected behavior Successful build ### Actual behavior Error using `toURI().toString()` ``` Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:/C:/my/git//conf/quarkus at io.quarkus.deployment.steps.ConfigGenerationBuildStep.lambda$watchConfigFiles$0(ConfigGenerationBuildStep.java:259) at io.quarkus.deployment.steps.ConfigGenerationBuildStep.watchConfigFiles(ConfigGenerationBuildStep.java:257) ``` Error using `toAbsolutePath()` ``` Caused by: java.lang.IllegalArgumentException: SRCFG00033: Scheme C not supported at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:101) at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:80) at io.smallrye.config.AbstractLocationConfigSourceFactory.getConfigSources(AbstractLocationConfigSourceFactory.java:30) at io.smallrye.config.PropertiesLocationConfigSourceFactory.getConfigSources(PropertiesLocationConfigSourceFactory.java:16) at io.smallrye.config.ConfigurableConfigSource.unwrap(ConfigurableConfigSource.java:53) at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:49) at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:618) at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:529) at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:66) at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:419) at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:173) at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:108) at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:328) ``` ### How to Reproduce? ```groovy build { // Shared Quarkus configuration applied to all projects def shareConfig = rootProject.projectDir.toURI().toString() + "/conf/quarkus" System.setProperty("quarkus.config.locations", "${shareConfig}") } ``` or ```groovy build { // Shared Quarkus configuration applied to all projects def shareConfig = rootProject.projectDir.getAbsolutePath() + "/conf/quarkus" System.setProperty("quarkus.config.locations", "${shareConfig}") } ``` ### Output of `uname -a` or `ver` MINGW64_NT-10.0-19042 ### Output of `java -version` OpenJDK 11.0.11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.6.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.3.3 ### Additional information _No response_
2e9d5d5bc80c737a3a540d411b71459d106d4052
c1a065c3cc1a52edeec5ac513ac09173510bae74
https://github.com/quarkusio/quarkus/compare/2e9d5d5bc80c737a3a540d411b71459d106d4052...c1a065c3cc1a52edeec5ac513ac09173510bae74
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java index af8f03468ff..0793c514d43 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java @@ -260,8 +260,8 @@ public void watchConfigFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> wa for (URI location : locations) { Path path = location.getScheme() != null ? Paths.get(location) : Paths.get(location.getPath()); if (!Files.isDirectory(path)) { - configWatchedFiles.add(location.toString()); - configWatchedFiles.add(appendProfileToFilename(location.toString(), profile)); + configWatchedFiles.add(path.toString()); + configWatchedFiles.add(appendProfileToFilename(path.toString(), profile)); } } });
['core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java']
{'.java': 1}
1
1
0
0
1
19,161,045
3,711,474
488,409
4,744
323
50
4
1
3,696
265
858
90
0
5
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,537
quarkusio/quarkus/22767/22765
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22765
https://github.com/quarkusio/quarkus/pull/22767
https://github.com/quarkusio/quarkus/pull/22767
1
fixes
Status Code and Message Mismatch in WebApplicationException
### Describe the bug When using the RESTEasy Reactive Client the HTTP status message doesn't match the HTTP status code. ### Expected behavior The HTTP status message is expected to match the status code ### Actual behavior ```java @Test void testWebApplicationException() { assertEquals("HTTP 428 Precondition required", new WebApplicationException(428).getMessage()); // HTTP 428 Expectation Failed // should be: HTTP 428 Precondition required assertEquals("HTTP 429 Too Many Requests", new WebApplicationException(429).getMessage()); // HTTP 429 Precondition Required // should be: HTTP 429 Too Many Requests assertEquals("431 Request Header Fields Too Large", new WebApplicationException(431).getMessage()); // HTTP 431 Too Many Requests // should be: HTTP 431 Request Header Fields Too Large } // taken from Response.class // // REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested Range Not Satisfiable"), // /** // * 417 Expectation Failed, see {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18">HTTP/1.1 documentation</a>}. // * // * @since 2.0 // */ // EXPECTATION_FAILED(417, "Expectation Failed"), // /** // * 428 Precondition required, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-3">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // PRECONDITION_REQUIRED(428, "Precondition Required"), // /** // * 429 Too Many Requests, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-4">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // TOO_MANY_REQUESTS(429, "Too Many Requests"), // /** // * 431 Request Header Fields Too Large, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-5">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"), ``` ### How to Reproduce? run the JBang script: ```java ///usr/bin/env jbang "$0" "$@" ; exit $? //JAVAC_OPTIONS -parameters //JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager //DEPS io.quarkus:quarkus-rest-client-reactive:2.6.1.Final //DEPS io.quarkus:quarkus-arc:2.6.1.Final import static java.lang.System.*; import io.quarkus.runtime.annotations.QuarkusMain; import io.quarkus.runtime.Quarkus; import javax.inject.Inject; import org.jboss.logging.Logger; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; @QuarkusMain public class webapplicationexception { public static void main(String... args) { System.out.println("Expected: " + Response.Status.PRECONDITION_REQUIRED.getStatusCode() + " " + Response.Status.PRECONDITION_REQUIRED.getReasonPhrase()); System.out.println("Got: " + new WebApplicationException(428).getMessage()); System.out.println(); System.out.println("Expected: " + Response.Status.TOO_MANY_REQUESTS.getStatusCode() + " " + Response.Status.TOO_MANY_REQUESTS.getReasonPhrase()); System.out.println("Got: " + new WebApplicationException(429).getMessage()); System.out.println(); System.out.println("Expected: " + Response.Status.REQUEST_HEADER_FIELDS_TOO_LARGE.getStatusCode() + " " + Response.Status.REQUEST_HEADER_FIELDS_TOO_LARGE.getReasonPhrase()); System.out.println("Got: " + new WebApplicationException(431).getMessage()); } // taken from public enum Status implements StatusType in Response.class // // REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested Range Not Satisfiable"), // /** // * 417 Expectation Failed, see {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18">HTTP/1.1 documentation</a>}. // * // * @since 2.0 // */ // EXPECTATION_FAILED(417, "Expectation Failed"), // /** // * 428 Precondition required, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-3">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // PRECONDITION_REQUIRED(428, "Precondition Required"), // /** // * 429 Too Many Requests, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-4">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // TOO_MANY_REQUESTS(429, "Too Many Requests"), // /** // * 431 Request Header Fields Too Large, see {@link <a href="https://tools.ietf.org/html/rfc6585#section-5">RFC 6585: Additional HTTP Status Codes</a>}. // * // * @since 2.1 // */ // REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"), } ``` ### Output of `uname -a` or `ver` Darwin cdh.localdomain 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64 ### Output of `java -version` java version "17" 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: ~/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1 Java version: 17, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home Default locale: de_AT, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "aarch64", family: "mac" ### Additional information _No response_
2e9d5d5bc80c737a3a540d411b71459d106d4052
4716194b4eb7e151e8e54192598d1191a567ab7e
https://github.com/quarkusio/quarkus/compare/2e9d5d5bc80c737a3a540d411b71459d106d4052...4716194b4eb7e151e8e54192598d1191a567ab7e
diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/AbstractRestResponseBuilder.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/AbstractRestResponseBuilder.java index 6d074fa75f2..df452fb0532 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/AbstractRestResponseBuilder.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/AbstractRestResponseBuilder.java @@ -32,6 +32,8 @@ static { defaultReasonPhrases.put(100, "Continue"); defaultReasonPhrases.put(101, "Switching Protocols"); + defaultReasonPhrases.put(102, "Processing"); + defaultReasonPhrases.put(103, "Early Hints"); defaultReasonPhrases.put(200, "OK"); defaultReasonPhrases.put(201, "Created"); defaultReasonPhrases.put(202, "Accepted"); @@ -39,6 +41,8 @@ defaultReasonPhrases.put(204, "No Content"); defaultReasonPhrases.put(205, "Reset Content"); defaultReasonPhrases.put(206, "Partial Content"); + defaultReasonPhrases.put(208, "Already Reported"); + defaultReasonPhrases.put(226, "IM Used"); defaultReasonPhrases.put(300, "Multiple Choices"); defaultReasonPhrases.put(301, "Moved Permanently"); defaultReasonPhrases.put(302, "Found"); @@ -65,16 +69,22 @@ defaultReasonPhrases.put(415, "Unsupported Media Type"); defaultReasonPhrases.put(416, "Requested Range Not Satisfiable"); defaultReasonPhrases.put(417, "Expectation Failed"); + defaultReasonPhrases.put(421, "Misdirected Request"); defaultReasonPhrases.put(426, "Upgrade Required"); - defaultReasonPhrases.put(428, "Expectation Failed"); - defaultReasonPhrases.put(429, "Precondition Required"); - defaultReasonPhrases.put(431, "Too Many Requests"); + defaultReasonPhrases.put(428, "Precondition Required"); + defaultReasonPhrases.put(429, "Too Many Requests"); + defaultReasonPhrases.put(431, "Request Header Fields Too Large"); + defaultReasonPhrases.put(451, "Unavailable For Legal Reasons"); defaultReasonPhrases.put(500, "Internal Server Error"); defaultReasonPhrases.put(501, "Not Implemented"); defaultReasonPhrases.put(502, "Bad Gateway"); defaultReasonPhrases.put(503, "Service Unavailable"); defaultReasonPhrases.put(504, "Gateway Timeout"); defaultReasonPhrases.put(505, "HTTP Version Not Supported"); + defaultReasonPhrases.put(506, "Variant Also Negotiates"); + defaultReasonPhrases.put(507, "Insufficient Storage"); + defaultReasonPhrases.put(508, "Loop Detected"); + defaultReasonPhrases.put(510, "Not Extended"); defaultReasonPhrases.put(511, "Network Authentication Required"); }
['independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/AbstractRestResponseBuilder.java']
{'.java': 1}
1
1
0
0
1
19,161,045
3,711,474
488,409
4,744
988
223
16
1
6,152
576
1,638
149
8
2
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,538
quarkusio/quarkus/22744/22731
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22731
https://github.com/quarkusio/quarkus/pull/22744
https://github.com/quarkusio/quarkus/pull/22744
1
fixes
NPE when adding new registry in Quarkus CLI
### Describe the bug When new registry is added into freshly installed Quarkus CLI, the operation fails with NullPointerException. ### Expected behavior New registry is added successfully. ### Actual behavior Exception in console: ``` java.lang.NullPointerException at io.quarkus.registry.config.RegistriesConfigMapperHelper.serialize(RegistriesConfigMapperHelper.java:45) at io.quarkus.registry.config.RegistriesConfig$Mutable.persist(RegistriesConfig.java:111) at io.quarkus.cli.RegistryAddCommand.call(RegistryAddCommand.java:54) at io.quarkus.cli.RegistryAddCommand.call(RegistryAddCommand.java:12) at picocli.CommandLine.executeUserObject(CommandLine.java:1953) at picocli.CommandLine.access$1300(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358) at picocli.CommandLine$RunLast.handle(CommandLine.java:2352) at picocli.CommandLine$RunLast.handle(CommandLine.java:2314) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) at picocli.CommandLine$RunLast.execute(CommandLine.java:2316) at picocli.CommandLine.execute(CommandLine.java:2078) at io.quarkus.cli.QuarkusCli.run(QuarkusCli.java:50) at io.quarkus.cli.QuarkusCli_ClientProxy.run(Unknown Source) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:125) at io.quarkus.runtime.Quarkus.run(Quarkus.java:67) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.cli.Main.main(Main.java:9) ``` ### How to Reproduce? Steps to reproduce: 1. `jbang app uninstall quarkus` 2. `rm -r ~/.quarkus/` 3. `jbang app install --fresh --force quarkus@quarkusio` 4. ``` $ quarkus version 2.6.1.Final # 2.5.2.Final worked as expected ``` 5. `quarkus registry add registry.quarkus.redhat.com` ### Output of `uname -a` or `ver` OS name: "linux", version: "5.15.6-100.fc34.x86_64" ### Output of `java -version` 11.0.13, vendor: Eclipse Adoptium ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
aed1114b1aded4611a16817841d7659e3821db8a
df807fbf7e4901784b6fa00899f821428fc2d55d
https://github.com/quarkusio/quarkus/compare/aed1114b1aded4611a16817841d7659e3821db8a...df807fbf7e4901784b6fa00899f821428fc2d55d
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java index 016147cb321..7ce770d8546 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java @@ -30,16 +30,13 @@ public Integer call() throws Exception { existingConfig = Files.exists(configYaml); } + registryClient.refreshRegistryCache(output); final RegistriesConfig.Mutable config; - if (existingConfig) { - registryClient.refreshRegistryCache(output); - config = registryClient.resolveConfig().mutable(); - if (config.getSource().getFilePath() == null) { - output.error("Can only modify file-based configuration. Config source is " + config.getSource().describe()); - return CommandLine.ExitCode.SOFTWARE; - } - } else { + if (configYaml != null && !existingConfig) { + // we're creating a new configuration for a new file config = RegistriesConfig.builder(); + } else { + config = registryClient.resolveConfig().mutable(); } boolean persist = false; @@ -48,10 +45,10 @@ public Integer call() throws Exception { } if (persist) { - if (existingConfig) { - config.persist(); - } else { + if (configYaml != null) { config.persist(configYaml); + } else { + config.persist(); } } return CommandLine.ExitCode.OK; diff --git a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigImpl.java b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigImpl.java index dd969f9982e..495e8f3827e 100644 --- a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigImpl.java +++ b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigImpl.java @@ -217,7 +217,9 @@ public String toString() { static void persistConfigSource(RegistriesConfigImpl config) throws IOException { Path targetFile = config.configSource.getFilePath(); - if (targetFile == null) { + if (config.configSource == ConfigSource.DEFAULT) { + targetFile = RegistriesConfigLocator.getDefaultConfigYamlLocation(); + } else if (targetFile == null) { throw new UnsupportedOperationException( String.format("Can not write configuration as it was read from an alternate source: %s", config.configSource.describe())); diff --git a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigLocator.java b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigLocator.java index f26ac04d706..66ce462cf0d 100644 --- a/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigLocator.java +++ b/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigLocator.java @@ -159,8 +159,6 @@ public static RegistryConfig getDefaultRegistry() { } /** - * TODO: compare set *.json.RegistriesConfigLocator#initFromEnvironmentOrNull - * * @param map A Map containing environment variables, e.g. {@link System#getenv()} * @return A RegistriesConfig object initialized from environment variables. */
['independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigLocator.java', 'devtools/cli/src/main/java/io/quarkus/cli/RegistryAddCommand.java', 'independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/config/RegistriesConfigImpl.java']
{'.java': 3}
3
3
0
0
3
19,068,000
3,693,516
485,572
4,726
1,180
224
25
3
2,268
169
598
70
0
2
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,539
quarkusio/quarkus/22732/19063
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/19063
https://github.com/quarkusio/quarkus/pull/22732
https://github.com/quarkusio/quarkus/pull/22732
1
fixes
NPE in LambdaHttpHandler (amazon-lambda-http extension)
### Describe the bug While testing a Quarkus Lambda function, I hit the following NPE: ERROR [qua.ama.lam.http] (main) Request Failure: java.lang.NullPointerException at io.quarkus.amazon.lambda.http.LambdaHttpHandler.nettyDispatch(LambdaHttpHandler.java:171) at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:63) at io.quarkus.amazon.lambda.http.LambdaHttpHandler.handleRequest(LambdaHttpHandler.java:43) at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.handle(AmazonLambdaRecorder.java:71) at io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler.handleRequest(QuarkusStreamHandler.java:58) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at lambdainternal.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:375) at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:899) at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:257) at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:192) at lambdainternal.AWSLambda.main(AWSLambda.java:187) Would be nicer to get a proper error message. I'm willing to open a PR, just wondering what would be the best way to fix/ validate this? @patriot1burke @richiethom @HardNorth ### Expected behavior A proper error message ### Actual behavior NullPointerException ### How to Reproduce? 1. Open a deployed Quarkus Lambda function in AWS console 2. Hit Test button 3. NPE is shown in Log output section ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` Java 11 (Corretto) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.1.0 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Maven 3.8.1 ### Additional information _No response_
6a36ecf6d078769c0f5095b83d858afce5a7b79e
151897a299dbe3e4665171c9a989922fcabe84dd
https://github.com/quarkusio/quarkus/compare/6a36ecf6d078769c0f5095b83d858afce5a7b79e...151897a299dbe3e4665171c9a989922fcabe84dd
diff --git a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java index 7236fe332fe..dea92dbf76d 100644 --- a/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java +++ b/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java @@ -167,8 +167,16 @@ private APIGatewayV2HTTPResponse nettyDispatch(InetSocketAddress clientAddress, quarkusHeaders.setContextObject(Context.class, context); quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.class, request); quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.RequestContext.class, request.getRequestContext()); + HttpMethod httpMethod = null; + if (request.getRequestContext() != null && request.getRequestContext().getHttp() != null + && request.getRequestContext().getHttp().getMethod() != null) { + httpMethod = HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod()); + } + if (httpMethod == null) { + throw new IllegalStateException("Missing HTTP method in request event"); + } DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, - HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod()), ofNullable(request.getRawQueryString()) + httpMethod, ofNullable(request.getRawQueryString()) .filter(q -> !q.isEmpty()).map(q -> request.getRawPath() + '?' + q).orElse(request.getRawPath()), quarkusHeaders); if (request.getHeaders() != null) { //apparently this can be null if no headers are sent
['extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java']
{'.java': 1}
1
1
0
0
1
19,156,405
3,710,687
488,334
4,744
654
110
10
1
2,064
171
499
61
0
0
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,540
quarkusio/quarkus/22717/21455
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/21455
https://github.com/quarkusio/quarkus/pull/22717
https://github.com/quarkusio/quarkus/pull/22717
1
fixes
Quarkus quartz should not reschedule jobs on start
### Describe the bug Bug introduced by https://github.com/quarkusio/quarkus/issues/20538 Anytime quarkus starts it will reschedule jobs, not matter if the job config changed or not. It's a tough decision, at best it should only detect changes and WARN, nothing else. This can have serious collateral damages depending on what your jobs are doing. If you are cleaning up your data once a year, you don't want that to be re initialized and triggered every time you restart the app or scale up your cluster. ### Expected behavior Do not reschedule jobs, WARN or maybe improve the dev tools but this is too dangerous. ### Actual behavior All jobs are rescheduled on start. ### How to Reproduce? Pick any quartz based clustered app. Create a job running every 5 sec for example. Request the db for select * from qrtz_simple_triggers and select * from qrtz_triggers Restart the app and check the table again. All triggers, executions are reset, ignoring past execution and, most important, the expected and persistent next_fire_time on qrtz_triggers. ### Output of `uname -a` or `ver` no impact ### Output of `java -version` no impact ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev since 2.3.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) no impact ### Additional information _No response_
8d0517772f179f09c9b73379645a4f476bc8432d
d657de40d9fe415d10a7f8f5ac21c8b44d8fe829
https://github.com/quarkusio/quarkus/compare/8d0517772f179f09c9b73379645a4f476bc8432d...d657de40d9fe415d10a7f8f5ac21c8b44d8fe829
diff --git a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java index d3939ebe628..6fc95db8c4a 100644 --- a/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java +++ b/extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java @@ -201,7 +201,9 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Sc LOGGER.debugf("Scheduled business method %s with config %s", method.getMethodDescription(), scheduled); } else { - scheduler.rescheduleJob(trigger.getKey(), trigger); + org.quartz.Trigger oldTrigger = scheduler.getTrigger(trigger.getKey()); + scheduler.rescheduleJob(trigger.getKey(), + triggerBuilder.startAt(oldTrigger.getNextFireTime()).build()); LOGGER.debugf("Rescheduled business method %s with config %s", method.getMethodDescription(), scheduled); }
['extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java']
{'.java': 1}
1
1
0
0
1
19,067,682
3,693,437
485,560
4,726
352
46
4
1
1,388
220
323
52
1
0
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,541
quarkusio/quarkus/22681/22662
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22662
https://github.com/quarkusio/quarkus/pull/22681
https://github.com/quarkusio/quarkus/pull/22681
1
fixes
Gauges annotation are not showing up his value, on a resteasy endpoint
### Describe the bug If a gauge is declared in a Resteasy endpoint through an annotation, the gauge value is not pushed to `/metrics` Example: ``` @Path("/using-microprofile-pingpong") public class UsingMicroProfilePingPongResource { private static final String PING_PONG = "ping pong"; private static final long DEFAULT_GAUGE_VALUE = 100L; // counters works as expected @GET @Counted(name = "simple_counter_mp", absolute = true) @Produces(MediaType.TEXT_PLAIN) @Path("/counter") public String simpleScenario() { return PING_PONG; } //TODO gauges are not promoting their values to /metrics @GET @Gauge(name = "simple_gauge_mp", unit = MetricUnits.NONE) @Produces(MediaType.TEXT_PLAIN) @Path("/gauge") public long highestPrimeNumberSoFar() { return DEFAULT_GAUGE_VALUE; } } ``` But If I move on the gauge to a separate public method, then works as expected: ``` @Path("/using-microprofile-pingpong") public class UsingMicroProfilePingPongResource { private static final String PING_PONG = "ping pong"; private static final long DEFAULT_GAUGE_VALUE = 100L; @GET @Counted(name = "simple_counter_mp", absolute = true) @Produces(MediaType.TEXT_PLAIN) @Path("/counter") public String simpleScenario() { return PING_PONG; } @GET @Produces(MediaType.TEXT_PLAIN) @Path("/gauge") public long highestPrimeNumberSoFar() { return getDefaultGauge(); } @Gauge(name = "simple_gauge_mp", unit = MetricUnits.NONE) public long getDefaultGauge() { return DEFAULT_GAUGE_VALUE; } } ``` Additional when the gauge is not promoted I am getting the following warning message: ``` 2022-01-05 16:48:04,996 WARN [io.mic.cor.ins.int.DefaultGauge] (vert.x-worker-thread-0) Failed to apply the value function for the gauge 'io.quarkus.ts.micrometer.prometheus.UsingMicroProfilePingPongResource.simple_gauge_mp'. Note that subsequent logs will be logged at debug level.: javax.enterprise.context.ContextNotActiveException at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:46) at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ClientProxy.arc$delegate(Unknown Source) ``` From a developer experience point of view, would be great to have the same behavior in all metrics data structures. So, if counter annotations is available in an endpoint declaration then gauges should be also valid. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
9a40f35af46ddeb20a6426fef10348fe02045788
6c613029edec5fcddea931062ebb9f2ecdde0c01
https://github.com/quarkusio/quarkus/compare/9a40f35af46ddeb20a6426fef10348fe02045788...6c613029edec5fcddea931062ebb9f2ecdde0c01
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java index 820e93c7411..835b0e6e831 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java @@ -10,7 +10,7 @@ import io.micrometer.core.instrument.Tags; -class MetricDescriptor { +public class MetricDescriptor { final String name; final Tags tags; ExtendedMetricID metricId = null; diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java index 232fa2cc10d..80df6d2aee8 100644 --- a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java +++ b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java @@ -4,6 +4,7 @@ import java.util.Set; import javax.annotation.Priority; +import javax.enterprise.context.ContextNotActiveException; import javax.inject.Inject; import javax.interceptor.AroundInvoke; import javax.interceptor.Interceptor; @@ -12,6 +13,7 @@ import io.quarkus.arc.ArcInvocationContext; import io.quarkus.vertx.http.runtime.CurrentVertxRequest; import io.vertx.core.http.impl.HttpServerRequestInternal; +import io.vertx.ext.web.RoutingContext; @SuppressWarnings("unused") @QuarkusRestPathTemplate @@ -24,7 +26,13 @@ public class QuarkusRestPathTemplateInterceptor { @AroundInvoke Object restMethodInvoke(InvocationContext context) throws Exception { QuarkusRestPathTemplate annotation = getAnnotation(context); - if ((annotation != null) && (request.getCurrent() != null)) { + RoutingContext routingContext = null; + try { + routingContext = request.getCurrent(); + } catch (ContextNotActiveException ex) { + // just leave routingContext as null + } + if ((annotation != null) && (routingContext != null)) { ((HttpServerRequestInternal) request.getCurrent().request()).context().putLocal("UrlPathTemplate", annotation.value()); } diff --git a/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java b/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java index 8504a49f242..0545b7477f9 100644 --- a/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java +++ b/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java @@ -70,6 +70,8 @@ String checkPrime(long number) { } @Gauge(name = "highestPrimeNumberSoFar", unit = MetricUnits.NONE, description = "Highest prime number so far.") + @GET + @Path("/blabla") // make this a REST method just to verify that a gauge will still work on it public Long highestPrimeNumberSoFar() { return highestPrimeSoFar.get(); }
['extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java', 'extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java', 'integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java']
{'.java': 3}
3
3
0
0
3
19,059,894
3,691,996
485,377
4,722
519
98
12
2
3,140
338
780
109
0
3
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,542
quarkusio/quarkus/22667/22663
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22663
https://github.com/quarkusio/quarkus/pull/22667
https://github.com/quarkusio/quarkus/pull/22667
1
close
Gradle Task quarkusTest stopped working with version 2.6.1
### Describe the bug `./gradlew quarkusTest` stopped working after upgrading Quarkus to version 2.6.1 `./gradlew quarkusDev` still works as expected (and also runs the tests, if told so) ### Expected behavior `./gradlew quarkusTest` runs quarkus in test mode ### Actual behavior Logs an error: ``` > Task :quarkusGenerateCode preparing quarkus application > Task :quarkusGenerateCodeTests preparing quarkus application > Task :quarkusTest FAILED FAILURE: Build failed with an exception. * What went wrong: A problem was found with the configuration of task ':quarkusTest' (type 'QuarkusTest'). - In plugin 'io.quarkus' type 'io.quarkus.gradle.tasks.QuarkusTest' property 'quarkusDevConfiguration' doesn't have a configured value. Reason: This property isn't marked as optional and no value has been configured. Possible solutions: 1. Assign a value to 'quarkusDevConfiguration'. 2. Mark property 'quarkusDevConfiguration' as optional. Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#value_not_set for more details about this problem. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 9s 6 actionable tasks: 6 executed ``` ### How to Reproduce? Steps to reproduce the behaviour: 1. Download and unpack empty project with gradle from code.quarkus.io 2. Run `./gradlew quarkusTest` inside the folder ### Output of `uname -a` or `ver` Darwin FXMBPFVFF771GQ05N 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64 ### Output of `java -version` openjdk version "11.0.13" 2021-10-19 ### GraalVM version (if different from Java) OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05) ### Quarkus version or git rev 2.6.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.3.3 ### Additional information _No response_
4e9dea2835302bafe4ccfab24594b3447e7fea7e
5e70a7cbb1a0f835d3f9f84c2c0a4949044a0f9d
https://github.com/quarkusio/quarkus/compare/4e9dea2835302bafe4ccfab24594b3447e7fea7e...5e70a7cbb1a0f835d3f9f84c2c0a4949044a0f9d
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index c2860d18b4e..8d4451fe3dd 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -167,7 +167,7 @@ public void execute(Task test) { ConfigurationContainer configurations = project.getConfigurations(); // create a custom configuration for devmode - Configuration configuration = configurations.create(DEV_MODE_CONFIGURATION_NAME) + Configuration devModeConfiguration = configurations.create(DEV_MODE_CONFIGURATION_NAME) .extendsFrom(configurations.findByName(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME)); tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile.class, @@ -197,12 +197,15 @@ public void execute(Task test) { task.dependsOn(classesTask, resourcesTask, testClassesTask, testResourcesTask, quarkusGenerateCodeDev, quarkusGenerateCodeTests); - task.setQuarkusDevConfiguration(configuration); + task.setQuarkusDevConfiguration(devModeConfiguration); }); quarkusRemoteDev.configure(task -> task.dependsOn(classesTask, resourcesTask)); - quarkusTest.configure(task -> task.dependsOn(classesTask, resourcesTask, testClassesTask, testResourcesTask, - quarkusGenerateCode, - quarkusGenerateCodeTests)); + quarkusTest.configure(task -> { + task.dependsOn(classesTask, resourcesTask, testClassesTask, testResourcesTask, + quarkusGenerateCode, + quarkusGenerateCodeTests); + task.setQuarkusDevConfiguration(devModeConfiguration); + }); quarkusBuild.configure( task -> task.dependsOn(classesTask, resourcesTask, tasks.named(JavaPlugin.JAR_TASK_NAME))); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index 88ebef62663..38c19e093c2 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -51,7 +51,7 @@ public class QuarkusDev extends QuarkusTask { public static final String IO_QUARKUS_DEVMODE_ARGS = "io.quarkus.devmode-args"; private Set<File> filesIncludedInClasspath = new HashSet<>(); - private Configuration quarkusDevConfiguration; + protected Configuration quarkusDevConfiguration; private File buildDir;
['devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java', 'devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java']
{'.java': 2}
2
2
0
0
2
19,053,259
3,690,738
485,218
4,720
1,081
164
15
2
2,162
278
606
78
2
1
1970-01-01T00:27:21
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,483
quarkusio/quarkus/24038/24037
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/24037
https://github.com/quarkusio/quarkus/pull/24038
https://github.com/quarkusio/quarkus/pull/24038
1
fix
quarkus-reactive-routes fails when using Mutiny.SessionFactory.withSession
### Describe the bug quarkus-reactive-routes based code fails when using Mutiny.SessionFactory.withSession hibernate-reactive-routes-quickstart is failing since https://github.com/quarkusio/quarkus/pull/23719 got merged Code link https://github.com/quarkusio/quarkus-quickstarts/blob/main/hibernate-reactive-routes-quickstart/src/main/java/org/acme/hibernate/reactive/FruitsRoutes.java#L39 ``` 2022-03-01 10:27:25,791 ERROR [org.acm.hib.rea.FruitsRoutes] (vert.x-eventloop-thread-1) Failed to handle request: java.lang.IllegalStateException: The current operation requires a safe (isolated) Vert.x sub-context, but the current context hasn't been flagged as such. You can still use Hibernate Reactive, you just need to avoid using the methods which implicitly require accessing the stateful context, such as MutinySessionFactory#withTransaction and #withSession. at io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.checkIsSafe(VertxContextSafetyToggle.java:80) at io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.validateContextIfExists(VertxContextSafetyToggle.java:63) at io.quarkus.hibernate.reactive.runtime.customized.CheckingVertxContext.get(CheckingVertxContext.java:46) at org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl.withSession(MutinySessionFactoryImpl.java:189) at org.acme.hibernate.reactive.FruitsRoutes.getAll(FruitsRoutes.java:39) ... ``` Zulip chat - https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/hibernate-reactive-routes-quickstart/near/273641831 Conclusion: the vert.x http server didn't mark the context as safe ### Expected behavior hibernate-reactive-routes-quickstart is passing ### Actual behavior hibernate-reactive-routes-quickstart is failing ### How to Reproduce? Run hibernate-reactive-routes-quickstart ### Output of `uname -a` or `ver` macOS Monterey ### Output of `java -version` Java 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev Quarkus main ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
9089423fde7bd7aaf1b93ed5243c4e4db4217211
895f0434c884315a71587730bec38ef63cc1678f
https://github.com/quarkusio/quarkus/compare/9089423fde7bd7aaf1b93ed5243c4e4db4217211...895f0434c884315a71587730bec38ef63cc1678f
diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/context/GrpcDuplicatedContextGrpcInterceptor.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/context/GrpcDuplicatedContextGrpcInterceptor.java index b6f0938dafe..21d7b0ee422 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/context/GrpcDuplicatedContextGrpcInterceptor.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/context/GrpcDuplicatedContextGrpcInterceptor.java @@ -1,5 +1,7 @@ package io.quarkus.grpc.runtime.supports.context; +import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe; + import java.util.function.Supplier; import javax.enterprise.context.ApplicationScoped; @@ -39,6 +41,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, Re if (capturedVertxContext != null) { // If we are not on a duplicated context, create and switch. Context local = VertxContext.getOrCreateDuplicatedContext(capturedVertxContext); + setContextSafe(local, true); // Must be sure to call next.startCall on the right context return new ListenedOnDuplicatedContext<>(() -> next.startCall(call, headers), local); diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/InstrumenterVertxTracer.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/InstrumenterVertxTracer.java index 7bfd07b10bb..294c0205162 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/InstrumenterVertxTracer.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/InstrumenterVertxTracer.java @@ -1,5 +1,7 @@ package io.quarkus.opentelemetry.runtime.tracing.vertx; +import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe; + import java.util.Map; import java.util.function.BiConsumer; @@ -91,6 +93,7 @@ default <R> SpanOperation sendRequest( io.opentelemetry.context.Context spanContext = instrumenter.start(parentContext, writableHeaders((REQ) request, headers)); Context duplicatedContext = VertxContext.getOrCreateDuplicatedContext(context); + setContextSafe(duplicatedContext, true); Scope scope = QuarkusContextStorage.INSTANCE.attach(duplicatedContext, spanContext); return spanOperation(duplicatedContext, (REQ) request, toMultiMap(headers), spanContext, scope); } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 929b1088030..adeb4a57192 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -1,5 +1,8 @@ package io.quarkus.vertx.http.runtime; +import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setContextSafe; +import static io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle.setCurrentContextSafe; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -488,6 +491,7 @@ public void handle(HttpServerRequest event) { root = new Handler<HttpServerRequest>() { @Override public void handle(HttpServerRequest event) { + setCurrentContextSafe(true); delegate.handle(new ResumingRequestWrapper(event)); } }; @@ -1209,7 +1213,12 @@ public void initChannel(VirtualChannel ch) throws Exception { VertxHandler<Http1xServerConnection> handler = VertxHandler.create(chctx -> { Http1xServerConnection conn = new Http1xServerConnection( - () -> (ContextInternal) VertxContext.getOrCreateDuplicatedContext(context), + () -> { + ContextInternal internal = (ContextInternal) VertxContext + .getOrCreateDuplicatedContext(context); + setContextSafe(internal, true); + return internal; + }, null, new HttpServerOptions(), chctx,
['extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/context/GrpcDuplicatedContextGrpcInterceptor.java', 'extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/InstrumenterVertxTracer.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java']
{'.java': 3}
3
3
0
0
3
19,970,488
3,865,774
507,548
4,880
1,045
157
17
3
2,157
172
542
56
3
1
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,492
quarkusio/quarkus/23840/22762
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/22762
https://github.com/quarkusio/quarkus/pull/23840
https://github.com/quarkusio/quarkus/pull/23840
1
fix
Server Sent Events delaying 200 response
### Describe the bug I am on 2.6.1.Final. I have an endpoint that is an SSE endpoint. The status code is only returned after the first element is produced. This was not the case in 1.x and can lead to timeouts on clients. ### Expected behavior I would expect a 200 to be returned immediately (provided everything worked as expected). ### Actual behavior The status code, headers, etc. is not returned until the moment the first item is produced. ### How to Reproduce? [getting-started.zip](https://github.com/quarkusio/quarkus/files/7837816/getting-started.zip) ### Output of `uname -a` or `ver` Linux jose-buguroo 5.11.0-41-generic #45-Ubuntu SMP Fri Nov 5 11:37:01 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "14.0.2" 2020-07-14 OpenJDK Runtime Environment (build 14.0.2+12-46) OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.6.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/jose/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 14.0.2, vendor: Oracle Corporation, runtime: /home/jose/.sdkman/candidates/java/14.0.2-open Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.11.0-41-generic", arch: "amd64", family: "unix" ### Additional information From what I see `SseUtil.send` is producing the response the first time an element is produced. Therefore, until the first element is generated, no call to it happens and no response is flushed. I see this could have to do with `PublisherResponseHandler` suspending the context. I wonder if an option could be to have that class handle SSE slightly different and generate a status code. I see that adding: ``` requestContext.serverResponse().setStatusCode(200) requestContext.serverResponse().setChunked(true) requestContext.serverResponse().write(new byte[]{}) ``` to PublisherResponseHandler works as expected (i.e. we get the status code, headers, etc. and then the events get produced as they come). Any reason you can think of not to do that?
5137bb9f42aaa9f3e65f0b494f761ba583de2c7c
23ab5a000f0c5c23c0e3b9a149bc1786a991fe55
https://github.com/quarkusio/quarkus/compare/5137bb9f42aaa9f3e65f0b494f761ba583de2c7c...23ab5a000f0c5c23c0e3b9a149bc1786a991fe55
diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java index 963d71a82fe..07564a0982b 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java @@ -151,8 +151,6 @@ public static void setHeaders(ResteasyReactiveRequestContext context, ServerHttp public static void setHeaders(ResteasyReactiveRequestContext context, ServerHttpResponse response, List<PublisherResponseHandler.StreamingResponseCustomizer> customizers) { - // FIXME: spec says we should flush the headers when first message is sent or when the resource method returns, whichever - // happens first if (!response.headWritten()) { response.setStatusCode(Response.Status.OK.getStatusCode()); response.setResponseHeader(HttpHeaders.CONTENT_TYPE, MediaType.SERVER_SENT_EVENTS); @@ -164,6 +162,7 @@ public static void setHeaders(ResteasyReactiveRequestContext context, ServerHttp customizers.get(i).customize(response); } // FIXME: other headers? + } } } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java index 43ddb8b91cf..64dc218adb1 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java @@ -1,10 +1,14 @@ package org.jboss.resteasy.reactive.server.handlers; +import static org.jboss.resteasy.reactive.server.jaxrs.SseEventSinkImpl.EMPTY_BUFFER; + import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.BiConsumer; import java.util.function.BiFunction; +import java.util.function.Consumer; import javax.ws.rs.core.MediaType; import org.jboss.logging.Logger; import org.jboss.resteasy.reactive.common.util.RestMediaType; @@ -43,9 +47,9 @@ private static class SseMultiSubscriber extends AbstractMultiSubscriber { @Override public void onNext(Object item) { OutboundSseEventImpl event = new OutboundSseEventImpl.BuilderImpl().data(item).build(); - SseUtil.send(requestContext, event, customizers).handle(new BiFunction<Object, Throwable, Object>() { + SseUtil.send(requestContext, event, customizers).whenComplete(new BiConsumer<Object, Throwable>() { @Override - public Object apply(Object v, Throwable t) { + public void accept(Object v, Throwable t) { if (t != null) { // need to cancel because the exception didn't come from the Multi subscription.cancel(); @@ -54,7 +58,6 @@ public Object apply(Object v, Throwable t) { // send in the next item subscription.request(1); } - return null; } }); } @@ -250,11 +253,11 @@ public void handle(ResteasyReactiveRequestContext requestContext) throws Excepti requestContext.setResponseContentType(mediaType); // this is the non-async return type requestContext.setGenericReturnType(requestContext.getTarget().getReturnType()); - // we have several possibilities here, but in all we suspend - requestContext.suspend(); + if (mediaType.isCompatible(MediaType.SERVER_SENT_EVENTS_TYPE)) { handleSse(requestContext, result); } else { + requestContext.suspend(); boolean json = mediaType.toString().contains(JSON); if (requiresChunkedStream(mediaType)) { handleChunkedStreaming(requestContext, result, json); @@ -279,7 +282,18 @@ private void handleStreaming(ResteasyReactiveRequestContext requestContext, Publ } private void handleSse(ResteasyReactiveRequestContext requestContext, Publisher<?> result) { - result.subscribe(new SseMultiSubscriber(requestContext, streamingResponseCustomizers)); + SseUtil.setHeaders(requestContext, requestContext.serverResponse(), streamingResponseCustomizers); + requestContext.suspend(); + requestContext.serverResponse().write(EMPTY_BUFFER, new Consumer<Throwable>() { + @Override + public void accept(Throwable throwable) { + if (throwable == null) { + result.subscribe(new SseMultiSubscriber(requestContext, streamingResponseCustomizers)); + } else { + requestContext.resume(throwable); + } + } + }); } public interface StreamingResponseCustomizer { diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java index 6cdf099eab4..48735ac388c 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java @@ -11,7 +11,7 @@ public class SseEventSinkImpl implements SseEventSink { - private static final byte[] EMPTY_BUFFER = new byte[0]; + public static final byte[] EMPTY_BUFFER = new byte[0]; private ResteasyReactiveRequestContext context; private SseBroadcasterImpl broadcaster; private boolean closed;
['independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java', 'independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/SseUtil.java', 'independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java']
{'.java': 3}
3
3
0
0
3
19,858,822
3,844,908
505,026
4,865
1,671
305
31
3
2,275
296
646
51
1
1
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,498
quarkusio/quarkus/23675/23674
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23674
https://github.com/quarkusio/quarkus/pull/23675
https://github.com/quarkusio/quarkus/pull/23675
1
fixes
DevUI console no longer responds if you enter input before it boots
### Describe the bug In a Quarkus app, if you type something before the app is initialized with `mvn clean compile quarkus:dev`, you'll get the following exception in the console and the input no longer works (you need to kill the process to Ctrl+C the application): ```java Exception in thread "Aesh InputStream Reader" java.lang.NullPointerException: Cannot invoke "io.quarkus.dev.console.QuarkusConsole$StateChangeInputStream.acceptInput(int)" because "redirectIn" is null at io.quarkus.deployment.console.AeshConsole.lambda$setup$1(AeshConsole.java:231) at org.aesh.terminal.EventDecoder.accept(EventDecoder.java:118) at org.aesh.terminal.EventDecoder.accept(EventDecoder.java:31) at org.aesh.terminal.io.Decoder.write(Decoder.java:133) at org.aesh.readline.tty.terminal.TerminalConnection.openBlocking(TerminalConnection.java:216) at org.aesh.readline.tty.terminal.TerminalConnection.openBlocking(TerminalConnection.java:203) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) ``` ### Expected behavior No errors and input works normally ### Actual behavior You can't input anything in the console while the app is running ### How to Reproduce? 1. Create a Quarkus application 2. Run `mvn clean compile quarkus:dev` 3. Start typing in the console before the application starts ### Output of `uname -a` or `ver` Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64 ### Output of `java -version` OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode) ### GraalVM version (if different from Java) None ### Quarkus version or git rev 2.7.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Maven 3.8.4 ### Additional information _No response_
ea4099305aed07d0428bf4aa53de61142a2e7499
cf27363f6bd771062935fdf67c9bc613051971d9
https://github.com/quarkusio/quarkus/compare/ea4099305aed07d0428bf4aa53de61142a2e7499...cf27363f6bd771062935fdf67c9bc613051971d9
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/console/AeshConsole.java b/core/deployment/src/main/java/io/quarkus/deployment/console/AeshConsole.java index b7e144bbbdd..15bec6b648d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/console/AeshConsole.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/console/AeshConsole.java @@ -225,6 +225,10 @@ public void run() { conn.setStdinHandler(keys -> { QuarkusConsole.StateChangeInputStream redirectIn = QuarkusConsole.REDIRECT_IN; + // redirectIn might have not been initialized yet + if (redirectIn == null) { + return; + } //see if the users application wants to read the keystrokes: int pos = 0; while (pos < keys.length) {
['core/deployment/src/main/java/io/quarkus/deployment/console/AeshConsole.java']
{'.java': 1}
1
1
0
0
1
19,784,494
3,830,374
503,387
4,854
157
25
4
1
1,975
195
514
54
0
1
1970-01-01T00:27:24
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,496
quarkusio/quarkus/23751/23734
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23734
https://github.com/quarkusio/quarkus/pull/23751
https://github.com/quarkusio/quarkus/pull/23751
1
resolves
@Message template fails to use #each or #for
### Describe the bug I'm using Qute to enable i18n on a project. When parsing a string using `Qute.fmt`, passing a template directly renders the message just fine. But when I reference its template via the message bundle namespace, such as ```java Qute.fmt("{error:errorMessage(dates)}").data("dates", dates)).attribute('locale', locale).render() ``` I get the following error ```text 2022-02-15 19:54:04,757 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (vert.x-worker-thread-0) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.qute.deployment.QuteProcessor#processTemplateErrors threw an exception: io.quarkus.qute.TemplateException: Found template problems (1): [1] Incorrect expression found: {it} - it is not a parameter of the message bundle method net.dummy.example.i18n.ErrorMessages#errorMessage() - at net.dummy.example.i18n.ErrorMessages#errorMessage():1 at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:200) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at java.base/java.lang.Thread.run(Thread.java:834) at org.jboss.threads.JBossThread.run(JBossThread.java:501) Suppressed: io.quarkus.qute.TemplateException: Incorrect expression found: {it} - it is not a parameter of the message bundle method net.dummy.example.i18n.ErrorMessages#errorMessage() - at net.dummy.example.i18n.ErrorMessages#errorMessage():1 at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:174) ... 11 more ``` @Message("FROM i18n A booking for user {user} in the selected period {#each period}{it}{#if it_hasNext}, {/if}{/each} already exists.") I have an interface like this: ```java @MessageBundle(value = "error") public interface ErrorMessages { @Message("Information in the selected period {#each dates}{it}{/each} already exists.") String errorMessage(List<String> dates); } ``` ### Expected behavior I want it to return `Information in the selected period 2022-02-15, 2022-02-16 already exists.` ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` Oracle JDK 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) ### Additional information _No response_
f52d0ae1a17ae68503e3ecb1dc099675ab76a38b
d596df37371dcf6acc585d631af9a57c59a2279d
https://github.com/quarkusio/quarkus/compare/f52d0ae1a17ae68503e3ecb1dc099675ab76a38b...d596df37371dcf6acc585d631af9a57c59a2279d
diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java index a226da57c02..2233a59a65d 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java @@ -78,6 +78,7 @@ import io.quarkus.qute.EvaluatedParams; import io.quarkus.qute.Expression; import io.quarkus.qute.Expression.Part; +import io.quarkus.qute.Expressions; import io.quarkus.qute.Namespaces; import io.quarkus.qute.Resolver; import io.quarkus.qute.deployment.QuteProcessor.LookupConfig; @@ -316,8 +317,8 @@ void validateMessageBundleMethods(TemplatesAnalysisBuildItem templatesAnalysis, for (TemplateAnalysis analysis : templatesAnalysis.getAnalysis()) { MessageBundleMethodBuildItem messageBundleMethod = bundleMethods.get(analysis.id); if (messageBundleMethod != null) { + // All top-level expressions without a namespace should be mapped to a param Set<String> usedParamNames = new HashSet<>(); - // All top-level expressions without namespace map to a param Set<String> paramNames = IntStream.range(0, messageBundleMethod.getMethod().parameters().size()) .mapToObj(idx -> getParameterName(messageBundleMethod.getMethod(), idx)).collect(Collectors.toSet()); for (Expression expression : analysis.expressions) { @@ -342,8 +343,12 @@ private void validateExpression(BuildProducer<IncorrectExpressionBuildItem> inco return; } if (!expression.hasNamespace()) { - String name = expression.getParts().get(0).getName(); - if (!paramNames.contains(name)) { + Expression.Part firstPart = expression.getParts().get(0); + String name = firstPart.getName(); + // Skip expressions that have type info derived from a parent section, e.g "it<loop#3>" and "foo<set#3>" + if (firstPart.getTypeInfo() == null || (firstPart.getTypeInfo().startsWith("" + Expressions.TYPE_INFO_SEPARATOR) + && !paramNames.contains(name))) { + // Expression has no type info or type info that does not match a method parameter incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), name + " is not a parameter of the message bundle method " + messageBundleMethod.getMethod().declaringClass().name() + "#" @@ -815,7 +820,7 @@ private String generateImplementation(ClassInfo defaultBundleInterface, String d return generatedName.replace('/', '.'); } - private String getParameterName(MethodInfo method, int position) { + static String getParameterName(MethodInfo method, int position) { String name = method.parameterName(position); AnnotationInstance paramAnnotation = Annotations .find(Annotations.getParameterAnnotations(method.annotations()).stream() diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java index 50dd9d684b6..7751d806c61 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java @@ -453,8 +453,8 @@ public void beforeParsing(ParserHelper parserHelper) { MethodInfo method = messageBundleMethod.getMethod(); for (ListIterator<Type> it = method.parameters().listIterator(); it.hasNext();) { Type paramType = it.next(); - parserHelper.addParameter(method.parameterName(it.previousIndex()), - JandexUtil.getBoxedTypeName(paramType)); + String name = MessageBundleProcessor.getParameterName(method, it.previousIndex()); + parserHelper.addParameter(name, JandexUtil.getBoxedTypeName(paramType)); } } } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/Item.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/Item.java index 23b0464cb71..b71ef2116af 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/Item.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/Item.java @@ -1,5 +1,7 @@ package io.quarkus.qute.deployment.i18n; +import java.util.List; + public class Item { private String name; @@ -19,4 +21,8 @@ public Integer getAge() { return age; } + public List<String> getNames() { + return List.of(name); + } + } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleExpressionValidationTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleExpressionValidationTest.java index d730e1a6faa..9cb0d8f9096 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleExpressionValidationTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleExpressionValidationTest.java @@ -19,6 +19,7 @@ public class MessageBundleExpressionValidationTest { .withApplicationRoot((jar) -> jar .addClasses(WrongBundle.class, Item.class) .addAsResource(new StringAsset( + // foo is not a parameter of WrongBundle.hello() "hello=Hallo {foo}!"), "messages/msg_de.properties")) .assertException(t -> { @@ -34,10 +35,12 @@ public class MessageBundleExpressionValidationTest { if (te == null) { fail("No template exception thrown: " + t); } - assertTrue(te.getMessage().contains("Found template problems (3)"), te.getMessage()); + assertTrue(te.getMessage().contains("Found template problems (5)"), te.getMessage()); assertTrue(te.getMessage().contains("item.foo"), te.getMessage()); assertTrue(te.getMessage().contains("bar"), te.getMessage()); assertTrue(te.getMessage().contains("foo"), te.getMessage()); + assertTrue(te.getMessage().contains("baf"), te.getMessage()); + assertTrue(te.getMessage().contains("it.baz"), te.getMessage()); }); @Test @@ -48,7 +51,8 @@ public void testValidation() { @MessageBundle public interface WrongBundle { - @Message("Hello {item.foo} {bar}") // -> there is no foo property and bar is not a parameter + // item has no "foo" property, "bar" and "baf" are not parameters + @Message("Hello {item.foo} {bar} {#each item.names}{it}{it.baz}{baf}{/each}") String hello(Item item); }
['extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/MessageBundleProcessor.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/MessageBundleExpressionValidationTest.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/i18n/Item.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java']
{'.java': 4}
4
4
0
0
4
19,800,135
3,833,686
503,715
4,857
1,356
252
17
2
3,299
280
835
88
0
3
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,494
quarkusio/quarkus/23827/23756
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23756
https://github.com/quarkusio/quarkus/pull/23827
https://github.com/quarkusio/quarkus/pull/23827
1
fixes
RESTEasy (Reactive) JSON serialization for multipart form data containing emojis is wrong
### Describe the bug Serialization (string) data containing emojis as JSON form parts in multipart responses or payloads differs from serialization in non-multipart contexts: ``` @Path("/test") public class ReactiveMultipartTestResource { public static class TestData { public String bar; public TestData(String bar) { this.bar = bar; } } public static class FormData { @RestForm @PartType(MediaType.APPLICATION_JSON) public TestData data; @RestForm public String dataAsString; } @Inject ObjectMapper om; @GET @Produces(MediaType.MULTIPART_FORM_DATA) public FormData hello() throws JsonProcessingException { FormData form = new FormData(); form.data = new TestData("Bar äöü 😀"); form.dataAsString = om.writeValueAsString(form.data); return form; } } ``` Looking at the raw request's response shows different encodings for the emoji part. It's not a "simple" UTF-8 problem as the German umlauts for example are correct. This is taken from IntelliJ's HTTP request tool's response file, not sure how encoding is screwed by pasting and submitting here though...) ``` --b7ae92fe-eb4e-4a8b-b142-c77b79adbd88 Content-Disposition: form-data; name="data" Content-Type: application/json {"bar":"Bar äöü \\uD83D\\uDE00"} --b7ae92fe-eb4e-4a8b-b142-c77b79adbd88 Content-Disposition: form-data; name="dataAsString" Content-Type: text/plain {"bar":"Bar äöü 😀"} --b7ae92fe-eb4e-4a8b-b142-c77b79adbd88-- ``` ### Expected behavior Serialized JSON should be the same for "standard" serialization and "automatic" serialization in multipart contexts. ### Actual behavior See above :) ### How to Reproduce? See above :) ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
e4886ccf7dbe79754615dc1f301a051903500557
98b54fb8d017d5dd044d195fd22103854428c21d
https://github.com/quarkusio/quarkus/compare/e4886ccf7dbe79754615dc1f301a051903500557...98b54fb8d017d5dd044d195fd22103854428c21d
diff --git a/independent-projects/resteasy-reactive/server/jackson/src/main/java/org/jboss/resteasy/reactive/server/jackson/JacksonMessageBodyWriterUtil.java b/independent-projects/resteasy-reactive/server/jackson/src/main/java/org/jboss/resteasy/reactive/server/jackson/JacksonMessageBodyWriterUtil.java index 9de661d986f..d9bbd9fc5c9 100644 --- a/independent-projects/resteasy-reactive/server/jackson/src/main/java/org/jboss/resteasy/reactive/server/jackson/JacksonMessageBodyWriterUtil.java +++ b/independent-projects/resteasy-reactive/server/jackson/src/main/java/org/jboss/resteasy/reactive/server/jackson/JacksonMessageBodyWriterUtil.java @@ -55,7 +55,7 @@ public static void doLegacyWrite(Object o, Annotation[] annotations, Multivalued } } } - entityStream.write(defaultWriter.writeValueAsBytes(o)); + entityStream.write(defaultWriter.writeValueAsString(o).getBytes(StandardCharsets.UTF_8)); } }
['independent-projects/resteasy-reactive/server/jackson/src/main/java/org/jboss/resteasy/reactive/server/jackson/JacksonMessageBodyWriterUtil.java']
{'.java': 1}
1
1
0
0
1
19,846,134
3,842,555
504,693
4,862
171
29
2
1
2,147
243
526
90
0
2
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,493
quarkusio/quarkus/23839/23735
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23735
https://github.com/quarkusio/quarkus/pull/23839
https://github.com/quarkusio/quarkus/pull/23839
1
fix
Gradle Unit Tests Don't Work Since 2.7.1
### Describe the bug After moving to Quarkus 2.7.1 from 2.7.0 unit tests in Gradle no longer run. Quarkus says "No tests found" even though there tests. ### Expected behavior Unit tests run and fail because my code is trash ### Actual behavior Unit tests pass saying "No tests found" so I push it to prod and my boss gets angri :fearful: ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` OpenJDK Runtime Environment 18.9 (build 11.0.14+9) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.3 ### Additional information _No response_
465e779699c2158e92ace1dbaf8573f0b5a1a9e2
b7cff8f2c7c96a7cedb0379aeb9710178040e2d4
https://github.com/quarkusio/quarkus/compare/465e779699c2158e92ace1dbaf8573f0b5a1a9e2...b7cff8f2c7c96a7cedb0379aeb9710178040e2d4
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index 7dcd4e9de5e..c2e481183a7 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -487,7 +487,7 @@ private void addLocalProject(ResolvedDependency project, GradleDevModeLauncher.B if (testClassesDir != null && (!testSourcePaths.isEmpty() || (testResourcesOutputDir != null && Files.exists(testResourcesOutputDir)))) { final String testResourcesOutputPath; - if (Files.exists(testResourcesOutputDir)) { + if (testResourcesOutputDir != null && Files.exists(testResourcesOutputDir)) { testResourcesOutputPath = testResourcesOutputDir.toString(); if (!Files.exists(testClassesDir)) { // currently classesDir can't be null and is expected to exist diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index c7ad440963b..17ecf361f7e 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -43,6 +43,7 @@ import io.quarkus.bootstrap.model.gradle.ModelParameter; import io.quarkus.bootstrap.model.gradle.impl.ModelParameterImpl; import io.quarkus.bootstrap.resolver.AppModelResolverException; +import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.bootstrap.workspace.DefaultArtifactSources; import io.quarkus.bootstrap.workspace.DefaultSourceDir; import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; @@ -139,10 +140,10 @@ public static ResolvedDependency getProjectArtifact(Project project, LaunchMode .setBuildFile(project.getBuildFile().toPath()); initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME), - SourceSet.MAIN_SOURCE_SET_NAME, ""); - if (mode.equals(LaunchMode.TEST)) { + SourceSet.MAIN_SOURCE_SET_NAME, ArtifactSources.MAIN); + if (mode.equals(LaunchMode.TEST) || mode.equals(LaunchMode.DEVELOPMENT)) { initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME), - SourceSet.TEST_SOURCE_SET_NAME, "tests"); + SourceSet.TEST_SOURCE_SET_NAME, ArtifactSources.TEST); } final PathList.Builder paths = PathList.builder(); @@ -553,11 +554,6 @@ private void addSubstitutedProject(PathList.Builder paths, File projectFile) { } } - private static byte setFlag(byte flags, byte flag) { - flags |= flag; - return flags; - } - private static boolean isFlagOn(byte walkingFlags, byte flag) { return (walkingFlags & flag) > 0; } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusMavenWorkspaceBuilder.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusMavenWorkspaceBuilder.java index 8cc651d413f..80fa1f1e896 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusMavenWorkspaceBuilder.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusMavenWorkspaceBuilder.java @@ -9,9 +9,9 @@ import org.apache.maven.project.MavenProject; import io.quarkus.bootstrap.model.ApplicationModelBuilder; +import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.bootstrap.workspace.DefaultArtifactSources; import io.quarkus.bootstrap.workspace.DefaultSourceDir; -import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; import io.quarkus.bootstrap.workspace.SourceDir; import io.quarkus.bootstrap.workspace.WorkspaceModule; import io.quarkus.bootstrap.workspace.WorkspaceModuleId; @@ -38,7 +38,7 @@ static WorkspaceModule toProjectModule(MavenProject project) { resources.add(new DefaultSourceDir(Path.of(r.getDirectory()), r.getTargetPath() == null ? classesDir : Path.of(r.getTargetPath()))); } - moduleBuilder.addArtifactSources(new DefaultArtifactSources(DefaultWorkspaceModule.MAIN, sources, resources)); + moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.MAIN, sources, resources)); final Path testClassesDir = Path.of(build.getTestOutputDirectory()); final List<SourceDir> testSources = new ArrayList<>(project.getCompileSourceRoots().size()); @@ -48,7 +48,7 @@ static WorkspaceModule toProjectModule(MavenProject project) { testResources.add(new DefaultSourceDir(Path.of(r.getDirectory()), r.getTargetPath() == null ? testClassesDir : Path.of(r.getTargetPath()))); } - moduleBuilder.addArtifactSources(new DefaultArtifactSources(DefaultWorkspaceModule.TEST, testSources, testResources)); + moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.TEST, testSources, testResources)); moduleBuilder.setBuildFile(project.getFile().toPath()); diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/ArtifactSources.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/ArtifactSources.java index 5091476bba7..f4016b2dd50 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/ArtifactSources.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/ArtifactSources.java @@ -9,12 +9,15 @@ public interface ArtifactSources { + String MAIN = ""; + String TEST = "tests"; + static ArtifactSources main(SourceDir sources, SourceDir resources) { - return new DefaultArtifactSources(DefaultWorkspaceModule.MAIN, List.of(sources), List.of(resources)); + return new DefaultArtifactSources(MAIN, List.of(sources), List.of(resources)); } static ArtifactSources test(SourceDir sources, SourceDir resources) { - return new DefaultArtifactSources(DefaultWorkspaceModule.TEST, List.of(sources), List.of(resources)); + return new DefaultArtifactSources(TEST, List.of(sources), List.of(resources)); } String getClassifier(); diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/DefaultWorkspaceModule.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/DefaultWorkspaceModule.java index e7ec6096fdd..5a530b56126 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/DefaultWorkspaceModule.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/DefaultWorkspaceModule.java @@ -17,9 +17,6 @@ public class DefaultWorkspaceModule implements WorkspaceModule, Serializable { private static final long serialVersionUID = 6906903256002107806L; - public static final String MAIN = ""; - public static final String TEST = "tests"; - public static Builder builder() { return new DefaultWorkspaceModule().new Builder(); } @@ -91,12 +88,12 @@ public Builder addArtifactSources(ArtifactSources sources) { @Override public boolean hasMainSources() { - return DefaultWorkspaceModule.this.sourcesSets.containsKey(DefaultWorkspaceModule.MAIN); + return DefaultWorkspaceModule.this.sourcesSets.containsKey(ArtifactSources.MAIN); } @Override public boolean hasTestSources() { - return DefaultWorkspaceModule.this.sourcesSets.containsKey(DefaultWorkspaceModule.TEST); + return DefaultWorkspaceModule.this.sourcesSets.containsKey(ArtifactSources.TEST); } @Override diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/WorkspaceModule.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/WorkspaceModule.java index efe2a69638d..4e7ebda086f 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/WorkspaceModule.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/WorkspaceModule.java @@ -28,19 +28,19 @@ static Mutable builder() { ArtifactSources getSources(String classifier); default boolean hasMainSources() { - return hasSources(DefaultWorkspaceModule.MAIN); + return hasSources(ArtifactSources.MAIN); } default boolean hasTestSources() { - return hasSources(DefaultWorkspaceModule.TEST); + return hasSources(ArtifactSources.TEST); } default ArtifactSources getMainSources() { - return getSources(DefaultWorkspaceModule.MAIN); + return getSources(ArtifactSources.MAIN); } default ArtifactSources getTestSources() { - return getSources(DefaultWorkspaceModule.TEST); + return getSources(ArtifactSources.TEST); } PathCollection getBuildFiles(); diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java index 887447a01bc..25cd99bc9c5 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java @@ -2,9 +2,9 @@ import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; +import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.bootstrap.workspace.DefaultArtifactSources; import io.quarkus.bootstrap.workspace.DefaultSourceDir; -import io.quarkus.bootstrap.workspace.DefaultWorkspaceModule; import io.quarkus.bootstrap.workspace.SourceDir; import io.quarkus.bootstrap.workspace.WorkspaceModule; import io.quarkus.maven.dependency.ArtifactCoords; @@ -359,12 +359,12 @@ public WorkspaceModule toWorkspaceModule() { } if (!moduleBuilder.hasMainSources()) { - moduleBuilder.addArtifactSources(new DefaultArtifactSources(DefaultWorkspaceModule.MAIN, + moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.MAIN, Collections.singletonList(new DefaultSourceDir(getSourcesSourcesDir(), getClassesDir())), collectMainResources(null))); } if (!moduleBuilder.hasTestSources()) { - moduleBuilder.addArtifactSources(new DefaultArtifactSources(DefaultWorkspaceModule.TEST, + moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.TEST, Collections.singletonList( new DefaultSourceDir(getTestSourcesSourcesDir(), getTestClassesDir())), collectTestResources(null))); @@ -435,7 +435,7 @@ private List<String> collectChildValues(final Xpp3Dom container) { private static String getClassifier(Xpp3Dom dom, boolean test) { final Xpp3Dom classifier = dom.getChild("classifier"); - return classifier == null ? (test ? DefaultWorkspaceModule.TEST : DefaultWorkspaceModule.MAIN) : classifier.getValue(); + return classifier == null ? (test ? ArtifactSources.TEST : ArtifactSources.MAIN) : classifier.getValue(); } private Collection<SourceDir> collectMainResources(PathFilter filter) { diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/builder/QuarkusModelBuilderTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/builder/QuarkusModelBuilderTest.java index 5b2e2e81559..15d1cec60f3 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/builder/QuarkusModelBuilderTest.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/builder/QuarkusModelBuilderTest.java @@ -19,24 +19,48 @@ import io.quarkus.bootstrap.model.ApplicationModel; import io.quarkus.bootstrap.resolver.QuarkusGradleModelFactory; +import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.bootstrap.workspace.SourceDir; import io.quarkus.bootstrap.workspace.WorkspaceModule; +import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.PathTree; class QuarkusModelBuilderTest { @Test - public void shouldLoadSimpleModuleModel() throws URISyntaxException, IOException { + public void shouldLoadSimpleModuleTestModel() throws URISyntaxException, IOException { File projectDir = getResourcesProject("builder/simple-module-project"); final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(projectDir, "TEST"); assertNotNull(quarkusModel); assertNotNull(quarkusModel.getApplicationModule()); assertThat(quarkusModel.getWorkspaceModules()).isEmpty(); + + final ResolvedDependency appArtifact = quarkusModel.getAppArtifact(); + assertThat(appArtifact).isNotNull(); + assertThat(appArtifact.getWorkspaceModule()).isNotNull(); + final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources(); + assertThat(testSources).isNotNull(); + } + + @Test + public void shouldLoadSimpleModuleDevModel() throws URISyntaxException, IOException { + File projectDir = getResourcesProject("builder/simple-module-project"); + final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(projectDir, "DEVELOPMENT"); + + assertNotNull(quarkusModel); + assertNotNull(quarkusModel.getApplicationModule()); + assertThat(quarkusModel.getWorkspaceModules()).isEmpty(); + + final ResolvedDependency appArtifact = quarkusModel.getAppArtifact(); + assertThat(appArtifact).isNotNull(); + assertThat(appArtifact.getWorkspaceModule()).isNotNull(); + final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources(); + assertThat(testSources).isNotNull(); } @Test - public void shouldLoadMultiModuleModel() throws URISyntaxException, IOException { + public void shouldLoadMultiModuleTestModel() throws URISyntaxException, IOException { File projectDir = getResourcesProject("builder/multi-module-project"); final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(new File(projectDir, "application"), "TEST"); @@ -51,6 +75,53 @@ public void shouldLoadMultiModuleModel() throws URISyntaxException, IOException for (WorkspaceModule p : projectModules) { assertProjectModule(p, new File(projectDir, p.getId().getArtifactId()), false); } + + final ResolvedDependency appArtifact = quarkusModel.getAppArtifact(); + assertThat(appArtifact).isNotNull(); + assertThat(appArtifact.getWorkspaceModule()).isNotNull(); + final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources(); + assertThat(testSources).isNotNull(); + assertThat(testSources.getSourceDirs().size()).isEqualTo(1); + final SourceDir testSrcDir = testSources.getSourceDirs().iterator().next(); + assertThat(testSrcDir.getDir()) + .isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("java")); + assertThat(testSources.getResourceDirs().size()).isEqualTo(1); + final SourceDir testResourcesDir = testSources.getResourceDirs().iterator().next(); + assertThat(testResourcesDir.getDir()) + .isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("resources")); + } + + @Test + public void shouldLoadMultiModuleDevModel() throws URISyntaxException, IOException { + File projectDir = getResourcesProject("builder/multi-module-project"); + + final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(new File(projectDir, "application"), + "DEVELOPMENT"); + + assertNotNull(quarkusModel); + + assertProjectModule(quarkusModel.getApplicationModule(), + new File(projectDir, quarkusModel.getApplicationModule().getId().getArtifactId()), true); + + final Collection<WorkspaceModule> projectModules = quarkusModel.getWorkspaceModules(); + assertEquals(projectModules.size(), 1); + for (WorkspaceModule p : projectModules) { + assertProjectModule(p, new File(projectDir, p.getId().getArtifactId()), false); + } + + final ResolvedDependency appArtifact = quarkusModel.getAppArtifact(); + assertThat(appArtifact).isNotNull(); + assertThat(appArtifact.getWorkspaceModule()).isNotNull(); + final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources(); + assertThat(testSources).isNotNull(); + assertThat(testSources.getSourceDirs().size()).isEqualTo(1); + final SourceDir testSrcDir = testSources.getSourceDirs().iterator().next(); + assertThat(testSrcDir.getDir()) + .isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("java")); + assertThat(testSources.getResourceDirs().size()).isEqualTo(1); + final SourceDir testResourcesDir = testSources.getResourceDirs().iterator().next(); + assertThat(testResourcesDir.getDir()) + .isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("resources")); } private void assertProjectModule(WorkspaceModule projectModule, File projectDir, boolean withTests) {
['independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/ArtifactSources.java', 'integration-tests/gradle/src/test/java/io/quarkus/gradle/builder/QuarkusModelBuilderTest.java', 'independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalProject.java', 'devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java', 'independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/WorkspaceModule.java', 'devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java', 'devtools/maven/src/main/java/io/quarkus/maven/QuarkusMavenWorkspaceBuilder.java', 'independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/workspace/DefaultWorkspaceModule.java']
{'.java': 8}
8
8
0
0
8
19,849,132
3,843,067
504,751
4,862
3,437
603
50
7
745
122
211
41
0
0
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,491
quarkusio/quarkus/23881/23776
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23776
https://github.com/quarkusio/quarkus/pull/23881
https://github.com/quarkusio/quarkus/pull/23881
1
close
Running gradle quarkusDev fails in a multi-module Gradle project
### Describe the bug I am learning the tutorial: [GETTING STARTED WITH REACTIVE](https://quarkus.io/guides/getting-started-reactive) When I run `gradle :quarkus-reactive:quarkusDev` in a multi-module gradle project, I get an exception > Execution failed for task ':quarkus-reactive:compileJava'. > \\> Cannot change dependencies of dependency configuration ':quarkus-reactive:annotationProcessor' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration. When I comment out `implementation("io.quarkus:quarkus-hibernate-reactive-panache")` it works fine ### Expected behavior This Quarkus plugin should work fine in other submodules ### Actual behavior this Quarkus plugin doesn't seem to be able to execute `compileJava` task in submodule ### How to Reproduce? Here is my example code: [reproduce/quarkus at main · tabuyos/reproduce](https://github.com/tabuyos/reproduce/tree/main/quarkus) Execute the `gradle :quarkus-reactive:quarkusDev` task in the quarkus directory ### Output of `uname -a` or `ver` Microsoft Windows [version 10.0.19043.1466] ### Output of `java -version` openjdk version "16" 2021-03-16 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.0.2 ### Additional information _No response_
0bd2724d6876ed64ac3420abce5eec196cc20933
d52bc651cc877a8327f2f86c2c1cf973513bfac8
https://github.com/quarkusio/quarkus/compare/0bd2724d6876ed64ac3420abce5eec196cc20933...d52bc651cc877a8327f2f86c2c1cf973513bfac8
diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java index 049f5f9355d..8b6e31b5fee 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java @@ -70,10 +70,12 @@ public static void initConfigurations(Project project) { configContainer.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)); // enable the Panache annotation processor on the classpath, if it's found among the dependencies - configContainer.getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME).getIncoming() - .beforeResolve(annotationProcessors -> { - Set<ResolvedArtifact> compileClasspathArtifacts = configContainer - .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).getResolvedConfiguration() + configContainer.getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME) + .withDependencies(annotationProcessors -> { + Set<ResolvedArtifact> compileClasspathArtifacts = DependencyUtils + .duplicateConfiguration(project, configContainer + .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)) + .getResolvedConfiguration() .getResolvedArtifacts(); for (ResolvedArtifact artifact : compileClasspathArtifacts) { if ("quarkus-panache-common".equals(artifact.getName())
['devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/dependency/ApplicationDeploymentClasspathBuilder.java']
{'.java': 1}
1
1
0
0
1
19,909,463
3,854,288
506,118
4,869
829
132
10
1
1,472
176
385
50
2
0
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,484
quarkusio/quarkus/24028/23776
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23776
https://github.com/quarkusio/quarkus/pull/24028
https://github.com/quarkusio/quarkus/pull/24028
1
fix
Running gradle quarkusDev fails in a multi-module Gradle project
### Describe the bug I am learning the tutorial: [GETTING STARTED WITH REACTIVE](https://quarkus.io/guides/getting-started-reactive) When I run `gradle :quarkus-reactive:quarkusDev` in a multi-module gradle project, I get an exception > Execution failed for task ':quarkus-reactive:compileJava'. > \\> Cannot change dependencies of dependency configuration ':quarkus-reactive:annotationProcessor' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration. When I comment out `implementation("io.quarkus:quarkus-hibernate-reactive-panache")` it works fine ### Expected behavior This Quarkus plugin should work fine in other submodules ### Actual behavior this Quarkus plugin doesn't seem to be able to execute `compileJava` task in submodule ### How to Reproduce? Here is my example code: [reproduce/quarkus at main · tabuyos/reproduce](https://github.com/tabuyos/reproduce/tree/main/quarkus) Execute the `gradle :quarkus-reactive:quarkusDev` task in the quarkus directory ### Output of `uname -a` or `ver` Microsoft Windows [version 10.0.19043.1466] ### Output of `java -version` openjdk version "16" 2021-03-16 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.0.2 ### Additional information _No response_
a8243c313328641299e0b4ea0400afbae11b67c6
ec596dc0769c9aeb7bca3b3dc99de8acdde26a95
https://github.com/quarkusio/quarkus/compare/a8243c313328641299e0b4ea0400afbae11b67c6...ec596dc0769c9aeb7bca3b3dc99de8acdde26a95
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 55d857392b2..05cbf49b6a1 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -54,6 +54,7 @@ import io.quarkus.gradle.tasks.QuarkusTestNative; import io.quarkus.gradle.tasks.QuarkusUpdate; import io.quarkus.gradle.tooling.GradleApplicationModelBuilder; +import io.quarkus.gradle.tooling.dependency.DependencyUtils; import io.quarkus.gradle.tooling.dependency.ExtensionDependency; public class QuarkusPlugin implements Plugin<Project> { @@ -299,10 +300,12 @@ private void registerConditionalDependencies(Project project) { configName).declareConditionalDependencies(); deploymentClasspathBuilder.createBuildClasspath(testExtensions, configName); }); - project.getConfigurations().getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME).getIncoming() - .beforeResolve(annotationProcessors -> { - Set<ResolvedArtifact> compileClasspathArtifacts = project.getConfigurations() - .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).getResolvedConfiguration() + project.getConfigurations().getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME) + .withDependencies(annotationProcessors -> { + Set<ResolvedArtifact> compileClasspathArtifacts = DependencyUtils + .duplicateConfiguration(project, project.getConfigurations() + .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)) + .getResolvedConfiguration() .getResolvedArtifacts(); // enable the Panache annotation processor on the classpath, if it's found among the dependencies
['devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java']
{'.java': 1}
1
1
0
0
1
19,698,225
3,814,315
500,978
4,827
939
151
11
1
1,472
176
385
50
2
0
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,490
quarkusio/quarkus/23959/23937
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23937
https://github.com/quarkusio/quarkus/pull/23959
https://github.com/quarkusio/quarkus/pull/23959
1
fixes
quarkus:test Re-run failed tests does not run failed ParameterizedTest
### Describe the bug In Continuous Testing mode tests that use `@ParameterizedTest` with `@ValueSource` like this: ``` @QuarkusTest public class GreetingResourceTest { @ParameterizedTest @ValueSource(strings = {"fail"}) public void parametrizedTest(String input) { assertEquals("ok", input); } } ``` are not rerun when a "Re-run failed tests" command is issued, but `All tests are now passing` is shown instead. ### Expected behavior ParameterizedTest tests that fail should be rerun ### Actual behavior ParameterizedTest tests that fail are declared as passing without having been rerurn ### How to Reproduce? Declare a failing ParameterizedTest test and try to rerun it in Continuous Testing ### Output of `uname -a` or `ver` 5.13.0-30-generic #33-Ubuntu SMP Fri Feb 4 17:03:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` Java version: 11.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 ### GraalVM version (if different from Java) NA ### Quarkus version or git rev 2.7.2 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) ### Additional information _No response_
96c1fbdad8ef1194d9b4b69042f00ddedb133c2f
d0fb15ba0d7491d3628458a1183830b9f9ca50f0
https://github.com/quarkusio/quarkus/compare/96c1fbdad8ef1194d9b4b69042f00ddedb133c2f...d0fb15ba0d7491d3628458a1183830b9f9ca50f0
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java index 85da540feb5..2e965d77246 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java @@ -67,11 +67,6 @@ public void runComplete(TestRunResults testRunResults) { }); } - @Override - public void noTests(TestRunResults results) { - runComplete(results); - } - @Override public void runAborted() { ContinuousTestingSharedStateManager.setInProgress(false); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java index 1bce4eaedfd..a43da33c5d4 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java @@ -178,21 +178,6 @@ public FilterResult apply(TestDescriptor testDescriptor) { LauncherDiscoveryRequest request = launchBuilder .build(); TestPlan testPlan = launcher.discover(request); - if (!testPlan.containsTests()) { - testState.pruneDeletedTests(allDiscoveredIds, dynamicIds); - //nothing to see here - for (TestRunListener i : listeners) { - i.noTests(new TestRunResults(runId, classScanResult, classScanResult == null, start, - System.currentTimeMillis(), toResultsMap(testState.getCurrentResults()))); - } - quarkusTestClasses.close(); - return new Runnable() { - @Override - public void run() { - - } - }; - } long toRun = testPlan.countTestIdentifiers(TestIdentifier::isTest); for (TestRunListener listener : listeners) { listener.runStarted(toRun); @@ -226,6 +211,7 @@ public void quarkusStarting() { }); Map<String, Map<UniqueId, TestResult>> resultsByClass = new HashMap<>(); + AtomicReference<TestIdentifier> currentNonDynamicTest = new AtomicReference<>(); launcher.execute(testPlan, new TestExecutionListener() { @Override @@ -233,6 +219,10 @@ public void executionStarted(TestIdentifier testIdentifier) { if (aborted) { return; } + boolean dynamic = dynamicIds.contains(UniqueId.parse(testIdentifier.getUniqueId())); + if (!dynamic) { + currentNonDynamicTest.set(testIdentifier); + } startTimes.put(testIdentifier, System.currentTimeMillis()); String testClassName = ""; Class<?> testClass = getTestClassFromSource(testIdentifier.getSource()); @@ -260,7 +250,7 @@ public void executionSkipped(TestIdentifier testIdentifier, String reason) { s -> new HashMap<>()); TestResult result = new TestResult(displayName, testClass.getName(), id, TestExecutionResult.aborted(null), - logHandler.captureOutput(), testIdentifier.isTest(), runId, 0); + logHandler.captureOutput(), testIdentifier.isTest(), runId, 0, true); results.put(id, result); if (result.isTest()) { for (TestRunListener listener : listeners) { @@ -274,6 +264,9 @@ public void executionSkipped(TestIdentifier testIdentifier, String reason) { @Override public void dynamicTestRegistered(TestIdentifier testIdentifier) { dynamicIds.add(UniqueId.parse(testIdentifier.getUniqueId())); + for (TestRunListener listener : listeners) { + listener.dynamicTestRegistered(testIdentifier); + } } @Override @@ -282,6 +275,7 @@ public void executionFinished(TestIdentifier testIdentifier, if (aborted) { return; } + boolean dynamic = dynamicIds.contains(UniqueId.parse(testIdentifier.getUniqueId())); Set<String> touched = touchedClasses.pop(); Class<?> testClass = getTestClassFromSource(testIdentifier.getSource()); String displayName = getDisplayNameFromIdentifier(testIdentifier, testClass); @@ -306,18 +300,33 @@ public void executionFinished(TestIdentifier testIdentifier, testClassUsages.updateTestData(testClassName, id, touched); } } - Map<UniqueId, TestResult> results = resultsByClass.computeIfAbsent(testClassName, s -> new HashMap<>()); TestResult result = new TestResult(displayName, testClassName, id, testExecutionResult, logHandler.captureOutput(), testIdentifier.isTest(), runId, - System.currentTimeMillis() - startTimes.get(testIdentifier)); - results.put(id, result); + System.currentTimeMillis() - startTimes.get(testIdentifier), true); + if (!results.containsKey(id)) { + //if a child has failed we may have already marked the parent failed + results.put(id, result); + } if (result.isTest()) { for (TestRunListener listener : listeners) { listener.testComplete(result); } + if (dynamic && testExecutionResult.getStatus() == TestExecutionResult.Status.FAILED) { + //if it is dynamic we fail the parent as well for re-runs + + RuntimeException failure = new RuntimeException("A child test failed"); + failure.setStackTrace(new StackTraceElement[0]); + results.put(id, + new TestResult(currentNonDynamicTest.get().getDisplayName(), + result.getTestClass(), + currentNonDynamicTest.get().getUniqueIdObject(), + TestExecutionResult.failed(failure), List.of(), false, runId, 0, + false)); + results.put(UniqueId.parse(currentNonDynamicTest.get().getUniqueId()), result); + } } else if (testExecutionResult.getStatus() == TestExecutionResult.Status.FAILED) { //if a parent fails we fail the children Set<TestIdentifier> children = testPlan.getChildren(testIdentifier); @@ -327,7 +336,7 @@ public void executionFinished(TestIdentifier testIdentifier, childId, testExecutionResult, logHandler.captureOutput(), child.isTest(), runId, - System.currentTimeMillis() - startTimes.get(testIdentifier)); + System.currentTimeMillis() - startTimes.get(testIdentifier), true); results.put(childId, result); if (child.isTest()) { for (TestRunListener listener : listeners) { diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConsoleHandler.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConsoleHandler.java index 764b66944c3..9225b2b8fc4 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConsoleHandler.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConsoleHandler.java @@ -220,9 +220,11 @@ public void runComplete(TestRunResults results) { log.error(statusHeader("TEST REPORT #" + results.getId())); for (Map.Entry<String, TestClassResult> classEntry : results.getCurrentFailing().entrySet()) { for (TestResult test : classEntry.getValue().getFailing()) { - log.error( - RED + "Test " + test.getDisplayName() + " failed \\n" + RESET, - test.getTestExecutionResult().getThrowable().get()); + if (test.isReportable()) { + log.error( + RED + "Test " + test.getDisplayName() + " failed \\n" + RESET, + test.getTestExecutionResult().getThrowable().get()); + } } } log.error( @@ -244,11 +246,6 @@ public void runComplete(TestRunResults results) { } } - @Override - public void noTests(TestRunResults results) { - runComplete(results); - } - @Override public void runAborted() { firstRun = false; @@ -268,6 +265,11 @@ public void testStarted(TestIdentifier testIdentifier, String className) { } testsStatusOutput.setMessage(status); } + + @Override + public void dynamicTestRegistered(TestIdentifier testIdentifier) { + totalNoTests.incrementAndGet(); + } }); } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestResult.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestResult.java index 44e278c986e..4250d332492 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestResult.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestResult.java @@ -18,9 +18,10 @@ public class TestResult { final long runId; final long time; final List<Throwable> problems; + final boolean reportable; public TestResult(String displayName, String testClass, UniqueId uniqueId, TestExecutionResult testExecutionResult, - List<String> logOutput, boolean test, long runId, long time) { + List<String> logOutput, boolean test, long runId, long time, boolean reportable) { this.displayName = displayName; this.testClass = testClass; this.uniqueId = uniqueId; @@ -29,6 +30,7 @@ public TestResult(String displayName, String testClass, UniqueId uniqueId, TestE this.test = test; this.runId = runId; this.time = time; + this.reportable = reportable; List<Throwable> problems = new ArrayList<>(); if (testExecutionResult.getThrowable().isPresent()) { Throwable t = testExecutionResult.getThrowable().get(); @@ -75,4 +77,8 @@ public long getTime() { public List<Throwable> getProblems() { return problems; } + + public boolean isReportable() { + return reportable; + } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunListener.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunListener.java index 5a817d18576..0f3e8278d40 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunListener.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunListener.java @@ -24,7 +24,7 @@ default void testStarted(TestIdentifier testIdentifier, String className) { } - default void noTests(TestRunResults results) { + default void dynamicTestRegistered(TestIdentifier testIdentifier) { } } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java index 1ac18ade9c3..01d76c06184 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java @@ -374,20 +374,8 @@ public void testStarted(TestIdentifier testIdentifier, String className) { } } - @Override - public void noTests(TestRunResults results) { - allResults.add(results); - runStarted(0); - } })); } - if (testCount.get() == 0) { - TestRunResults results = new TestRunResults(runId, classScanResult, classScanResult == null, start, - System.currentTimeMillis(), Collections.emptyMap()); - for (var i : testRunListeners) { - i.noTests(results); - } - } for (var i : testRunListeners) { i.runStarted(testCount.get()); } diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java index 3a0ac541a62..5d8ee7d0ce9 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java @@ -146,6 +146,7 @@ DevConsoleRouteBuildItem runAllTests(LaunchModeBuildItem launchModeBuildItem) { @Override public void handle(RoutingContext event) { ts.get().runAllTests(); + event.response().setStatusCode(204).end(); } }); } @@ -178,6 +179,7 @@ DevConsoleRouteBuildItem runFailedTests(LaunchModeBuildItem launchModeBuildItem) @Override public void handle(RoutingContext event) { ts.get().runFailedTests(); + event.response().setStatusCode(204).end(); } }); } @@ -192,6 +194,7 @@ DevConsoleRouteBuildItem printfailures(LaunchModeBuildItem launchModeBuildItem) @Override public void handle(RoutingContext event) { ts.get().printFullResults(); + event.response().setStatusCode(204).end(); } }); } @@ -235,6 +238,7 @@ DevConsoleRouteBuildItem forceRestart(LaunchModeBuildItem launchModeBuildItem) { @Override public void handle(RoutingContext event) { RuntimeUpdatesProcessor.INSTANCE.doScan(true, true); + event.response().setStatusCode(204).end(); } }); } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java index 57c14bc6694..1c85ca3dd13 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java @@ -13,6 +13,7 @@ import io.quarkus.test.ContinuousTestingTestUtils; import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; +import io.restassured.RestAssured; public class TestParameterizedTestCase { @@ -42,6 +43,13 @@ public void testParameterizedTests() throws InterruptedException { Assertions.assertEquals(4L, ts.getTestsPassed()); Assertions.assertEquals(0L, ts.getTestsSkipped()); + RestAssured.post("q/dev/io.quarkus.quarkus-vertx-http/tests/runfailed"); + + ts = utils.waitForNextCompletion(); + + Assertions.assertEquals(1L, ts.getTestsFailed()); + Assertions.assertEquals(3L, ts.getTestsPassed()); //they are all re-run + Assertions.assertEquals(0L, ts.getTestsSkipped()); test.modifyTestSourceFile(ParamET.class, new Function<String, String>() { @Override public String apply(String s) {
['core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestRunListener.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java', 'extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/testing/JunitTestRunner.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestSupport.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestResult.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestConsoleHandler.java']
{'.java': 8}
8
8
0
0
8
19,961,254
3,864,309
507,372
4,878
5,449
792
94
6
1,293
165
352
55
0
1
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,489
quarkusio/quarkus/23973/23813
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23813
https://github.com/quarkusio/quarkus/pull/23973
https://github.com/quarkusio/quarkus/pull/23973
1
fixes
@MongoEntity with database parameter does not detect database when using mongo panache
### Describe the bug The following is my code structure: ``` public interface BaseMongoRepository<T extends BaseMongoEntity> extends ReactivePanacheMongoRepository<T> {} public interface UserRepository extends BaseMongoRepository<UserEntity> {} public class BaseMongoRepositoryImpl<T extends BaseMongoEntity> implements BaseMongoRepository<T> {} public class UserRepositoryImpl extends BaseMongoRepositoryImpl<UserEntity> implements UserRepository @MongoEntity(database = "userDB", collection= "users") public class User {} ``` When I'm running this code, mongo panache fails with IllegalArgumentException: `The database attribute was not set for the @MongoEntity annotation and neither was the database property configured for the default Mongo Client (via 'quarkus.mongodb.database').` If I pass the default client using `quarkus.mongodb.database`, all my collections are created in the same database. However, the collections args for @MongoEntity works fine. ### Expected behavior When passing @MongoEntity(database = "userDB"), the collection should be created in the userDB database. ### Actual behavior If no default database is passed in application.properties, an error is thrown. Else the collection is created in the default database. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64 ### Output of `java -version` openjdk version "17.0.2" 2022-01-18 OpenJDK Runtime Environment Homebrew (build 17.0.2+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.2+0, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.0 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Java version: 17.0.2, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home Default locale: en_IN, platform encoding: UTF-8 OS name: "mac os x", version: "12.0.1", arch: "aarch64", family: "mac" ### Additional information _No response_
5919bee6710783d5630d6144ba0d5ff15360b87f
0fd7b0d370830b357135511ba76d7795852d2e05
https://github.com/quarkusio/quarkus/compare/5919bee6710783d5630d6144ba0d5ff15360b87f...0fd7b0d370830b357135511ba76d7795852d2e05
diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java index 112cb255871..bf433a4dd30 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java @@ -311,6 +311,9 @@ private ReactiveMongoCollection mongoCollection(Object entity) { private ReactiveMongoDatabase mongoDatabase(MongoEntity mongoEntity) { ReactiveMongoClient mongoClient = clientFromArc(mongoEntity, ReactiveMongoClient.class, true); + if (mongoEntity != null && !mongoEntity.database().isEmpty()) { + return mongoClient.getDatabase(mongoEntity.database()); + } String databaseName = getDefaultDatabaseName(mongoEntity); return mongoClient.getDatabase(databaseName); }
['extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java']
{'.java': 1}
1
1
0
0
1
19,959,007
3,863,582
507,283
4,878
152
29
3
1
2,198
256
533
65
0
1
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,488
quarkusio/quarkus/23996/23949
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23949
https://github.com/quarkusio/quarkus/pull/23996
https://github.com/quarkusio/quarkus/pull/23996
1
closes
NullPointerException in Resteasy Reactive Client due to no Configuration
### Describe the bug When using classic jaxrs ClientBuilder with implementation from Resteasy Reactive Client jars, the configuration is not initialized. ### Expected behavior ClientRequestFilter(s) successfully registered with classic ClientBuilder ### Actual behavior NullPointerException thrown from ```org.jboss.resteasy.reactive.client.impl.ClientBuilderImpl, line 313``` ### How to Reproduce? With dependencies: ```xml io.quarkus.resteasy.reactive:resteasy-reactive-common:jar:2.7.1.Final org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.1.Final ``` Use the following code: ```java import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.ClientRequestFilter; public static void main(String args[]) { ClientBuilder clientBuilder = ClientBuilder.newBuilder(); for (ClientRequestFilter filter : filters) { // following line has NPE clientBuilder.register(filter); } } ``` ### Output of `uname -a` or `ver` Darwin C02YD0B0JG5J.corp.proofpoint.com 20.6.0 Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:42 PST 2022; root:xnu-7195.141.19~2/RELEASE_X86_64 x86_64 ### Output of `java -version` openjdk version "11.0.12" 2021-07-20 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) ### Additional information _No response_
e68c24fbfef0a0d92c0f100dbed5f5bba073b46a
b520c71d2e6128fa76067d4c64312ceddd6c7446
https://github.com/quarkusio/quarkus/compare/e68c24fbfef0a0d92c0f100dbed5f5bba073b46a...b520c71d2e6128fa76067d4c64312ceddd6c7446
diff --git a/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/AsyncRestClientFilterTestCase.java b/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/AsyncRestClientFilterTestCase.java index a8baa6b800d..d4389344a49 100644 --- a/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/AsyncRestClientFilterTestCase.java +++ b/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/AsyncRestClientFilterTestCase.java @@ -47,8 +47,10 @@ public class AsyncRestClientFilterTestCase { @BeforeEach public void before() { - client = ClientBuilder.newClient() + // register one filter with builder to test configuration inheritance + client = ClientBuilder.newBuilder() .register(SyncClientRequestFilter.class) + .build() .register(AsyncClientRequestFilter.class) .register(AsyncClientResponseFilter.class); } diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java index 6ca8e156ec7..b56f7b52b0d 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java @@ -20,6 +20,7 @@ import java.util.regex.Pattern; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; +import javax.ws.rs.RuntimeType; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Configuration; import org.jboss.logging.Logger; @@ -62,6 +63,10 @@ public class ClientBuilderImpl extends ClientBuilder { private ClientLogger clientLogger = new DefaultClientLogger(); private String userAgent = "Resteasy Reactive Client"; + public ClientBuilderImpl() { + configuration = new ConfigurationImpl(RuntimeType.CLIENT); + } + @Override public ClientBuilder withConfig(Configuration config) { this.configuration = new ConfigurationImpl(config);
['independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java', 'extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/test/java/io/quarkus/jaxrs/client/reactive/deployment/test/AsyncRestClientFilterTestCase.java']
{'.java': 2}
2
2
0
0
2
19,959,485
3,863,696
507,294
4,878
143
26
5
1
1,531
152
422
62
0
3
1970-01-01T00:27:25
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,487
quarkusio/quarkus/24002/23966
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23966
https://github.com/quarkusio/quarkus/pull/24002
https://github.com/quarkusio/quarkus/pull/24002
1
fixes
Rest Client sets own User-Agent header even if user specifies a different one
### Describe the bug This issue is based on the Zulip chat: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/io.2Evertx.2Ecore.2Ehttp.2Eimpl.2ENoStackTraceTimeoutException We have a reactive rest client where we set a custom `User-Agent` header. The user agent needs to be this specific value for the API to accept our request. ``` @RegisterRestClient(configKey = "xxxxx") @Produces(MediaType.APPLICATION_JSON) interface GatewayApi { @GET @Path("zzzzz") suspend fun getUser( @HeaderParam("Accept-Language") acceptLanguage: String, @HeaderParam("x-request-tracing-id") traceId: String, @HeaderParam("x-api-key") apiKey: String, @HeaderParam("User-Agent") userAgent: String ): Response } ``` Unfortunately, it seems that Quarkus versions >= 2.7.0 add an own `User-Agent` header value with the value: `Resteasy Reactive Client`. This value is always added, no matter if we set our own `User-Agent`. So when we make a request the `User-Agent` header has the values: `[Resteasy Reactive Client, Our_Custom_Header_Value]` compared to versions <= 2.6.3 where the `User-Agent` values is `[Our_Custom_Header_Value]`. A workaround is to add a custom ClientHeadersFactory and register it to above interface. For example: ``` class GatewayHeadersFactory: ClientHeadersFactory { override fun update(incomingHeaders: MultivaluedMap<String, String>?, clientOutgoingHeaders: MultivaluedMap<String, String>?): MultivaluedMap<String, String> { val clientHeaders = MultivaluedHashMap<String, String>() "Our_Custom_Header_Value".addHeader("User-Agent", clientHeaders) return clientHeaders } } ``` ### Expected behavior The rest client should only add its own `User-Agent` header when we do not specify our own header. This should apply when the header is set with the `@HeaderParam` annotation in the method as well as when using `@ClientHeaderParam` to set a `User-Agent` header. ### Actual behavior The rest client always adds it's own User-Agent header. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
4e56d41e4e00cdabda79ad9c978ed73f7d6bbac3
ec4e26752d9c75b6a3187fb21dbd62539487d897
https://github.com/quarkusio/quarkus/compare/4e56d41e4e00cdabda79ad9c978ed73f7d6bbac3...ec4e26752d9c75b6a3187fb21dbd62539487d897
diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/headers/UserAgentTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/headers/UserAgentTest.java index 3e2c924ac9a..d5341d80e33 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/headers/UserAgentTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/headers/UserAgentTest.java @@ -30,6 +30,12 @@ void testHeadersWithSubresource() { assertThat(client.call()).isEqualTo("Resteasy Reactive Client"); } + @Test + void testHeaderOverride() { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + assertThat(client.callWithUserAgent("custom-agent")).isEqualTo("custom-agent"); + } + @Path("/") @ApplicationScoped public static class Resource { @@ -44,6 +50,10 @@ public interface Client { @Path("/") @GET String call(); + + @Path("/") + @GET + String callWithUserAgent(@HeaderParam("User-AgenT") String userAgent); } } diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java index 5126b4ab0c4..f9f25cf593c 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java @@ -51,9 +51,6 @@ public InvocationBuilderImpl(URI uri, ClientImpl restClient, HttpClient httpClie this.httpClient = httpClient; this.target = target; this.requestSpec = new RequestSpec(configuration); - if (restClient.getUserAgent() != null && !restClient.getUserAgent().isEmpty()) { - this.requestSpec.headers.header(HttpHeaders.USER_AGENT, restClient.getUserAgent()); - } this.configuration = configuration; this.handlerChain = handlerChain; this.requestContext = requestContext; @@ -67,11 +64,13 @@ public InvocationBuilderImpl(URI uri, ClientImpl restClient, HttpClient httpClie @Override public Invocation build(String method) { + setUserAgentIfNotSet(); return new InvocationImpl(method, async(), null); } @Override public Invocation build(String method, Entity<?> entity) { + setUserAgentIfNotSet(); return new InvocationImpl(method, async(), entity); } @@ -97,6 +96,7 @@ public Invocation buildPut(Entity<?> entity) { @Override public AsyncInvokerImpl async() { + setUserAgentIfNotSet(); return new AsyncInvokerImpl(restClient, httpClient, uri, requestSpec, configuration, properties, handlerChain, requestContext); } @@ -175,6 +175,7 @@ public CompletionStageRxInvoker rx() { @Override public <T extends RxInvoker> T rx(Class<T> clazz) { + setUserAgentIfNotSet(); if (clazz == MultiInvoker.class) { return (T) new MultiInvoker(this); } else if (clazz == UniInvoker.class) { @@ -189,6 +190,13 @@ public <T extends RxInvoker> T rx(Class<T> clazz) { return null; } + private void setUserAgentIfNotSet() { + if (!requestSpec.headers.getHeaders().containsKey(HttpHeaders.USER_AGENT) + && restClient.getUserAgent() != null && !restClient.getUserAgent().isEmpty()) { + this.requestSpec.headers.header(HttpHeaders.USER_AGENT, restClient.getUserAgent()); + } + } + @Override public Response get() { return unwrap(async().get());
['independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/InvocationBuilderImpl.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/headers/UserAgentTest.java']
{'.java': 2}
2
2
0
0
2
19,959,485
3,863,696
507,294
4,878
669
131
14
1
2,448
291
590
70
1
2
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,486
quarkusio/quarkus/24003/23978
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23978
https://github.com/quarkusio/quarkus/pull/24003
https://github.com/quarkusio/quarkus/pull/24003
1
fixes
Kafka dev services can not be used with redpanda images from outside of DockerHub
### Describe the bug Devmode for Kafka explicitly requires, that images should be from vectorized/redpanda dockerhub repository. Because of that, even if the very same is copied to other docker repository, it can be used. The reproducer uses image `quay.io/quarkusqeteam/redpanda` which was copied with docker pull/push from DockerHub to quay.io ### Expected behavior Kafka dev services should work with redpanda images from any repository ### Actual behavior Error: `IllegalArgumentException: Only vectorized/redpanda images are supported` ### How to Reproduce? 1. `git clone -b reproducer/redpanda git@github.com:fedinskiy/quarkus-test-suite.git` 2. `cd super-size/many-extensions` 3. `mvn clean validate compile test package verify -Dall-modules -DexcludedGroups=fips-incompatible -Dit.test=DevModeManyExtensionsIT` ### Output of `uname -a` or `ver` 5.16.7-200.fc35.x86_64 ### Output of `java -version` 11.0.12, vendor: GraalVM Community ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.2.Final, 2.2.5.Final, 3bda8b29565261d2dc188f8feda6d027eb085d6f ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) ### Additional information _No response_
4e56d41e4e00cdabda79ad9c978ed73f7d6bbac3
eb221b0448485cb3c193c14d053d2b9903b6c1b0
https://github.com/quarkusio/quarkus/compare/4e56d41e4e00cdabda79ad9c978ed73f7d6bbac3...eb221b0448485cb3c193c14d053d2b9903b6c1b0
diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java index 2ce80507699..6e603d381bd 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java @@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Supplier; -import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.kafka.clients.admin.AdminClient; @@ -53,9 +52,6 @@ public class DevServicesKafkaProcessor { private static final Logger log = Logger.getLogger(DevServicesKafkaProcessor.class); private static final String KAFKA_BOOTSTRAP_SERVERS = "kafka.bootstrap.servers"; - private static final Pattern STRIMZI_IMAGE_NAME_PATTERN = Pattern - .compile("(^.*test-container):(\\\\d+\\\\.\\\\d+\\\\.\\\\d+|latest)-kafka-(.*)$"); - /** * Label to add to shared Dev Service for Kafka running in containers. * This allows other applications to discover the running service and use it instead of starting a new instance. diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java index d7d9881d1c7..02f3179f02a 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java @@ -39,15 +39,11 @@ final class RedPandaKafkaContainer extends GenericContainer<RedPandaKafkaContain } // For redpanda, we need to start the broker - see https://vectorized.io/docs/quick-start-docker/ - if (dockerImageName.getRepository().equals("vectorized/redpanda")) { - withCreateContainerCmdModifier(cmd -> { - cmd.withEntrypoint("sh"); - }); - withCommand("-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT); - waitingFor(Wait.forLogMessage(".*Started Kafka API server.*", 1)); - } else { - throw new IllegalArgumentException("Only vectorized/redpanda images are supported"); - } + withCreateContainerCmdModifier(cmd -> { + cmd.withEntrypoint("sh"); + }); + withCommand("-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT); + waitingFor(Wait.forLogMessage(".*Started Kafka API server.*", 1)); } @Override
['extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java', 'extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java']
{'.java': 2}
2
2
0
0
2
19,959,485
3,863,696
507,294
4,878
985
237
18
2
1,300
153
376
45
0
0
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,485
quarkusio/quarkus/24014/23986
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23986
https://github.com/quarkusio/quarkus/pull/24014
https://github.com/quarkusio/quarkus/pull/24014
1
fixes
Quarkus Multipart not working for multi layer applications
### Describe the bug We have an export-import microservice design that exports and imports data, one microservice component per family of entities. This microservice design imports & exports using rest reactive design. And it works perfectly without any issues. **Requirement** But now we have a different requirement. We have a module that provides the user a page to select the list of microservices that needs to be exported and/or imported. After selecting multiple microservices and clicking on "Export" button, a zip file will be generated that contains the exported file of all the microservices selected on the page. **Design** Since all the components already have the export import function, all I have to do is created a separate service that will do the following. - Take a request that comprises the selected component names. - Iterate through the component names, and build a Unijoin list to call the export import function of all the microservices in parallel. `UniJoin.Builder<CommonAccountTypeXMLDto> builder = Uni.join().builder(); builder.joinAll().andFailFast();` - Collect the files into a zip file, and return the zip file. **Issue** The service uses Rest Reactive Client to connect to the individual microservices. So I use the 'Rest Reactive Client with Multipart' approach. But it gives an error. `022-02-25 16:13:11,174 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: javax.ws.rs.ProcessingException: Response could not be mapped to type class com.company.services.exim.client.DownloadFormData` ### Expected behavior A Quarkus microservice using Rest Reactive Client fails with an exception when it connects with a Quarkus Rest Reactive Service. Though the requirement is for Multipart bodies, it fails for normal bodies too. In summary, a Quarkus service calling another quarkus service using Rest Reactive Client fails. ### Actual behavior Quarkus Rest Reactive Client should be able to connect to a Quarkus Rest Service. ### How to Reproduce? Steps to reproduce the issue: 1. Create a Restful Reactive service with two methods, one returning a normal class, while other returns Multipart. 2. Create a separate service with a Restful Reactive Client having the same two methods as defined in Step 1. 3. Call the service through postman. Error occurs: `022-02-25 16:13:11,174 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: javax.ws.rs.ProcessingException: **** could not be mapped to type class ***.***.***.*******` ### Output of `uname -a` or `ver` Microsoft Windows [Version 10.0.19044.1526] ### Output of `java -version` Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.5.0.FINAL ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739) ### Additional information [Error.txt](https://github.com/quarkusio/quarkus/files/8145574/Error.txt) [raj-quarkus-multipart.zip](https://github.com/quarkusio/quarkus/files/8145575/raj-quarkus-multipart.zip) **Sample** For the sake of simplicity, I am attaching a single project that contains a server project and a client project. - Server package returns a multipart object when export is clicked. - Client package contains the Rest Reactive Client to call the server project. Also attached is the error text. You can run the project and reproduce the same error. Use postman to call the function. Please help find the actual cause of the error. Thanks!
b4e0afddeebf0f536412ddc45cf886d9a13471d6
8efb2f76a0ae1e4d7d7a149cb1ff0c5e2888faef
https://github.com/quarkusio/quarkus/compare/b4e0afddeebf0f536412ddc45cf886d9a13471d6...8efb2f76a0ae1e4d7d7a149cb1ff0c5e2888faef
diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartResponseTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartResponseTest.java index 4c73daa59c3..ab9c432c4f4 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartResponseTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartResponseTest.java @@ -43,7 +43,7 @@ void shouldParseMultipartResponse() { Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); MultipartData data = client.getFile(); assertThat(data.file).exists(); - verifyWooHooFile(data.file); + verifyWooHooFile(data.file, 10000); assertThat(data.name).isEqualTo("foo"); assertThat(data.panda.weight).isEqualTo("huge"); assertThat(data.panda.height).isEqualTo("medium"); @@ -52,6 +52,18 @@ void shouldParseMultipartResponse() { assertThat(data.numberz).containsSequence(2008, 2011, 2014); } + @Test + void shouldParseMultipartResponseWithSmallFile() { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + MultipartData data = client.getSmallFile(); + assertThat(data.file).exists(); + verifyWooHooFile(data.file, 1); + assertThat(data.name).isEqualTo("foo"); + assertThat(data.panda).isNull(); + assertThat(data.number).isEqualTo(1984); + assertThat(data.numberz).isNull(); + } + @Test void shouldParseMultipartResponseWithNulls() { Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); @@ -93,7 +105,7 @@ void shouldParseMultipartResponseWithClientBuilderApi() { assertThat(data.numbers).containsSequence(2008, 2011, 2014); } - void verifyWooHooFile(File file) { + void verifyWooHooFile(File file, int expectedTimes) { int position = 0; try (FileReader reader = new FileReader(file)) { int read; @@ -101,7 +113,7 @@ void verifyWooHooFile(File file) { assertThat((char) read).isEqualTo(WOO_HOO_WOO_HOO_HOO.charAt(position % WOO_HOO_WOO_HOO_HOO.length())); position++; } - assertThat(position).isEqualTo(WOO_HOO_WOO_HOO_HOO.length() * 10000); + assertThat(position).isEqualTo(WOO_HOO_WOO_HOO_HOO.length() * expectedTimes); } catch (IOException e) { fail("failed to read provided file", e); } @@ -113,6 +125,11 @@ public interface Client { @Produces(MediaType.MULTIPART_FORM_DATA) MultipartData getFile(); + @GET + @Produces(MediaType.MULTIPART_FORM_DATA) + @Path("/small") + MultipartData getSmallFile(); + @GET @Produces(MediaType.MULTIPART_FORM_DATA) @Path("/empty") @@ -146,6 +163,19 @@ public MultipartData getFile() throws IOException { 1984, new int[] { 2008, 2011, 2014 }); } + @GET + @Produces(MediaType.MULTIPART_FORM_DATA) + @Path("/small") + public MultipartData getSmallFile() throws IOException { + File file = File.createTempFile("toDownload", ".txt"); + file.deleteOnExit(); + // let's write Woo hoo, woo hoo hoo 1 time + try (FileOutputStream out = new FileOutputStream(file)) { + out.write(WOO_HOO_WOO_HOO_HOO.getBytes(StandardCharsets.UTF_8)); + } + return new MultipartData("foo", file, null, 1984, null); + } + @GET @Produces(MediaType.MULTIPART_FORM_DATA) @Path("/empty") diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormUpload.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormUpload.java index 14af23304ae..c784f803436 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormUpload.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormUpload.java @@ -51,7 +51,7 @@ public QuarkusMultipartFormUpload(Context context, io.netty.handler.codec.http.HttpMethod.POST, "/"); Charset charset = parts.getCharset() != null ? parts.getCharset() : HttpConstants.DEFAULT_CHARSET; - DefaultHttpDataFactory httpDataFactory = new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE, charset) { + DefaultHttpDataFactory httpDataFactory = new DefaultHttpDataFactory(-1, charset) { @Override public FileUpload createFileUpload(HttpRequest request, String name, String filename, String contentType, String contentTransferEncoding, Charset _charset, long size) { diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDataFactory.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDataFactory.java index 0770f91f9e9..72758422c29 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDataFactory.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDataFactory.java @@ -25,9 +25,7 @@ import io.netty.handler.codec.http.multipart.HttpData; import io.netty.handler.codec.http.multipart.InterfaceHttpData; import io.netty.handler.codec.http.multipart.MemoryAttribute; -import io.netty.handler.codec.http.multipart.MemoryFileUpload; import io.netty.handler.codec.http.multipart.MixedAttribute; -import io.netty.handler.codec.http.multipart.MixedFileUpload; import io.vertx.core.http.HttpClientResponse; import java.io.IOException; import java.nio.charset.Charset; @@ -240,31 +238,16 @@ public Attribute createAttribute(HttpClientResponse response, String name, Strin } // to reuse netty stuff as much as possible, we use FileUpload class to represent the downloaded file + // the difference between this and the original is that we always use DiskFileUpload public FileUpload createFileUpload(HttpClientResponse response, String name, String filename, String contentType, String contentTransferEncoding, Charset charset, long size) { - if (useDisk) { - FileUpload fileUpload = new DiskFileUpload(name, filename, contentType, - contentTransferEncoding, charset, size, baseDir, deleteOnExit); - fileUpload.setMaxSize(maxSize); - checkHttpDataSize(fileUpload); - List<HttpData> list = getList(response); - list.add(fileUpload); - return fileUpload; - } - if (checkSize) { - FileUpload fileUpload = new MixedFileUpload(name, filename, contentType, - contentTransferEncoding, charset, size, minSize, baseDir, deleteOnExit); - fileUpload.setMaxSize(maxSize); - checkHttpDataSize(fileUpload); - List<HttpData> list = getList(response); - list.add(fileUpload); - return fileUpload; - } - MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, contentType, - contentTransferEncoding, charset, size); + FileUpload fileUpload = new DiskFileUpload(name, filename, contentType, + contentTransferEncoding, charset, size, baseDir, deleteOnExit); fileUpload.setMaxSize(maxSize); checkHttpDataSize(fileUpload); + List<HttpData> list = getList(response); + list.add(fileUpload); return fileUpload; }
['extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartResponseTest.java', 'independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormUpload.java', 'independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDataFactory.java']
{'.java': 3}
3
3
0
0
3
19,962,894
3,864,250
507,365
4,878
1,659
322
29
2
3,688
498
859
75
2
0
1970-01-01T00:27:26
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,213
quarkusio/quarkus/32703/32702
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/32702
https://github.com/quarkusio/quarkus/pull/32703
https://github.com/quarkusio/quarkus/pull/32703
1
fixes
Native MariaDb with useSsl throw NPE
### Describe the bug When the Jdbc url contains `useSsl=true`, those lines throw a NPE https://github.com/mariadb-corporation/mariadb-connector-j/blob/d541afd6af963d931dd1a86adfb1cbcb1a0af10c/src/main/java/org/mariadb/jdbc/Configuration.java#L672-L679 I guess it's because the processor do not retain the deprecated.properties resource file https://github.com/quarkusio/quarkus/blob/6c7268b90a6f0d76cea39c3ad4520526e66275d9/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java#L65-L71 ### Expected behavior application can connect with `useSsl=true` ### Actual behavior Throw NPE ### Additional information In my case, I have no control over the jdbcUrl. **Would be great to backport it to 2.x**
f14cbb6aa69a498400a19e3181c3d988b676ecfb
6019c4fa82b1e61a10965673a9b5c11af656df26
https://github.com/quarkusio/quarkus/compare/f14cbb6aa69a498400a19e3181c3d988b676ecfb...6019c4fa82b1e61a10965673a9b5c11af656df26
diff --git a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java index e652d633874..d5443003105 100644 --- a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java +++ b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java @@ -68,6 +68,9 @@ void addNativeImageResources(BuildProducer<NativeImageResourceBuildItem> resourc // driver.properties is not added because it only provides optional descriptions for // org.mariadb.jdbc.Driver.getPropertyInfo(), which is probably not even called. resources.produce(new NativeImageResourceBuildItem("mariadb.properties")); + + // necessary when jdbcUrl contains useSsl=true + resources.produce(new NativeImageResourceBuildItem("deprecated.properties")); } @BuildStep
['extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java']
{'.java': 1}
1
1
0
0
1
26,285,969
5,185,061
668,954
6,198
144
27
3
1
796
64
226
26
2
0
1970-01-01T00:28:01
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,305
quarkusio/quarkus/29734/29732
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29732
https://github.com/quarkusio/quarkus/pull/29734
https://github.com/quarkusio/quarkus/pull/29734
1
closes
Consuming multiple media types from a resource method does not work
### Describe the bug Consuming multiple media types from a JAX-RS resource method does not work with RR: ``` @Path("postMultiMediaTypeConsumer") @Consumes({"application/soap+xml", MediaType.TEXT_XML}) @POST public Response postMultiMediaTypeConsumer() throws Exception { return Response.ok().build(); } ``` The reason why it does not work is that [MediaTypeMapper](https://github.com/quarkusio/quarkus/blob/main/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java#L38) is only resolving the first media type from the resource method. ### Expected behavior Resolve a JAX-RS method when multiple consume media types are set. ### Actual behavior RR fails to resolve multiple consume media types and only resolves the first one. ### How to Reproduce? ``` @Path("postMultiMediaTypeConsumer") @Consumes({"application/soap+xml", MediaType.TEXT_XML}) @POST public Response postMultiMediaTypeConsumer() throws Exception { return Response.ok().build(); } ``` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
841d75011753be373046594b78b19162ea34dff5
9dcbd7d7de3b2dbb8bf7b934096b1bfaa7fd8485
https://github.com/quarkusio/quarkus/compare/841d75011753be373046594b78b19162ea34dff5...9dcbd7d7de3b2dbb8bf7b934096b1bfaa7fd8485
diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java index 480d342920c..383b95b3931 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java @@ -28,6 +28,9 @@ */ public class MediaTypeMapper implements ServerRestHandler { + private static final MediaType[] DEFAULT_MEDIA_TYPES = new MediaType[] { MediaType.WILDCARD_TYPE }; + private static final List<MediaType> DEFAULT_MEDIA_TYPES_LIST = List.of(DEFAULT_MEDIA_TYPES); + final Map<MediaType, Holder> resourcesByConsumes; final List<MediaType> consumesTypes; @@ -35,20 +38,17 @@ public MediaTypeMapper(List<RuntimeResource> runtimeResources) { resourcesByConsumes = new HashMap<>(); consumesTypes = new ArrayList<>(); for (RuntimeResource runtimeResource : runtimeResources) { - MediaType consumesMT = runtimeResource.getConsumes().isEmpty() ? MediaType.WILDCARD_TYPE - : runtimeResource.getConsumes().get(0); - if (!resourcesByConsumes.containsKey(consumesMT)) { - consumesTypes.add(consumesMT); - resourcesByConsumes.put(consumesMT, new Holder()); - } - MediaType[] produces = runtimeResource.getProduces() != null - ? runtimeResource.getProduces().getSortedOriginalMediaTypes() - : null; - if (produces == null) { - produces = new MediaType[] { MediaType.WILDCARD_TYPE }; + List<MediaType> consumesMediaTypes = getConsumesMediaTypes(runtimeResource); + for (MediaType consumedMediaType : consumesMediaTypes) { + if (!resourcesByConsumes.containsKey(consumedMediaType)) { + consumesTypes.add(consumedMediaType); + resourcesByConsumes.put(consumedMediaType, new Holder()); + } } - for (MediaType producesMT : produces) { - resourcesByConsumes.get(consumesMT).setResource(runtimeResource, producesMT); + for (MediaType producesMT : getProducesMediaTypes(runtimeResource)) { + for (MediaType consumedMediaType : consumesMediaTypes) { + resourcesByConsumes.get(consumedMediaType).setResource(runtimeResource, producesMT); + } } } for (Holder holder : resourcesByConsumes.values()) { @@ -116,6 +116,17 @@ public MediaType selectMediaType(ResteasyReactiveRequestContext requestContext, return selected; } + private MediaType[] getProducesMediaTypes(RuntimeResource runtimeResource) { + return runtimeResource.getProduces() == null + ? DEFAULT_MEDIA_TYPES + : runtimeResource.getProduces().getSortedOriginalMediaTypes(); + } + + private List<MediaType> getConsumesMediaTypes(RuntimeResource runtimeResource) { + return runtimeResource.getConsumes().isEmpty() ? DEFAULT_MEDIA_TYPES_LIST + : runtimeResource.getConsumes(); + } + private static final class Holder { private final Map<MediaType, RuntimeResource> mtWithoutParamsToResource = new HashMap<>(); diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java index 0dcc8430247..f930b447f4c 100644 --- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java +++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java @@ -216,4 +216,28 @@ public void postInteger() throws Exception { String responseContent = response.readEntity(String.class); LOG.debug(String.format("Response: %s", responseContent)); } + + @Test + @DisplayName("Post Multi Media Type Consumer") + public void testConsumesMultiMediaType() { + WebTarget target = client.target(generateURL("/postMultiMediaTypeConsumer")); + Response response = target.request().post(Entity.entity("payload", "application/soap+xml")); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), + response.getStatus()); + Assertions.assertEquals("postMultiMediaTypeConsumer", response.readEntity(String.class)); + + response = target.request().post(Entity.entity("payload", MediaType.TEXT_XML)); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), + response.getStatus()); + Assertions.assertEquals("postMultiMediaTypeConsumer", response.readEntity(String.class)); + + response = target.request().post(Entity.entity("payload", "any/media-type")); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), + response.getStatus()); + Assertions.assertEquals("any/media-type", response.readEntity(String.class)); + + response = target.request().post(Entity.entity("payload", "unexpected/media-type")); + Assertions.assertEquals(Response.Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode(), + response.getStatus()); + } } diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java index 993cb9f9a6e..ba8f67206e0 100644 --- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java +++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java @@ -3,9 +3,11 @@ import java.util.Date; import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -75,4 +77,18 @@ public Response postIntegerProduce(String source) throws Exception { public Response postInteger(String source) throws Exception { return Response.ok().entity(5).build(); } + + @Path("postMultiMediaTypeConsumer") + @Consumes({ "application/soap+xml", MediaType.TEXT_XML }) + @POST + public Response postMultiMediaTypeConsumer() { + return Response.ok("postMultiMediaTypeConsumer").build(); + } + + @Path("postMultiMediaTypeConsumer") + @Consumes({ "any/media-type" }) + @POST + public Response postMultiMediaTypeConsumerAnyContentType(@HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType) { + return Response.ok(contentType).build(); + } }
['independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/resource/DefaultMediaTypeResource.java', 'independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java', 'independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/resource/basic/DefaultMediaTypeTest.java']
{'.java': 3}
3
3
0
0
3
24,002,458
4,726,269
612,529
5,616
2,175
398
37
1
1,438
155
321
57
1
2
1970-01-01T00:27:50
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,386
quarkusio/quarkus/26934/26748
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26748
https://github.com/quarkusio/quarkus/pull/26934
https://github.com/quarkusio/quarkus/pull/26934
1
fix
CVE-2022-2466 - Request Context not terminated with GraphQL
### Describe the bug ~~Upgrading from Quarkus 2.9.x to 2.10.x whenever i try to access `RoutingContext` request from a bean i get always the headers of the first request that have been made to the app.~~ ~~This happens on both @GraphQLApi endpoints and event in any CDI bean that consumes `RoutingContext` or `HttpServerRequest`.~~ ~~Also by debugging, the CurrentVertxRequest has always stale headers.~~ **Update:** The request context was not terminated. The issue is not related to the Routing Context. My dependencies are the following: ```xml <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-kotlin</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-graphql</artifactId> </dependency> <dependency> <groupId>io.smallrye</groupId> <artifactId>smallrye-jwt</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-client</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-rest-client-jackson</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-arc</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-undertow</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jdk8</artifactId> </dependency> ``` CDI bean: ```kotlin @ApplicationScoped class JWTAwareContext @Inject constructor( val routingContext: RoutingContext ): Context { override fun getTenant(): String { return parseClaims()!!.getClaimValueAsString("realm") } override fun getUser(): String { return parseClaims()!!.getClaimValueAsString("email") } fun parseClaims(): JwtClaims? { val rawToken = this.routingContext.request().headers().get("Authorization")?.replace("Bearer ", "") // --> this will always stale in 2.10.x if (rawToken != null) { val jsonClaims = String(Base64.getUrlDecoder().decode(rawToken.split(".")[1]), StandardCharsets.UTF_8) return JwtClaims.parse(jsonClaims) } throw PassProNextForbiddenExceptionGQL(ApiError("Missing Token", ErrorCode.FORBIDDEN)) } } ``` Graphql endpoint ```kotlin @GraphQLApi class Test { @Inject lateinit var routingContext: RoutingContext @Query fun test(): String { return "hello"; } } ``` With 2.9.x works correctly. ### Expected behavior Everytime a new Request is performed by a client, the Request headers should be inline with the actual HTTP Request ### Actual behavior With 2.10.x the first request headers became like cached value and any subsequent request headers will contain those instead of the actual headers ### How to Reproduce? 1) create an app with Quarkus 2.10.1 - 2.10.2 and the smallrye graphql extension 2) create an endpoint or a bean injecting RoutingContext 3) set some HTTP headers like Authorization, MyCustomHeader etc and send the http request 4) print RoutingContext.request().headers 5) set others HTTP headers or remove the previous and send the new http request 6) the second request headers will contain first request data also if you did not send them 7 ) switch to quarkus 2.9.x and will work as expected ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` adopt-openjdk-11.0.8 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.10.1 - 2.10.2 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) 3.8.1 ### Additional information _No response_
344497091997c5f869d872cec2ce4c00e21d4fc3
08e5c3106ce4bfb18b24a38514eeba6464668b07
https://github.com/quarkusio/quarkus/compare/344497091997c5f869d872cec2ce4c00e21d4fc3...08e5c3106ce4bfb18b24a38514eeba6464668b07
diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java index f0df7f59322..b6f44d441a3 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java @@ -58,22 +58,18 @@ public void handle(Object e) { @Override public void handle(final RoutingContext ctx) { - if (currentManagedContext.isActive()) { - handleWithIdentity(ctx); - } else { - + ctx.response() + .endHandler(currentManagedContextTerminationHandler) + .exceptionHandler(currentManagedContextTerminationHandler) + .closeHandler(currentManagedContextTerminationHandler); + if (!currentManagedContext.isActive()) { currentManagedContext.activate(); - ctx.response() - .endHandler(currentManagedContextTerminationHandler) - .exceptionHandler(currentManagedContextTerminationHandler) - .closeHandler(currentManagedContextTerminationHandler); - - try { - handleWithIdentity(ctx); - } catch (Throwable t) { - currentManagedContext.terminate(); - throw t; - } + } + try { + handleWithIdentity(ctx); + } catch (Throwable t) { + currentManagedContext.terminate(); + throw t; } } diff --git a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java index d153c2c9572..7ff8e8d4039 100644 --- a/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java +++ b/extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java @@ -196,8 +196,8 @@ private JsonObject getJsonObjectFromBody(RoutingContext ctx) throws IOException } private String readBody(RoutingContext ctx) { - if (ctx.getBody() != null) { - return ctx.getBodyAsString(); + if (ctx.body() != null) { + return ctx.body().asString(); } return null; }
['extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLAbstractHandler.java', 'extensions/smallrye-graphql/runtime/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLExecutionHandler.java']
{'.java': 2}
2
2
0
0
2
22,109,823
4,327,996
563,756
5,258
1,176
193
30
2
4,024
401
985
142
0
3
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,384
quarkusio/quarkus/27062/27063
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27063
https://github.com/quarkusio/quarkus/pull/27062
https://github.com/quarkusio/quarkus/pull/27062
1
fixes
Panache MongoDB doesn't support collation in count
### Describe the bug Panache MongoDB doesn't support `collation` for `count`. Taking a look in the `io.quarkus.mongodb.panache.common.runtime.CommonPanacheQueryImpl` and `io.quarkus.mongodb.panache.common.reactive.runtime.CommonReactivePanacheQueryImpl` we can see the method `count` doesn't support `collation`. Native queries and panache queries already support this, we can confirm in this [PR](https://github.com/loicmathieu/quarkus/commit/5c0a0a2112cc2d33ecc300618f0694846d0f0f1c#diff-610ce4a20cb8ce7c6942db761ecaebe7a4b6fc761e4b4f0b15b7406ec7db305f) from @loicmathieu already merged. I implemented the fix, basically I changed a small piece in `CommonReactivePanacheQueryImpl` and `CommonPanacheQueryImpl`: ``` public Uni<Long> count() { if (count == null) { CountOptions countOptions = new CountOptions(); if (collation != null) { countOptions.collation(collation); } count = mongoQuery == null ? collection.countDocuments() : collection.countDocuments(mongoQuery, countOptions); } return count; } ``` ``` public long count() { if (count == null) { Bson query = getQuery(); CountOptions countOptions = new CountOptions(); if (collation != null) { countOptions.collation(collation); } count = clientSession == null ? collection.countDocuments(query, countOptions) : collection.countDocuments(clientSession, query, countOptions); } return count; } ``` Here is the [PR](https://github.com/quarkusio/quarkus/pull/27062), let me know if I need to change something. Best regards. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
ea4990f498023f8b45364f0183c61bace566b7f8
d0bb07268a20cc09a68a6005ac63cc3dc3b0876d
https://github.com/quarkusio/quarkus/compare/ea4990f498023f8b45364f0183c61bace566b7f8...d0bb07268a20cc09a68a6005ac63cc3dc3b0876d
diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java index 11e71dea326..3e80f4f63f3 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java @@ -9,6 +9,7 @@ import com.mongodb.ReadPreference; import com.mongodb.client.model.Collation; +import com.mongodb.client.model.CountOptions; import io.quarkus.mongodb.FindOptions; import io.quarkus.mongodb.panache.common.runtime.MongoPropertyUtil; @@ -154,7 +155,14 @@ public <T extends Entity> CommonReactivePanacheQueryImpl<T> withReadPreference(R @SuppressWarnings("unchecked") public Uni<Long> count() { if (count == null) { - count = mongoQuery == null ? collection.countDocuments() : collection.countDocuments(mongoQuery); + CountOptions countOptions = new CountOptions(); + if (collation != null) { + countOptions.collation(collation); + } + + count = mongoQuery == null + ? collection.countDocuments() + : collection.countDocuments(mongoQuery, countOptions); } return count; } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/CommonPanacheQueryImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/CommonPanacheQueryImpl.java index 73b112ddc07..8ff48b6abd5 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/CommonPanacheQueryImpl.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/CommonPanacheQueryImpl.java @@ -16,6 +16,7 @@ import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import com.mongodb.client.model.Collation; +import com.mongodb.client.model.CountOptions; import io.quarkus.panache.common.Page; import io.quarkus.panache.common.Range; @@ -157,7 +158,14 @@ public <T extends Entity> CommonPanacheQueryImpl<T> withReadPreference(ReadPrefe public long count() { if (count == null) { Bson query = getQuery(); - count = clientSession == null ? collection.countDocuments(query) : collection.countDocuments(clientSession, query); + CountOptions countOptions = new CountOptions(); + if (collation != null) { + countOptions.collation(collation); + } + + count = clientSession == null + ? collection.countDocuments(query, countOptions) + : collection.countDocuments(clientSession, query, countOptions); } return count; } diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/test/TestResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/test/TestResource.java index 9d8d4cea807..7af7c72c510 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/test/TestResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/test/TestResource.java @@ -113,6 +113,16 @@ public Response testImperativeEntity() { Assertions.assertEquals("aaa", results.get(0).title); Assertions.assertEquals("AAA", results.get(1).title); Assertions.assertEquals("BBB", results.get(2).title); + + //count with collation + collation = Collation.builder() + .locale("en") + .collationStrength(CollationStrength.SECONDARY) + .build(); + Assertions.assertEquals(2, TestImperativeEntity.find("{'title' : ?1}", "aaa").withCollation(collation).count()); + Assertions.assertEquals(2, TestImperativeEntity.find("{'title' : ?1}", "AAA").withCollation(collation).count()); + Assertions.assertEquals(1, TestImperativeEntity.find("{'title' : ?1}", "bbb").withCollation(collation).count()); + Assertions.assertEquals(1, TestImperativeEntity.find("{'title' : ?1}", "BBB").withCollation(collation).count()); entityAUpper.delete(); entityALower.delete(); entityB.delete(); @@ -264,6 +274,17 @@ public Response testImperativeRepository() { Assertions.assertEquals("aaa", results.get(0).title); Assertions.assertEquals("AAA", results.get(1).title); Assertions.assertEquals("BBB", results.get(2).title); + + //count with collation + collation = Collation.builder() + .locale("en") + .collationStrength(CollationStrength.SECONDARY) + .build(); + + Assertions.assertEquals(2, testImperativeRepository.find("{'title' : ?1}", "aaa").withCollation(collation).count()); + Assertions.assertEquals(2, testImperativeRepository.find("{'title' : ?1}", "AAA").withCollation(collation).count()); + Assertions.assertEquals(1, testImperativeRepository.find("{'title' : ?1}", "bbb").withCollation(collation).count()); + Assertions.assertEquals(1, testImperativeRepository.find("{'title' : ?1}", "BBB").withCollation(collation).count()); testImperativeRepository.delete(entityALower); testImperativeRepository.delete(entityAUpper); testImperativeRepository.delete(entityB); @@ -494,6 +515,20 @@ public Response testReactiveEntity() { Assertions.assertEquals("aaa", results.get(0).title); Assertions.assertEquals("AAA", results.get(1).title); Assertions.assertEquals("BBB", results.get(2).title); + + //count with collation + collation = Collation.builder() + .locale("en") + .collationStrength(CollationStrength.SECONDARY) + .build(); + Assertions.assertEquals(2, TestReactiveEntity.find("{'title' : ?1}", "aaa").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(2, TestReactiveEntity.find("{'title' : ?1}", "AAA").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(1, TestReactiveEntity.find("{'title' : ?1}", "bbb").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(1, TestReactiveEntity.find("{'title' : ?1}", "BBB").withCollation(collation).count() + .await().indefinitely()); entityAUpper.delete().await().indefinitely(); entityALower.delete().await().indefinitely(); entityB.delete().await().indefinitely(); @@ -654,6 +689,20 @@ public Response testReactiveRepository() { Assertions.assertEquals("aaa", results.get(0).title); Assertions.assertEquals("AAA", results.get(1).title); Assertions.assertEquals("BBB", results.get(2).title); + + //count with collation + collation = Collation.builder() + .locale("en") + .collationStrength(CollationStrength.SECONDARY) + .build(); + Assertions.assertEquals(2, testReactiveRepository.find("{'title' : ?1}", "aaa").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(2, testReactiveRepository.find("{'title' : ?1}", "AAA").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(1, testReactiveRepository.find("{'title' : ?1}", "bbb").withCollation(collation).count() + .await().indefinitely()); + Assertions.assertEquals(1, testReactiveRepository.find("{'title' : ?1}", "BBB").withCollation(collation).count() + .await().indefinitely()); testReactiveRepository.delete(entityALower).await().indefinitely(); testReactiveRepository.delete(entityAUpper).await().indefinitely(); testReactiveRepository.delete(entityB).await().indefinitely();
['integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/test/TestResource.java', 'extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/CommonReactivePanacheQueryImpl.java', 'extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/CommonPanacheQueryImpl.java']
{'.java': 3}
3
3
0
0
3
22,143,332
4,334,196
564,539
5,264
1,034
173
20
2
2,253
222
538
81
2
2
1970-01-01T00:27:39
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,383
quarkusio/quarkus/27091/26938
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26938
https://github.com/quarkusio/quarkus/pull/27091
https://github.com/quarkusio/quarkus/pull/27091
1
fix
Maven artifacts from additional repo not found during quarkus:build
### Describe the bug Services with dependencies on Maven artifacts that are not on maven-central cannot be built if the repositories are declared only in `settings.xml` and not in the `pom.xml` project. (If the repo is entered in pom.xml, the build for repos works without credentials.) Error message: ``` Failed to execute goal io.quarkus:quarkus-maven-plugin:2.11.0.Final:build (default) on project example-artifact: Failed to build quarkus application: Failed to bootstrap application in NORMAL mode: Failed to resolve dependencies for org.acme:example-artifact:jar:999-SNAPSHOT: Could not find artifact io.confluent:kafka-avro-serializer:jar:7.2.1 in central (https://repo.maven.apache.org/maven2) -> [Help 1] ``` ### Expected behavior Maven artifacts from additional Maven repositories (such as confluent or private repositories) are not found when running mvn quarkus:build. The behavior only occurs if the repositories are defined exclusively in settings.xml. With version 2.10.3.Final, the build still worked correctly. ### Actual behavior Plugin tries to download artifact only from "central" repository and the build breaks with "Could not find artifact" error. Example: ``` Failed to execute goal io.quarkus:quarkus-maven-plugin:2.11.0.Final:build (default) on project example-artifact: Failed to build quarkus application: Failed to bootstrap application in NORMAL mode: Failed to resolve dependencies for org.acme:example-artifact:jar:999-SNAPSHOT: Could not find artifact io.confluent:kafka-avro-serializer:jar:7.2.1 in central (https://repo.maven.apache.org/maven2) -> [Help 1] ``` `mvn compile` can resolve the dependency. Only the quarkus-maven-plugin isn't able to locate the jar. ### How to Reproduce? - Add dependency to an artifact, that isn't on maven-central - Declare the repository only in settings.xml - run mvn quarkus:build Repository in profile in settings.xml: ``` <profiles> <profile> <id>3rdParty-repos</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <!-- Repository for Confluent--> <repository> <id>confluent</id> <url>https://packages.confluent.io/maven/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>confluent-plugins</id> <url>https://packages.confluent.io/maven/</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> ``` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.5 ### Additional information Dependency loading was changed with https://github.com/quarkusio/quarkus/commit/bd30d5cfa498e908e4bea41c508a9da1a820b0b1 AppModel is built only with the `managedRepos` and the repositories of the main-artifact. Other repositories from maven are ignored. - aggregatedRepos with `mangedRepos` and all maven repos: https://github.com/quarkusio/quarkus/blob/main/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java#L254 - Reduce aggregatedRepos to managedRepos and repositories from artifact: https://github.com/quarkusio/quarkus/blob/main/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java#L280-L281 When the reassignment of aggregatedRepos is omitted, `quarkus:build` will work again. But I cannot judge whether this restriction was made deliberately.
f2e4c801027d211f0f539200bff8f2b9034fa962
5657387b2db14008f82652c5399dca5b05179529
https://github.com/quarkusio/quarkus/compare/f2e4c801027d211f0f539200bff8f2b9034fa962...5657387b2db14008f82652c5399dca5b05179529
diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java index c0943ba8076..0b7a3147953 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java @@ -26,7 +26,6 @@ import io.quarkus.fs.util.ZipUtils; import io.quarkus.maven.dependency.ArtifactCoords; import io.quarkus.maven.dependency.ArtifactKey; -import io.quarkus.maven.dependency.GACTV; public abstract class BootstrapFromOriginalJarTestBase extends PackageAppTestBase { @@ -145,8 +144,10 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception { modulePom.setParent(parent); final Path moduleDir = IoUtils.mkdirs(ws.resolve(modulePom.getArtifactId())); ModelUtils.persistModel(moduleDir.resolve("pom.xml"), modulePom); - final Path resolvedJar = resolver.resolve(new GACTV(modulePom.getGroupId(), modulePom.getArtifactId(), - moduleDep.getClassifier(), moduleDep.getType(), modulePom.getVersion())).getResolvedPaths() + final Path resolvedJar = resolver + .resolve(ArtifactCoords.of(modulePom.getGroupId(), modulePom.getArtifactId(), + moduleDep.getClassifier(), moduleDep.getType(), modulePom.getVersion())) + .getResolvedPaths() .getSinglePath(); final Path moduleTargetDir = moduleDir.resolve("target"); ZipUtils.unzip(resolvedJar, moduleTargetDir.resolve("classes")); @@ -160,8 +161,10 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception { modulePom.setParent(parent); final Path moduleDir = IoUtils.mkdirs(ws.resolve(modulePom.getArtifactId())); ModelUtils.persistModel(moduleDir.resolve("pom.xml"), modulePom); - final Path resolvedJar = resolver.resolve(new GACTV(modulePom.getGroupId(), modulePom.getArtifactId(), - module.getClassifier(), module.getType(), modulePom.getVersion())).getResolvedPaths() + final Path resolvedJar = resolver + .resolve(ArtifactCoords.of(modulePom.getGroupId(), modulePom.getArtifactId(), + module.getClassifier(), module.getType(), modulePom.getVersion())) + .getResolvedPaths() .getSinglePath(); final Path moduleTargetDir = moduleDir.resolve("target"); ZipUtils.unzip(resolvedJar, moduleTargetDir.resolve("classes")); @@ -201,8 +204,10 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception { modulePom.setParent(parent); final Path moduleDir = IoUtils.mkdirs(ws.resolve(modulePom.getArtifactId())); ModelUtils.persistModel(moduleDir.resolve("pom.xml"), modulePom); - final Path resolvedJar = resolver.resolve(new GACTV(modulePom.getGroupId(), modulePom.getArtifactId(), - a.getClassifier(), a.getType(), modulePom.getVersion())).getResolvedPaths() + final Path resolvedJar = resolver + .resolve(ArtifactCoords.of(modulePom.getGroupId(), modulePom.getArtifactId(), + a.getClassifier(), a.getType(), modulePom.getVersion())) + .getResolvedPaths() .getSinglePath(); final Path moduleTargetDir = moduleDir.resolve("target"); ZipUtils.unzip(resolvedJar, moduleTargetDir.resolve("classes")); @@ -222,6 +227,7 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception { .setWorkspaceDiscovery(true) .setWorkspaceModuleParentHierarchy(workspaceModuleParentHierarchy()) .setRootProjectDir(ws) + .setUserSettings(getSettingsXml() == null ? null : getSettingsXml().toFile()) .setCurrentProject(appPomXml.toString())) .getCurrentProject(); diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/SimpleExtAndAppCompileDepsTest.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/SimpleExtAndAppCompileDepsTest.java index 0f6dff9e2ea..3d518736e32 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/SimpleExtAndAppCompileDepsTest.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/SimpleExtAndAppCompileDepsTest.java @@ -5,6 +5,12 @@ public class SimpleExtAndAppCompileDepsTest extends BootstrapFromOriginalJarTestBase { + @Override + protected boolean setupCustomMavenRepoInSettings() { + // this is to make sure repositories enabled in user settings are properly aggregated + return true; + } + @Override protected TsArtifact composeApplication() { diff --git a/devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java b/devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java index 8553d60ce73..00a402bcda5 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java @@ -6,7 +6,7 @@ import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; +import java.util.Map; import org.apache.maven.settings.Profile; import org.apache.maven.settings.Repository; @@ -78,7 +78,7 @@ static void setup() throws Exception { settingsXml = workDir().resolve("settings.xml"); try (BufferedWriter writer = Files.newBufferedWriter(settingsXml)) { - new DefaultSettingsWriter().write(writer, Collections.emptyMap(), settings); + new DefaultSettingsWriter().write(writer, Map.of(), settings); } testRepo = registryConfigDir.resolve("test-repo"); } @@ -109,7 +109,7 @@ protected static String getCurrentQuarkusVersion() { private static Settings getBaseMavenSettings(Path mavenSettings) throws IOException { if (Files.exists(mavenSettings)) { try (BufferedReader reader = Files.newBufferedReader(mavenSettings)) { - return new DefaultSettingsReader().read(reader, Collections.emptyMap()); + return new DefaultSettingsReader().read(reader, Map.of()); } } return new Settings(); diff --git a/devtools/maven/src/test/java/io/quarkus/maven/DependencyTreeMojoTestBase.java b/devtools/maven/src/test/java/io/quarkus/maven/DependencyTreeMojoTestBase.java index c89f2e5f57a..1ff2aad86c4 100644 --- a/devtools/maven/src/test/java/io/quarkus/maven/DependencyTreeMojoTestBase.java +++ b/devtools/maven/src/test/java/io/quarkus/maven/DependencyTreeMojoTestBase.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver; import io.quarkus.bootstrap.resolver.TsArtifact; import io.quarkus.bootstrap.resolver.TsDependency; import io.quarkus.bootstrap.resolver.TsQuarkusExt; @@ -48,7 +47,7 @@ public void setup() throws Exception { .setRemoteRepositories(Collections.emptyList()) .build(); - repoBuilder = TsRepoBuilder.getInstance(new BootstrapAppModelResolver(mvnResolver), workDir); + repoBuilder = TsRepoBuilder.getInstance(mvnResolver, workDir); initRepo(); } diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/CollectDependenciesBase.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/CollectDependenciesBase.java index d939ed795b1..9217b3490e2 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/CollectDependenciesBase.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/CollectDependenciesBase.java @@ -7,10 +7,10 @@ import io.quarkus.maven.dependency.DependencyFlags; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; +import org.eclipse.aether.util.artifact.JavaScopes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,8 +21,8 @@ public abstract class CollectDependenciesBase extends ResolverSetupCleanup { protected TsArtifact root; - protected List<Dependency> expectedResult = Collections.emptyList(); - protected List<Dependency> deploymentDeps = Collections.emptyList(); + protected List<Dependency> expectedResult = List.of(); + protected List<Dependency> deploymentDeps = List.of(); @Override @BeforeEach @@ -57,12 +57,12 @@ protected BootstrapAppModelResolver getTestResolver() throws Exception { } protected Path getInstallDir(TsArtifact artifact) { - return repoHome.resolve(artifact.getGroupId().replace('.', '/')).resolve(artifact.getArtifactId()) + return getInstallDir().resolve(artifact.getGroupId().replace('.', '/')).resolve(artifact.getArtifactId()) .resolve(artifact.getVersion()); } protected TsArtifact install(TsArtifact dep, boolean collected) { - return install(dep, collected ? "compile" : null); + return install(dep, collected ? JavaScopes.COMPILE : null); } protected TsArtifact install(TsArtifact dep, String collectedInScope) { @@ -74,7 +74,7 @@ protected TsArtifact install(TsArtifact dep, String collectedInScope, boolean op } protected TsArtifact install(TsArtifact dep, Path p, boolean collected) { - return install(dep, p, collected ? "compile" : null, false); + return install(dep, p, collected ? JavaScopes.COMPILE : null, false); } protected TsArtifact install(TsArtifact dep, Path p, String collectedInScope, boolean optional) { @@ -93,7 +93,7 @@ protected TsQuarkusExt install(TsQuarkusExt ext) { protected void install(TsQuarkusExt ext, boolean collected) { ext.install(repo); if (collected) { - addCollectedDep(ext.getRuntime(), "compile", false, DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDep(ext.getRuntime(), JavaScopes.COMPILE, false, DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); addCollectedDeploymentDep(ext.getDeployment()); } } @@ -101,7 +101,7 @@ protected void install(TsQuarkusExt ext, boolean collected) { protected void installAsDep(TsQuarkusExt ext) { ext.install(repo); root.addDependency(ext); - addCollectedDep(ext.getRuntime(), "compile", false, + addCollectedDep(ext.getRuntime(), JavaScopes.COMPILE, false, DependencyFlags.DIRECT | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); addCollectedDeploymentDep(ext.getDeployment()); @@ -142,11 +142,11 @@ protected void installAsDep(TsDependency dep, Path p, boolean collected, int... for (int f : flags) { allFlags |= f; } - addCollectedDep(artifact, dep.scope == null ? "compile" : dep.scope, dep.optional, allFlags); + addCollectedDep(artifact, dep.scope == null ? JavaScopes.COMPILE : dep.scope, dep.optional, allFlags); } protected void addCollectedDep(final TsArtifact artifact, int... flags) { - addCollectedDep(artifact, "compile", false, flags); + addCollectedDep(artifact, JavaScopes.COMPILE, false, flags); } protected void addCollectedDep(final TsArtifact artifact, final String scope, boolean optional, int... flags) { @@ -168,7 +168,7 @@ protected void addCollectedDeploymentDep(TsArtifact ext) { deploymentDeps = new ArrayList<>(); } deploymentDeps - .add(new ArtifactDependency(ext.toArtifact(), "compile", + .add(new ArtifactDependency(ext.toArtifact(), JavaScopes.COMPILE, DependencyFlags.DEPLOYMENT_CP)); } diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java index fe7f14a67b6..83c8da19979 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java @@ -4,11 +4,20 @@ import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; import io.quarkus.bootstrap.util.IoUtils; +import java.io.BufferedWriter; import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.apache.maven.settings.Activation; +import org.apache.maven.settings.Profile; +import org.apache.maven.settings.Repository; +import org.apache.maven.settings.RepositoryPolicy; +import org.apache.maven.settings.Settings; +import org.apache.maven.settings.io.DefaultSettingsWriter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -19,7 +28,9 @@ public class ResolverSetupCleanup { protected Path workDir; - protected Path repoHome; + private Path repoHome; + private Path localRepoHome; + private Path settingsXml; protected BootstrapAppModelResolver resolver; protected TsRepoBuilder repo; @@ -30,8 +41,45 @@ public void setup() throws Exception { setSystemProperties(); workDir = initWorkDir(); repoHome = IoUtils.mkdirs(workDir.resolve("repo")); + if (setupCustomMavenRepoInSettings()) { + localRepoHome = IoUtils.mkdirs(workDir).resolve("local-repo"); + + final Settings settings = new Settings(); + final Profile profile = new Profile(); + final Activation activation = new Activation(); + activation.setActiveByDefault(true); + profile.setActivation(activation); + final Repository repo = new Repository(); + repo.setId("custom-repo"); + repo.setName("Custom Test Repo"); + repo.setLayout("default"); + try { + repo.setUrl(repoHome.toUri().toURL().toExternalForm()); + } catch (MalformedURLException e) { + throw new BootstrapMavenException("Failed to initialize Maven repo URL", e); + } + RepositoryPolicy policy = new RepositoryPolicy(); + policy.setEnabled(true); + policy.setChecksumPolicy("ignore"); + policy.setUpdatePolicy("never"); + repo.setReleases(policy); + repo.setSnapshots(policy); + profile.setId("custom-repo"); + profile.addRepository(repo); + settings.addProfile(profile); + + settingsXml = workDir.resolve("settings.xml"); + try (BufferedWriter writer = Files.newBufferedWriter(settingsXml)) { + new DefaultSettingsWriter().write(writer, Map.of(), settings); + } catch (IOException e) { + throw new BootstrapMavenException("Failed to persist settings.xml", e); + } + } else { + localRepoHome = repoHome; + } + resolver = newAppModelResolver(null); - repo = TsRepoBuilder.getInstance(resolver, workDir); + repo = TsRepoBuilder.getInstance(newArtifactResolver(null, true), workDir); } @AfterEach @@ -51,6 +99,22 @@ public void cleanup() { } } + protected Path getInstallDir() { + return repoHome; + } + + /** + * Enabling this option will install all the artifacts to a Maven repo that + * will be enabled in the Maven settings as a remote repo for the test. + * Otherwise, all the artifacts will be installed in a Maven repo that will + * be configured as a local repo for the test. + * + * @return whether to setup a custom remote Maven repo for the test + */ + protected boolean setupCustomMavenRepoInSettings() { + return false; + } + protected void setSystemProperties() { } @@ -68,6 +132,10 @@ protected Path initWorkDir() { return IoUtils.createRandomTmpDir(); } + protected Path getSettingsXml() { + return settingsXml; + } + protected boolean cleanWorkDir() { return true; } @@ -85,12 +153,24 @@ protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProj } protected MavenArtifactResolver newArtifactResolver(LocalProject currentProject) throws BootstrapMavenException { - return MavenArtifactResolver.builder() - .setLocalRepository(repoHome.toString()) + return newArtifactResolver(currentProject, false); + } + + private MavenArtifactResolver newArtifactResolver(LocalProject currentProject, boolean forInstalling) + throws BootstrapMavenException { + final MavenArtifactResolver.Builder builder = MavenArtifactResolver.builder() .setOffline(true) .setWorkspaceDiscovery(false) - .setCurrentProject(currentProject) - .build(); + .setCurrentProject(currentProject); + if (forInstalling) { + builder.setLocalRepository(repoHome.toString()); + } else { + builder.setLocalRepository(localRepoHome.toString()); + if (settingsXml != null) { + builder.setUserSettings(settingsXml.toFile()).setOffline(false); + } + } + return builder.build(); } protected TsJar newJar() throws IOException { diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsRepoBuilder.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsRepoBuilder.java index 43b240a2c4c..2f1ff0e7b62 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsRepoBuilder.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsRepoBuilder.java @@ -1,12 +1,16 @@ package io.quarkus.bootstrap.resolver; +import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; +import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils; import io.quarkus.maven.dependency.ArtifactCoords; import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Map; import java.util.UUID; +import org.eclipse.aether.artifact.DefaultArtifact; /** * @@ -18,14 +22,14 @@ private static void error(String message, Throwable t) { throw new IllegalStateException(message, t); } - public static TsRepoBuilder getInstance(BootstrapAppModelResolver resolver, Path workDir) { + public static TsRepoBuilder getInstance(MavenArtifactResolver resolver, Path workDir) { return new TsRepoBuilder(resolver, workDir); } protected final Path workDir; - private final BootstrapAppModelResolver resolver; + private final MavenArtifactResolver resolver; - private TsRepoBuilder(BootstrapAppModelResolver resolver, Path workDir) { + private TsRepoBuilder(MavenArtifactResolver resolver, Path workDir) { this.resolver = resolver; this.workDir = workDir; } @@ -77,8 +81,10 @@ public void install(TsArtifact artifact, Path p) { protected void install(ArtifactCoords artifact, Path file) { try { - resolver.install(artifact, file); - } catch (AppModelResolverException e) { + resolver.install(new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), + artifact.getType(), + artifact.getVersion(), Map.of(), file.toFile())); + } catch (BootstrapMavenException e) { error("Failed to install " + artifact, e); } } diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java index 7f0dc13be3e..12f32324d52 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java @@ -277,7 +277,7 @@ private ApplicationModel doResolveModel(ArtifactCoords coords, directMvnDeps = DependencyUtils.mergeDeps(directMvnDeps, appArtifactDescr.getDependencies(), managedVersions, getExcludedScopes()); - aggregatedRepos = mvn.aggregateRepositories(managedRepos, + aggregatedRepos = mvn.aggregateRepositories(aggregatedRepos, mvn.newResolutionRepositories(appArtifactDescr.getRepositories())); return buildAppModel(appArtifact, diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java index d17c5161a23..f538d1a74d2 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java @@ -148,7 +148,7 @@ public BootstrapMavenContext(BootstrapMavenContextConfig<?> config) if (config.rootProjectDir == null) { final String topLevelBaseDirStr = PropertyUtils.getProperty(MAVEN_TOP_LEVEL_PROJECT_BASEDIR); if (topLevelBaseDirStr != null) { - final Path tmp = Paths.get(topLevelBaseDirStr); + final Path tmp = Path.of(topLevelBaseDirStr); if (!Files.exists(tmp)) { throw new BootstrapMavenException("Top-level project base directory " + topLevelBaseDirStr + " specified with system property " + MAVEN_TOP_LEVEL_PROJECT_BASEDIR + " does not exist");
['core/deployment/src/test/java/io/quarkus/deployment/runnerjar/SimpleExtAndAppCompileDepsTest.java', 'independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/BootstrapMavenContext.java', 'devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java', 'core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java', 'independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsRepoBuilder.java', 'independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/CollectDependenciesBase.java', 'independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java', 'independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java', 'devtools/maven/src/test/java/io/quarkus/maven/DependencyTreeMojoTestBase.java']
{'.java': 9}
9
9
0
0
9
22,147,608
4,334,993
564,599
5,264
263
54
4
2
3,827
384
996
105
7
3
1970-01-01T00:27:39
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,381
quarkusio/quarkus/27196/27194
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27194
https://github.com/quarkusio/quarkus/pull/27196
https://github.com/quarkusio/quarkus/pull/27196
1
resolves
AutoAddScopeBuildItem.isUnremovable() is ignored
https://github.com/quarkusio/quarkus/discussions/27103 An additional `UnremovableBeanBuildItem` should be used as a workaround Thanks @azzazzel for spotting the issue!
d9a76859de1d0c3ad89a5461b45f5b6791ffdfd7
eaed7bddce3e21a8cd9db4c22dbeceb2c04c82e7
https://github.com/quarkusio/quarkus/compare/d9a76859de1d0c3ad89a5461b45f5b6791ffdfd7...eaed7bddce3e21a8cd9db4c22dbeceb2c04c82e7
diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoAddScopeProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoAddScopeProcessor.java index ade8a079fb9..6df8e7ceb9e 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoAddScopeProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoAddScopeProcessor.java @@ -1,9 +1,10 @@ package io.quarkus.arc.deployment; import java.util.Comparator; -import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -43,7 +44,8 @@ void annotationTransformer(List<AutoAddScopeBuildItem> autoScopes, CustomScopeAn containerAnnotationNames.add(DotNames.PRE_DESTROY); containerAnnotationNames.add(DotNames.INJECT); - Set<DotName> unremovables = new HashSet<>(); + ConcurrentMap<DotName, AutoAddScopeBuildItem> unremovables = sortedAutoScopes.stream() + .anyMatch(AutoAddScopeBuildItem::isUnremovable) ? new ConcurrentHashMap<>() : null; annotationsTransformers.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { @@ -94,8 +96,8 @@ public void transform(TransformationContext context) { scope = autoScope.getDefaultScope(); reason = autoScope.getReason(); context.transform().add(scope).done(); - if (autoScope.isUnremovable()) { - unremovables.add(clazz.name()); + if (unremovables != null && autoScope.isUnremovable()) { + unremovables.put(clazz.name(), autoScope); } LOGGER.debugf("Automatically added scope %s to class %s: %s", scope, clazz, autoScope.getReason()); } @@ -103,12 +105,12 @@ public void transform(TransformationContext context) { } })); - if (!unremovables.isEmpty()) { + if (unremovables != null) { unremovableBeans.produce(new UnremovableBeanBuildItem(new Predicate<BeanInfo>() { @Override public boolean test(BeanInfo bean) { - return bean.isClassBean() && unremovables.contains(bean.getBeanClass()); + return bean.isClassBean() && unremovables.containsKey(bean.getBeanClass()); } })); } diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoscope/AutoScopeBuildItemTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoscope/AutoScopeBuildItemTest.java index d96ceaebe26..ec9038412da 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoscope/AutoScopeBuildItemTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoscope/AutoScopeBuildItemTest.java @@ -1,6 +1,7 @@ package io.quarkus.arc.test.autoscope; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.UUID; @@ -13,6 +14,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.arc.Arc; import io.quarkus.arc.deployment.AutoAddScopeBuildItem; import io.quarkus.arc.processor.BuiltinScope; import io.quarkus.builder.BuildContext; @@ -46,6 +48,14 @@ public void execute(BuildContext context) { }).defaultScope(BuiltinScope.SINGLETON).priority(10).reason("Foo!").build()); } }).produces(AutoAddScopeBuildItem.class).build(); + b.addBuildStep(new BuildStep() { + @Override + public void execute(BuildContext context) { + context.produce(AutoAddScopeBuildItem.builder().match((clazz, annotations, index) -> { + return clazz.name().toString().equals(NotABean.class.getName()); + }).defaultScope(BuiltinScope.SINGLETON).unremovable().build()); + } + }).produces(AutoAddScopeBuildItem.class).build(); }).setLogRecordPredicate(log -> "AutoScopeBuildItemTest".equals(log.getLoggerName())) .assertLogRecords(records -> { assertEquals(1, records.size()); @@ -56,10 +66,14 @@ public void execute(BuildContext context) { Instance<SimpleBean> instance; @Test - public void testBean() { + public void testBeans() { assertTrue(instance.isResolvable()); // The scope should be @Singleton assertEquals(instance.get().ping(), instance.get().ping()); + + NotABean notABean1 = Arc.container().instance(NotABean.class).get(); + assertNotNull(notABean1); + assertEquals(notABean1.ping(), Arc.container().instance(NotABean.class).get().ping()); } static class SimpleBean { @@ -77,4 +91,20 @@ void init() { } + // add @Singleton and make it unremovable + static class NotABean { + + private String id; + + public String ping() { + return id; + } + + @PostConstruct + void init() { + id = UUID.randomUUID().toString(); + } + + } + }
['extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoAddScopeProcessor.java', 'extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoscope/AutoScopeBuildItemTest.java']
{'.java': 2}
2
2
0
0
2
22,150,859
4,335,550
564,678
5,264
910
186
14
1
173
16
44
5
1
0
1970-01-01T00:27:40
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,380
quarkusio/quarkus/27207/27198
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27198
https://github.com/quarkusio/quarkus/pull/27207
https://github.com/quarkusio/quarkus/pull/27207
1
resolves
Arc Ignoring injected field
### Describe the bug When building the project we get the following warning: ```java [io.qua.arc.pro.Injection] (build-56) An injection field must be non-static and non-final - ignoring ``` with the given class ```java package //s.service; package // omitted import java.time.LocalDate; import java.util.Collection; import java.util.List; import java.util.Optional; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.inject.Named; import javax.ws.rs.BadRequestException; import //.GlobalConstants; import //.KeycloackService; import //r.BasicUserWithHistoriesDto; import //.UserHistory; import //.HistoryRepository; import //.HistoryUpdateHandler; import //.HttpCacheHandler; @ApplicationScoped @RequiredArgsConstructor(onConstructor = @__(@Inject)) @Slf4j public class HistoryService { private final KeycloackService keycloackService; private final HistoryRepository historyRepository; @Named(GlobalConstants.POST_HISTORY_HANDLERS_NAME) private final List<HistoryUpdateHandler> historyHooks; private final HttpCacheHandler<Collection<BasicUserWithHistoriesDto>, Long> userHistoriesCache; // rest of the code omitted } ``` and the given lombok conf ``` config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true lombok.copyableAnnotations += javax.inject.Named ``` producing the given source: ```java // Generated by delombok at Tue Aug 09 11:28:41 CEST 2022 package // omitted import java.time.LocalDate; import java.util.Collection; import java.util.List; import java.util.Optional; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.inject.Named; import javax.ws.rs.BadRequestException; import //.GlobalConstants; import //.KeycloackService; import //r.BasicUserWithHistoriesDto; import //.UserHistory; import //.HistoryRepository; import //.HistoryUpdateHandler; import //.HttpCacheHandler; @ApplicationScoped public class HistoryService { @java.lang.SuppressWarnings("all") @lombok.Generated private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(HistoryService.class); private final KeycloackService keycloackService; private final HistoryRepository historyRepository; @Named(GlobalConstants.POST_HISTORY_HANDLERS_NAME) private final List<HistoryUpdateHandler> historyHooks; private final HttpCacheHandler<Collection<BasicUserWithHistoriesDto>, Long> userHistoriesCache; // rest of the code omitted @Inject @java.lang.SuppressWarnings("all") @lombok.Generated public HistoryService(final KeycloackService keycloackService, final HistoryRepository historyRepository, @Named(GlobalConstants.POST_HISTORY_HANDLERS_NAME) final List<HistoryUpdateHandler> historyHooks, final HttpCacheHandler<Collection<BasicUserWithHistoriesDto>, Long> userHistoriesCache) { this.keycloackService = keycloackService; this.historyRepository = historyRepository; this.historyHooks = historyHooks; this.userHistoriesCache = userHistoriesCache; } } ``` ### Expected behavior No warning as we use the constructor to inject the value in the field and not `@Inject` ### Actual behavior We get the warning [io.qua.arc.pro.Injection] (build-56) An injection field must be non-static and non-final - ignoring ### How to Reproduce? 1. Use Quarkus 2.11.2.Final 2. Use Lombok with the given configuration 3. Build the project ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) maven ### Additional information _No response_
dc51ebc7ea34339b43139cd16bf8ac4d44ef868a
6ee79e92f4f6aa33700c1e4cd1edc0690aefea16
https://github.com/quarkusio/quarkus/compare/dc51ebc7ea34339b43139cd16bf8ac4d44ef868a...6ee79e92f4f6aa33700c1e4cd1edc0690aefea16
diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java index ffaa6bca3f6..35159793b75 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java @@ -48,7 +48,7 @@ public class ArcConfig { public String removeUnusedBeans; /** - * If set to true {@code @Inject} is automatically added to all non-static fields that are annotated with + * If set to true {@code @Inject} is automatically added to all non-static non-final fields that are annotated with * one of the annotations defined by {@link AutoInjectAnnotationBuildItem}. */ @ConfigItem(defaultValue = "true") diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoInjectFieldProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoInjectFieldProcessor.java index 861dd020650..2da0e5b6d9c 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoInjectFieldProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoInjectFieldProcessor.java @@ -11,6 +11,7 @@ import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.DotName; +import org.jboss.jandex.FieldInfo; import org.jboss.logging.Logger; import io.quarkus.arc.processor.AnnotationsTransformer; @@ -69,7 +70,10 @@ public int getPriority() { @Override public void transform(TransformationContext ctx) { Collection<AnnotationInstance> fieldAnnotations = ctx.getAnnotations(); - if (Modifier.isStatic(ctx.getTarget().asField().flags()) || contains(fieldAnnotations, DotNames.INJECT) + FieldInfo field = ctx.getTarget().asField(); + if (Modifier.isStatic(field.flags()) + || Modifier.isFinal(field.flags()) + || contains(fieldAnnotations, DotNames.INJECT) || contains(fieldAnnotations, DotNames.PRODUCES)) { return; } diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoinject/AutoFieldInjectionTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoinject/AutoFieldInjectionTest.java index 69333fcd13e..96b10acffdb 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoinject/AutoFieldInjectionTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoinject/AutoFieldInjectionTest.java @@ -6,6 +6,7 @@ import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; @@ -35,11 +36,17 @@ public class AutoFieldInjectionTest { public void testInjectionWorks() { assertEquals("ok", bean.foo); assertEquals(1l, bean.bar); + assertNull(Client.staticFoo); + assertNull(bean.baz); } @Dependent static class Client { + // @Inject should not be added here + @MyQualifier + static String staticFoo; + // @Inject is added automatically @MyQualifier String foo; @@ -47,6 +54,14 @@ static class Client { @MyQualifier Long bar; + // @Inject should not be added here + @MyQualifier + final Long baz; + + Client() { + this.baz = null; + } + } static class Producer {
['extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcConfig.java', 'extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AutoInjectFieldProcessor.java', 'extensions/arc/deployment/src/test/java/io/quarkus/arc/test/autoinject/AutoFieldInjectionTest.java']
{'.java': 3}
3
3
0
0
3
22,158,308
4,337,091
564,877
5,265
635
121
8
2
3,919
345
853
150
0
4
1970-01-01T00:27:40
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,379
quarkusio/quarkus/27336/27122
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27122
https://github.com/quarkusio/quarkus/pull/27336
https://github.com/quarkusio/quarkus/pull/27336
1
fixes
io.quarkus.oidc.OidcSession uses Instant to present duration
### Describe the bug In, io.quarkus.oidc.OidcSession (https://github.com/quarkusio/quarkus/blob/main/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java), it uses Instant to present duration. ``` /** * Return an {@linkplain:Instant} indicating how long will it take for the current session to expire. * * @return */ Instant expiresIn(); ``` Based on [Javadoc](https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html), it is an instantaneous point on the time-line. But the comment says "how long", it should be Duration. When using it in app, it seems that the value is filled with Duration too. e.g. One value I got is `"expiresIn": "1970-01-01T00:23:05Z"`. I guess it means the session has 23 hours and 5 minutes to expire. Personally, I prefer to use Instant but it should assigned the correct time value (a duration value is a little hard to predict the ending time without base time) and the comment should be updated. ### Expected behavior Using Instant but it should assigned the correct time value (a duration value is a little hard to predict the ending time without base time) and the comment should be updated. ### Actual behavior It uses Instant with the wrong value and comment is misleading. ### How to Reproduce? Just any endpoint with injection of OidcSession. ### Output of `uname -a` or `ver` Darwin Kernel Version 21.4.0 ### Output of `java -version` openjdk version "18" 2022-03-2 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.8.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.4.1 ### Additional information _No response_
e85d92aa11525e35f342540045b09b4f5e5fb8c6
4677e9e3f4ddbc4c395a61361b3bd6f2d71778fa
https://github.com/quarkusio/quarkus/compare/e85d92aa11525e35f342540045b09b4f5e5fb8c6...4677e9e3f4ddbc4c395a61361b3bd6f2d71778fa
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java index 66fe190fa95..9f50af65aed 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java @@ -1,5 +1,6 @@ package io.quarkus.oidc; +import java.time.Duration; import java.time.Instant; import org.eclipse.microprofile.jwt.JsonWebToken; @@ -18,10 +19,31 @@ public interface OidcSession { /** * Return an {@linkplain:Instant} indicating how long will it take for the current session to expire. * - * @return + * @deprecated This method shouldn't be used as it provides an instant corresponding to 1970-01-01T0:0:0Z plus the duration + * of the validity of the token, which is impractical. Please use either {@link #expiresAt()} or + * {@link #validFor()} depending on your requirements. This method will be removed in a later version of + * Quarkus. + * + * @return Instant */ + @Deprecated(forRemoval = true, since = "2.12.0") Instant expiresIn(); + /** + * Return an {@linkplain Instant} representing the current session's expiration time. + * + * @return Instant + */ + Instant expiresAt(); + + /** + * Return a {@linkplain Duration} indicating how long the current session will remain valid for + * starting from this method's invocation time. + * + * @return Duration + */ + Duration validFor(); + /** * Perform a local logout without a redirect to the OpenId Connect provider. * diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcSessionImpl.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcSessionImpl.java index 80f897682aa..af5e1e6b9a4 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcSessionImpl.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcSessionImpl.java @@ -1,5 +1,6 @@ package io.quarkus.oidc.runtime; +import java.time.Duration; import java.time.Instant; import java.util.function.Function; @@ -56,9 +57,19 @@ public Instant expiresIn() { return Instant.ofEpochSecond(idToken.getExpirationTime() - nowSecs); } + @Override + public Instant expiresAt() { + return Instant.ofEpochSecond(idToken.getExpirationTime()); + } + + @Override + public Duration validFor() { + final long nowSecs = System.currentTimeMillis() / 1000; + return Duration.ofSeconds(idToken.getExpirationTime() - nowSecs); + } + @Override public JsonWebToken getIdToken() { return idToken; } - } diff --git a/integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TenantHttps.java b/integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TenantHttps.java index bca5b831aed..4f752143d3e 100644 --- a/integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TenantHttps.java +++ b/integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TenantHttps.java @@ -27,7 +27,8 @@ public String getTenant() { @Path("query") @Authenticated public String getTenantWithQuery(@QueryParam("code") String value) { - return getTenant() + "?code=" + value; + return getTenant() + "?code=" + value + "&expiresAt=" + session.expiresAt().getEpochSecond() + + "&expiresInDuration=" + session.validFor().getSeconds(); } @GET diff --git a/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java b/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java index 4c7b5516cd8..c1571712c69 100644 --- a/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java +++ b/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java @@ -33,6 +33,7 @@ import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.smallrye.jwt.util.KeyUtils; +import io.vertx.core.json.JsonObject; /** * @author <a href="mailto:psilva@redhat.com">Pedro Igor</a> @@ -256,10 +257,18 @@ public void testCodeFlowForceHttpsRedirectUriWithQueryAndPkce() throws Exception URI endpointLocationWithoutQueryUri = URI.create(endpointLocationWithoutQuery); assertEquals("code=b", endpointLocationWithoutQueryUri.getRawQuery()); - page = webClient.getPage(endpointLocationWithoutQueryUri.toURL()); - assertEquals("tenant-https:reauthenticated?code=b", page.getBody().asText()); Cookie sessionCookie = getSessionCookie(webClient, "tenant-https_test"); assertNotNull(sessionCookie); + JsonObject idToken = OidcUtils.decodeJwtContent(sessionCookie.getValue().split("\\\\|")[0]); + String expiresAt = idToken.getInteger("exp").toString(); + page = webClient.getPage(endpointLocationWithoutQueryUri.toURL()); + String response = page.getBody().asText(); + assertTrue( + response.startsWith("tenant-https:reauthenticated?code=b&expiresAt=" + expiresAt + "&expiresInDuration=")); + Integer duration = Integer.valueOf(response.substring(response.length() - 1)); + assertTrue(duration > 1 && duration < 5); + sessionCookie = getSessionCookie(webClient, "tenant-https_test"); + assertNotNull(sessionCookie); webClient.getCookieManager().clearCookies(); } }
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcSessionImpl.java', 'integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java', 'integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TenantHttps.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcSession.java']
{'.java': 4}
4
4
0
0
4
22,275,820
4,360,085
567,941
5,308
1,278
284
37
2
1,729
244
439
59
2
1
1970-01-01T00:27:40
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,378
quarkusio/quarkus/27342/27291
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27291
https://github.com/quarkusio/quarkus/pull/27342
https://github.com/quarkusio/quarkus/pull/27342
1
fixes
BasicAuthenticationMechanism challenge contains a `Quarkus` realm property
### Describe the bug It adds `realm="Quarkus"` to the `WWW-Authenticate` header - it is an implementation detail (that `Quarkus` is used) and also adding `realm` causes side-effects for some applications. ### Expected behavior `realm` property should be returned only if it is configured ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
233f8b86ce1f3cd51587c42ecc286bcea19643f8
c8843a7f7fd98e6ef135dd9c93d5580c04ad395e
https://github.com/quarkusio/quarkus/compare/233f8b86ce1f3cd51587c42ecc286bcea19643f8...c8843a7f7fd98e6ef135dd9c93d5580c04ad395e
diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java index f1ff0f674b6..ea98c661856 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java @@ -23,6 +23,7 @@ public class CombinedFormBasicAuthTestCase { private static final String APP_PROPS = "" + "quarkus.http.auth.basic=true\\n" + + "quarkus.http.auth.realm=TestRealm\\n" + "quarkus.http.auth.form.enabled=true\\n" + "quarkus.http.auth.form.login-page=login\\n" + "quarkus.http.auth.form.error-page=error\\n" + @@ -154,7 +155,7 @@ public void testBasicAuthFailure() { .then() .assertThat() .statusCode(401) - .header("WWW-Authenticate", equalTo("basic realm=\\"Quarkus\\"")); + .header("WWW-Authenticate", equalTo("basic realm=\\"TestRealm\\"")); } } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java index c2bfb0bb43a..3e609d66f98 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java @@ -29,8 +29,8 @@ public class AuthConfig { /** * The authentication realm */ - @ConfigItem(defaultValue = "Quarkus") - public String realm; + @ConfigItem + public Optional<String> realm; /** * The HTTP permissions diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java index 1abbb36a500..60566daba95 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java @@ -95,7 +95,7 @@ public BasicAuthenticationMechanism(final String realmName, final boolean silent public BasicAuthenticationMechanism(final String realmName, final boolean silent, Charset charset, Map<Pattern, Charset> userAgentCharsets) { - this.challenge = BASIC_PREFIX + "realm=\\"" + realmName + "\\""; + this.challenge = realmName == null ? BASIC : BASIC_PREFIX + "realm=\\"" + realmName + "\\""; this.silent = silent; this.charset = charset; this.userAgentCharsets = Collections.unmodifiableMap(new LinkedHashMap<>(userAgentCharsets)); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java index 9a17a290d64..48a55cba4d3 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java @@ -279,7 +279,8 @@ public Supplier<?> setupBasicAuth(HttpBuildTimeConfig buildTimeConfig) { return new Supplier<BasicAuthenticationMechanism>() { @Override public BasicAuthenticationMechanism get() { - return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm, buildTimeConfig.auth.form.enabled); + return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm.orElse(null), + buildTimeConfig.auth.form.enabled); } }; } diff --git a/integration-tests/oidc/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java b/integration-tests/oidc/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java index 993d3b9ac2b..7e98044f368 100644 --- a/integration-tests/oidc/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java +++ b/integration-tests/oidc/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java @@ -75,7 +75,7 @@ public void testBasicAuthWrongPassword() { .when().get("/api/users/me") .then() .statusCode(401) - .header("WWW-Authenticate", equalTo("basic realm=\\"Quarkus\\"")); + .header("WWW-Authenticate", equalTo("basic")); } @Test @@ -144,7 +144,7 @@ public void testVerificationFailedNoBearerTokenAndBasicCreds() { RestAssured.given() .when().get("/api/users/me").then() .statusCode(401) - .header("WWW-Authenticate", equalTo("basic realm=\\"Quarkus\\"")); + .header("WWW-Authenticate", equalTo("basic")); } @Test @@ -171,7 +171,7 @@ public void testBearerAuthFailureWhereBasicIsRequired() { .when().get("/basic-only") .then() .statusCode(401) - .header("WWW-Authenticate", equalTo("basic realm=\\"Quarkus\\"")); + .header("WWW-Authenticate", equalTo("basic")); } @Test
['integration-tests/oidc/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/AuthConfig.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java']
{'.java': 5}
5
5
0
0
5
22,232,692
4,351,819
566,850
5,301
571
114
9
3
702
105
170
41
0
0
1970-01-01T00:27:40
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,376
quarkusio/quarkus/27497/27229
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27229
https://github.com/quarkusio/quarkus/pull/27497
https://github.com/quarkusio/quarkus/pull/27497
1
solve
Broken context propagation in HTTP request that involves hibernate-reactive-panache, resteasy-reactive and qute
### Describe the bug The CDI request context is not active when a template (that leverages a `@RequestScoped` bean) is rendered in a `Uni` chain: ```java @GET public Uni<TemplateInstance> get(@QueryParam("id") Long id) { // Fruit extends io.quarkus.hibernate.reactive.panache.PanacheEntity return Fruit.findById(id).onItem().transform(f -> Templates.fruit((Fruit) f)); } ``` ### How to Reproduce? 1. Checkout [this quarkus-quickstarts branch](https://github.com/mkouba/quarkus-quickstarts/tree/req-context-not-active) 2. Run the modified `hibernate-reactive-panache-quickstart` in the dev mode (can be reproduced in the prod mode as well) 3. HTTP GET `http://localhost:8080/test/template?id=1` You should see a `ContextNotActiveException` in the console. UPDATE: I've added two more simplified resource methods which produce a slightly different error: ``` javax.enterprise.inject.IllegalProductException: Normal scoped producer method may not return null: io.quarkus.vertx.http.runtime.CurrentVertxRequest.getCurrent() ``` It seems that the request context is active but the `CurrentVertxRequest` bean instance is not propagated. How to get this error: 1. HTTP GET `http://localhost:8080/test/simple?id=1` - this one does not involve a qute template 2. HTTP GET `http://localhost:8080/test/no-hibernate?id=1` - this one does not involve `hibernate-reactive-panache` It might be as well a PEBKAC on my side. I would be more than happy if someone explains to me what's going on here ;-)
da0581f3047d547400d7fc323b9ed86ebc792130
edfd6114cd0345d7bb2083b88dff87e97e8833f9
https://github.com/quarkusio/quarkus/compare/da0581f3047d547400d7fc323b9ed86ebc792130...edfd6114cd0345d7bb2083b88dff87e97e8833f9
diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/runtime/src/main/java/io/quarkus/resteasy/reactive/qute/runtime/TemplateResponseUniHandler.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/runtime/src/main/java/io/quarkus/resteasy/reactive/qute/runtime/TemplateResponseUniHandler.java index 10b7dc86e0e..ebf2667b445 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/runtime/src/main/java/io/quarkus/resteasy/reactive/qute/runtime/TemplateResponseUniHandler.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/runtime/src/main/java/io/quarkus/resteasy/reactive/qute/runtime/TemplateResponseUniHandler.java @@ -24,6 +24,8 @@ public void handle(ResteasyReactiveRequestContext requestContext) { return; } + requestContext.requireCDIRequestScope(); + if (engine == null) { synchronized (this) { if (engine == null) {
['extensions/resteasy-reactive/quarkus-resteasy-reactive-qute/runtime/src/main/java/io/quarkus/resteasy/reactive/qute/runtime/TemplateResponseUniHandler.java']
{'.java': 1}
1
1
0
0
1
22,289,674
4,362,739
568,273
5,309
51
9
2
1
1,557
180
385
34
4
2
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,375
quarkusio/quarkus/27498/27083
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27083
https://github.com/quarkusio/quarkus/pull/27498
https://github.com/quarkusio/quarkus/pull/27498
1
fix
RESTEasy Reactive - Server side multipart implementation is not being respected
### Describe the bug We have a multipart endpoint which accepts two parts handled as Strings such as this: ``` public class MultipartUpload { @RestForm @PartType(MediaType.TEXT_PLAIN) public String textPart; @RestForm @PartType(MediaType.APPLICATION_OCTET_STREAM) public String anotherTextPart; } ``` This is after we migrated to RESTEasy Reactive. With the exception of anotherTextPart being of type InputStream instead nothing has really changed since then, so essentially a multipart where we're not interested in working with the parts as files. What we weren't aware of was that some of our users are sending us parts with a filename provided, and whenever they do these two parts end up as null. I've tried looking into the implementation and it kind of looks like the MultipartParser will store everything into a file whenever a filename is provided. Haven't really understood the code completely but my guess is that the implementation will then fail to retrieve the data that was read unless the multipart is defined with File types. But I might be wrong here though. Looking at the [RFC-2183](https://datatracker.ietf.org/doc/html/rfc2183#section-2.3) for the Content-Disposition header, this behavior does not seem in line with the specification: > The presence of the filename parameter does not force an > implementation to write the entity to a separate file. It is > perfectly acceptable for implementations to leave the entity as part > of the normal mail stream unless the user requests otherwise. As a > consequence, the parameter may be used on any MIME entity, even > `inline' ones. These will not normally be written to files, but the > parameter could be used to provide a filename if the receiving user > should choose to write the part to a file. The users haven't changed anything in their implementation so it seems pretty evident that this has changed between Classic and Reactive. ### Expected behavior The server side implementation should be respected regardless of what the client sends. Unless a RESTEasy server multipart has implemented it, don't write parts of a multipart request to file, even if the Content-Disposition includes a filename. The request should still work as if the client had not provided a file name for the part in question, and such is the case in Classic. ### Actual behavior If a client sends a part with filename in the Content-Disposition header, the receiving end implementation writes the data to a file regardless of what the server side multipart implementation looks like. However, if the server side does not implement the part as a file it will not be able to retrieve the data for further use, i.e the part becomes null. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
885e25ef24d27874b3c93f8e44fd9964b5a66bf7
1600494b9dbe3582a997da6b85bf8b96e78ece67
https://github.com/quarkusio/quarkus/compare/885e25ef24d27874b3c93f8e44fd9964b5a66bf7...1600494b9dbe3582a997da6b85bf8b96e78ece67
diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java index 333226f0a9b..22c7a845d41 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java @@ -2,9 +2,15 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.stream.Collectors; import javax.enterprise.context.ApplicationScoped; import javax.ws.rs.Consumes; @@ -57,6 +63,45 @@ void shouldUseFileNameFromAnnotation() throws IOException { assertThat(client.postMultipartWithPartFilename(form)).isEqualTo(ClientForm2.FILE_NAME); } + @Test + void shouldCopyFileContentToString() throws IOException { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + + File file = File.createTempFile("MultipartTest", ".txt"); + Files.writeString(file.toPath(), "content!"); + file.deleteOnExit(); + + ClientForm form = new ClientForm(); + form.file = file; + assertThat(client.postMultipartWithFileContent(form)).isEqualTo("content!"); + } + + @Test + void shouldCopyFileContentToBytes() throws IOException { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + + File file = File.createTempFile("MultipartTest", ".txt"); + Files.writeString(file.toPath(), "content!"); + file.deleteOnExit(); + + ClientForm form = new ClientForm(); + form.file = file; + assertThat(client.postMultipartWithFileContentAsBytes(form)).isEqualTo("content!"); + } + + @Test + void shouldCopyFileContentToInputStream() throws IOException { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + + File file = File.createTempFile("MultipartTest", ".txt"); + Files.writeString(file.toPath(), "content!"); + file.deleteOnExit(); + + ClientForm form = new ClientForm(); + form.file = file; + assertThat(client.postMultipartWithFileContentAsInputStream(form)).isEqualTo("content!"); + } + @Path("/multipart") @ApplicationScoped public static class Resource { @@ -65,12 +110,52 @@ public static class Resource { public String upload(@MultipartForm FormData form) { return form.myFile.fileName(); } + + @POST + @Path("/file-content") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public String uploadWithFileContent(@MultipartForm FormDataWithFileContent form) { + return form.fileContent; + } + + @POST + @Path("/file-content-as-bytes") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public String uploadWithFileContentAsBytes(@MultipartForm FormDataWithBytes form) { + return new String(form.fileContentAsBytes); + } + + @POST + @Path("/file-content-as-inputstream") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public String uploadWithFileContentAsInputStream(@MultipartForm FormDataWithInputStream form) { + return new BufferedReader(new InputStreamReader(form.fileContentAsInputStream, StandardCharsets.UTF_8)) + .lines() + .collect(Collectors.joining(System.lineSeparator())); + } } public static class FormData { @FormParam("myFile") public FileUpload myFile; + } + public static class FormDataWithFileContent { + @FormParam("myFile") + @PartType(MediaType.APPLICATION_OCTET_STREAM) + public String fileContent; + } + + public static class FormDataWithBytes { + @FormParam("myFile") + @PartType(MediaType.APPLICATION_OCTET_STREAM) + public byte[] fileContentAsBytes; + } + + public static class FormDataWithInputStream { + @FormParam("myFile") + @PartType(MediaType.APPLICATION_OCTET_STREAM) + public InputStream fileContentAsInputStream; } @Path("/multipart") @@ -82,6 +167,21 @@ public interface Client { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) String postMultipartWithPartFilename(@MultipartForm ClientForm2 clientForm); + + @POST + @Path("/file-content") + @Consumes(MediaType.MULTIPART_FORM_DATA) + String postMultipartWithFileContent(@MultipartForm ClientForm clientForm); + + @POST + @Path("/file-content-as-bytes") + @Consumes(MediaType.MULTIPART_FORM_DATA) + String postMultipartWithFileContentAsBytes(@MultipartForm ClientForm clientForm); + + @POST + @Path("/file-content-as-inputstream") + @Consumes(MediaType.MULTIPART_FORM_DATA) + String postMultipartWithFileContentAsInputStream(@MultipartForm ClientForm clientForm); } public static class ClientForm { diff --git a/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/MultipartPopulatorGenerator.java b/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/MultipartPopulatorGenerator.java index ef0f652e40b..68418ada79c 100644 --- a/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/MultipartPopulatorGenerator.java +++ b/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/MultipartPopulatorGenerator.java @@ -13,6 +13,7 @@ import io.quarkus.gizmo.MethodDescriptor; import io.quarkus.gizmo.ResultHandle; import java.io.File; +import java.io.InputStream; import java.lang.reflect.Modifier; import java.nio.file.Path; import java.util.ArrayList; @@ -241,11 +242,10 @@ public static String generate(ClassInfo multipartClassInfo, ClassOutput classOut "Setter '" + setterName + "' of class '" + multipartClassInfo + "' must be public"); } - if (fieldDotName.equals(DotNames.INPUT_STREAM_NAME) - || fieldDotName.equals(DotNames.INPUT_STREAM_READER_NAME)) { + if (fieldDotName.equals(DotNames.INPUT_STREAM_READER_NAME)) { // don't support InputStream as it's too easy to get into trouble throw new IllegalArgumentException( - "InputStream and InputStreamReader are not supported as a field type of a Multipart POJO class. Offending field is '" + "InputStreamReader are not supported as a field type of a Multipart POJO class. Offending field is '" + field.name() + "' of class '" + multipartClassName + "'"); } @@ -332,6 +332,33 @@ public static String generate(ClassInfo multipartClassInfo, ClassOutput classOut rrCtxHandle); populate.assign(resultVariableHandle, allFileUploadsHandle); } + } else if (partType.equals(MediaType.APPLICATION_OCTET_STREAM)) { + if (fieldType.kind() == Type.Kind.ARRAY + && fieldType.asArrayType().component().name().equals(DotNames.BYTE_NAME)) { + populate.assign(resultVariableHandle, + populate.invokeStaticMethod(MethodDescriptor.ofMethod(MultipartSupport.class, + "getSingleFileUploadAsArrayBytes", byte[].class, String.class, + ResteasyReactiveRequestContext.class), + formAttrNameHandle, rrCtxHandle)); + } else if (fieldDotName.equals(DotNames.INPUT_STREAM_NAME)) { + populate.assign(resultVariableHandle, + populate.invokeStaticMethod(MethodDescriptor.ofMethod(MultipartSupport.class, + "getSingleFileUploadAsInputStream", InputStream.class, String.class, + ResteasyReactiveRequestContext.class), + formAttrNameHandle, rrCtxHandle)); + } else if (fieldDotName.equals(DotNames.STRING_NAME)) { + populate.assign(resultVariableHandle, + populate.invokeStaticMethod(MethodDescriptor.ofMethod(MultipartSupport.class, + "getSingleFileUploadAsString", String.class, String.class, + ResteasyReactiveRequestContext.class), + formAttrNameHandle, rrCtxHandle)); + } else { + throw new IllegalArgumentException( + "Unsupported type to read multipart file contents. Offending field is '" + + field.name() + "' of class '" + + field.declaringClass().name() + + "'. If you need to read the contents of the uploaded file, use 'Path' or 'File' as the field type and use File IO APIs to read the bytes, while making sure you annotate the endpoint with '@Blocking'"); + } } else { // this is a common enough mistake, so let's provide a good error message failIfFileTypeUsedAsGenericType(field, fieldType, fieldDotName); diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java index f598d3eaf44..5af3b1b30a7 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java @@ -2,16 +2,20 @@ import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import javax.ws.rs.BadRequestException; import javax.ws.rs.NotSupportedException; import javax.ws.rs.RuntimeType; import javax.ws.rs.core.MediaType; @@ -102,6 +106,55 @@ public static Object convertFormAttribute(String value, Class type, Type generic throw new NotSupportedException("Media type '" + mediaType + "' in multipart request is not supported"); } + public static String getSingleFileUploadAsString(String formName, ResteasyReactiveRequestContext context) { + DefaultFileUpload upload = getSingleFileUpload(formName, context); + if (upload != null) { + try { + return Files.readString(upload.filePath(), Charset.defaultCharset()); + } catch (IOException e) { + throw new MultipartPartReadingException(e); + } + } + + return null; + } + + public static byte[] getSingleFileUploadAsArrayBytes(String formName, ResteasyReactiveRequestContext context) { + DefaultFileUpload upload = getSingleFileUpload(formName, context); + if (upload != null) { + try { + return Files.readAllBytes(upload.filePath()); + } catch (IOException e) { + throw new MultipartPartReadingException(e); + } + } + + return null; + } + + public static InputStream getSingleFileUploadAsInputStream(String formName, ResteasyReactiveRequestContext context) { + DefaultFileUpload upload = getSingleFileUpload(formName, context); + if (upload != null) { + try { + return new FileInputStream(upload.filePath().toFile()); + } catch (IOException e) { + throw new MultipartPartReadingException(e); + } + } + + return null; + } + + public static DefaultFileUpload getSingleFileUpload(String formName, ResteasyReactiveRequestContext context) { + List<DefaultFileUpload> uploads = getFileUploads(formName, context); + if (uploads.size() > 1) { + throw new BadRequestException("Found more than one files for attribute '" + formName + "'. Expected only one file"); + } else if (uploads.size() == 1) { + return uploads.get(0); + } + return null; + } + public static DefaultFileUpload getFileUpload(String formName, ResteasyReactiveRequestContext context) { List<DefaultFileUpload> uploads = getFileUploads(formName, context); if (!uploads.isEmpty()) {
['independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/multipart/MultipartPopulatorGenerator.java', 'independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java']
{'.java': 3}
3
3
0
0
3
22,293,800
4,363,623
568,361
5,309
5,039
837
86
2
3,155
491
656
74
1
1
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,374
quarkusio/quarkus/27548/27549
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27549
https://github.com/quarkusio/quarkus/pull/27548
https://github.com/quarkusio/quarkus/pull/27548
1
fixes
Null Pointer Exception Attempting to Watch Change Stream in Database with ChangeStreamOptions
### Describe the bug If you supply a ChangeStreamOptions parameter to the watch() method of a Reactive Mongo Database for example in order to resume a change stream after a certain token the watch method returns null. This appears to be an oversight in the implementation, as the Collection equivalent works as expected. I.e. this works: ``` this.mongoClient .getDatabase(databaseName) .getCollection(collectionName) .watch(pipeline, Document.class, options); ``` But this returns null: ``` this.mongoClient .getDatabase(databaseName) .watch(pipeline, Document.class, options); ``` ### Expected behavior Supplying a ChangeStreamOptions parameter to the watch method, e.g.: ``` this.mongoClient .getDatabase(databaseName) .watch(pipeline, Document.class, options); ``` Would create a watch on the change stream of the database, and return a valid Multi. ### Actual behavior The method returns null. ### How to Reproduce? To reproduce: ``` ChangeStreamOptions options = new ChangeStreamOptions(); var watch = this.reactiveMongoClient .getDatabase(databaseName) .getCollection(collectionName) .watch(Document.class, options); Assertions.notNull("Change Stream Watch", watch); ``` ### Output of `uname -a` or `ver` Darwin ip-192-168-1-4.eu-central-1.compute.internal 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64 ### Output of `java -version` java version "17.0.1" 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/lthompson/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home Default locale: en_AU, platform encoding: UTF-8 OS name: "mac os x", version: "12.4", arch: "aarch64", family: "mac" ### Additional information _No response_
bb78a8b2b883dfdff0e0656de4c0eb55476dc4ea
76fb7499aab16bb279e6d2c5b0a502d16922ba25
https://github.com/quarkusio/quarkus/compare/bb78a8b2b883dfdff0e0656de4c0eb55476dc4ea...76fb7499aab16bb279e6d2c5b0a502d16922ba25
diff --git a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoDatabaseImpl.java b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoDatabaseImpl.java index 42756a44562..fc99cdeebcb 100644 --- a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoDatabaseImpl.java +++ b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoDatabaseImpl.java @@ -10,6 +10,7 @@ import com.mongodb.client.model.CreateViewOptions; import com.mongodb.client.model.changestream.ChangeStreamDocument; import com.mongodb.reactivestreams.client.AggregatePublisher; +import com.mongodb.reactivestreams.client.ChangeStreamPublisher; import com.mongodb.reactivestreams.client.ClientSession; import com.mongodb.reactivestreams.client.ListCollectionsPublisher; import com.mongodb.reactivestreams.client.MongoDatabase; @@ -217,7 +218,14 @@ public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz) { @Override public <T> Multi<ChangeStreamDocument<T>> watch(Class<T> clazz, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(clazz))); + } + + private <D> ChangeStreamPublisher<D> apply(ChangeStreamOptions options, ChangeStreamPublisher<D> watch) { + if (options == null) { + return watch; + } + return options.apply(watch); } @Override @@ -227,7 +235,7 @@ public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline @Override public Multi<ChangeStreamDocument<Document>> watch(List<? extends Bson> pipeline, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(pipeline))); } @Override @@ -238,7 +246,7 @@ public <T> Multi<ChangeStreamDocument<T>> watch(List<? extends Bson> pipeline, C @Override public <T> Multi<ChangeStreamDocument<T>> watch(List<? extends Bson> pipeline, Class<T> clazz, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(pipeline, clazz))); } @Override @@ -248,7 +256,7 @@ public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession) @Override public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(clientSession))); } @Override @@ -259,7 +267,7 @@ public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Cla @Override public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Class<T> clazz, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(clientSession, clazz))); } @Override @@ -270,7 +278,7 @@ public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, @Override public Multi<ChangeStreamDocument<Document>> watch(ClientSession clientSession, List<? extends Bson> pipeline, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(clientSession, pipeline))); } @Override @@ -282,7 +290,7 @@ public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, Lis @Override public <T> Multi<ChangeStreamDocument<T>> watch(ClientSession clientSession, List<? extends Bson> pipeline, Class<T> clazz, ChangeStreamOptions options) { - return null; + return Wrappers.toMulti(apply(options, database.watch(clientSession, pipeline, clazz))); } @Override
['extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/impl/ReactiveMongoDatabaseImpl.java']
{'.java': 1}
1
1
0
0
1
22,309,312
4,366,450
568,719
5,310
1,037
203
22
1
2,446
254
637
77
0
4
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,373
quarkusio/quarkus/27559/27489
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27489
https://github.com/quarkusio/quarkus/pull/27559
https://github.com/quarkusio/quarkus/pull/27559
1
fix
Mutiny Dropped Exception on SSE Cancel
### Describe the bug Undesirable `ERROR` message appears in logs, e.g: `2022-08-25 11:30:51,013 ERROR [io.qua.mut.run.MutinyInfrastructure] (vert.x-eventloop-thread-2) Mutiny had to drop the following exception: io.vertx.core.http.HttpClosedException: Connection was closed` ### Expected behavior Would prefer not to have these appearing in Production logs. Can they be avoided or suppressed? ### Actual behavior _No response_ ### How to Reproduce? https://github.com/jimbogithub/mutiny-sse Run the server and the client. Observe client logs. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information Mutiny SSE otherwise looks much better than legacy SSE (https://github.com/quarkusio/quarkus/issues/23997).
708c19c528f5be0abab53077b52b5899a644f799
d87622458521c8cafe2c34217b7bab7f3741c6e5
https://github.com/quarkusio/quarkus/compare/708c19c528f5be0abab53077b52b5899a644f799...d87622458521c8cafe2c34217b7bab7f3741c6e5
diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java index 0b17f299d25..6ae2a510969 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java @@ -59,6 +59,26 @@ public MultiRequest(MultiEmitter<? super R> emitter) { }); } + void emit(R item) { + if (!isCancelled()) { + emitter.emit(item); + } + } + + void fail(Throwable t) { + if (!isCancelled()) { + emitter.fail(t); + cancel(); + } + } + + void complete() { + if (!isCancelled()) { + emitter.complete(); + cancel(); + } + } + public boolean isCancelled() { return onCancel.get() == CLEARED; } @@ -130,20 +150,20 @@ private <R> void registerForSse(MultiRequest<? super R> multiRequest, // For now we don't want multi to reconnect SseEventSourceImpl sseSource = new SseEventSourceImpl(invocationBuilder.getTarget(), invocationBuilder, Integer.MAX_VALUE, TimeUnit.SECONDS); - // FIXME: deal with cancellation + + multiRequest.onCancel(() -> { + sseSource.close(); + }); sseSource.register(event -> { // DO NOT pass the response mime type because it's SSE: let the event pick between the X-SSE-Content-Type header or // the content-type SSE field - multiRequest.emitter.emit((R) event.readData(responseType)); + multiRequest.emit(event.readData(responseType)); }, error -> { - multiRequest.emitter.fail(error); + multiRequest.fail(error); }, () -> { - multiRequest.emitter.complete(); + multiRequest.complete(); }); // watch for user cancelling - multiRequest.onCancel(() -> { - sseSource.close(); - }); sseSource.registerAfterRequest(vertxResponse); }
['independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java']
{'.java': 1}
1
1
0
0
1
22,311,903
4,366,952
568,777
5,310
958
163
34
1
985
124
248
43
2
0
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,372
quarkusio/quarkus/27576/27377
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27377
https://github.com/quarkusio/quarkus/pull/27576
https://github.com/quarkusio/quarkus/pull/27576
1
fixes
Regression: `SRCFG00011: Could not expand value` exception
### Describe the bug There appears to be a regression in Quarkus 2.12.0.CR1 in the area of SmallRye Config. I have a simple application which only uses `quarkus-resteasy-reactive` and `quarkus-security` and the following `application.properties` file: ```properties quarkus.http.auth.permission.quarkus.paths=${quarkus.http.non-application-root-path}/* quarkus.http.auth.permission.quarkus.policy=devops quarkus.http.auth.policy.devops.roles-allowed=DEVOPS ``` When starting up the application it fails with an exception with the following root cause: ``` Caused by: java.util.NoSuchElementException: SRCFG00011: Could not expand value quarkus.http.non-application-root-path in property quarkus.http.auth.permission.quarkus.paths at io.smallrye.config.ExpressionConfigSourceInterceptor$1.accept(ExpressionConfigSourceInterceptor.java:68) at io.smallrye.config.ExpressionConfigSourceInterceptor$1.accept(ExpressionConfigSourceInterceptor.java:58) at io.smallrye.common.expression.ExpressionNode.emit(ExpressionNode.java:22) at io.smallrye.common.expression.CompositeNode.emit(CompositeNode.java:22) at io.smallrye.common.expression.Expression.evaluateException(Expression.java:56) at io.smallrye.common.expression.Expression.evaluate(Expression.java:70) at io.smallrye.config.ExpressionConfigSourceInterceptor.getValue(ExpressionConfigSourceInterceptor.java:58) at io.smallrye.config.ExpressionConfigSourceInterceptor.getValue(ExpressionConfigSourceInterceptor.java:38) at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20) at io.smallrye.config.FallbackConfigSourceInterceptor.getValue(FallbackConfigSourceInterceptor.java:24) at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20) at io.smallrye.config.PropertyNamesConfigSourceInterceptor.getValue(PropertyNamesConfigSourceInterceptor.java:17) at io.smallrye.config.SmallRyeConfigSourceInterceptorContext.proceed(SmallRyeConfigSourceInterceptorContext.java:20) at io.smallrye.config.SmallRyeConfig.getConfigValue(SmallRyeConfig.java:307) at io.quarkus.runtime.configuration.ConfigRecorder.handleConfigChange(ConfigRecorder.java:40) at io.quarkus.deployment.steps.ConfigGenerationBuildStep$checkForBuildTimeConfigChange1532146938.deploy_4(Unknown Source) at io.quarkus.deployment.steps.ConfigGenerationBuildStep$checkForBuildTimeConfigChange1532146938.deploy(Unknown Source) ... 52 more ``` So somehow the value in the `quarkus.http.auth.permission.quarkus.paths=${quarkus.http.non-application-root-path}/*` cannot be expanded. In all earlier versions of Quarkus this worked. ### Expected behavior It seems like this should be allowed. ### Actual behavior Exception thrown at startup (see issue description). ### How to Reproduce? Reproduce: 1. Download and extract [code-with-quarkus.zip](https://github.com/quarkusio/quarkus/files/9380509/code-with-quarkus.zip) 2. Run `mvn verify` or `mvn quarkus:dev` 3. See logged exception ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.12.0.CR1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
547eb817d03089422c9f39b43f68a5a84d1ff01c
c344879a52af997712de54c90168871d10fc3bd5
https://github.com/quarkusio/quarkus/compare/547eb817d03089422c9f39b43f68a5a84d1ff01c...c344879a52af997712de54c90168871d10fc3bd5
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java index b2d5df56d5f..d338e053705 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java @@ -1,9 +1,11 @@ package io.quarkus.runtime.configuration; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.spi.ConfigSource; @@ -11,6 +13,8 @@ import io.quarkus.runtime.annotations.Recorder; import io.quarkus.runtime.configuration.ConfigurationRuntimeConfig.BuildTimeMismatchAtRuntime; +import io.smallrye.config.ConfigSourceInterceptorContext; +import io.smallrye.config.ExpressionConfigSourceInterceptor; import io.smallrye.config.SmallRyeConfig; import io.smallrye.config.SmallRyeConfigBuilder; @@ -26,18 +30,51 @@ public ConfigRecorder(ConfigurationRuntimeConfig configurationConfig) { } public void handleConfigChange(Map<String, ConfigValue> buildTimeRuntimeValues) { + // Create a new Config without the "BuildTime RunTime Fixed" sources to check for different values SmallRyeConfigBuilder configBuilder = ConfigUtils.emptyConfigBuilder(); + // We need to disable the expression resolution, because we may be missing expressions from the "BuildTime RunTime Fixed" source + configBuilder.withDefaultValue(Config.PROPERTY_EXPRESSIONS_ENABLED, "false"); for (ConfigSource configSource : ConfigProvider.getConfig().getConfigSources()) { if ("BuildTime RunTime Fixed".equals(configSource.getName())) { continue; } configBuilder.withSources(configSource); } + // Add a new expression resolution to fall back to the current Config if we cannot expand the expression + configBuilder.withInterceptors(new ExpressionConfigSourceInterceptor() { + @Override + public io.smallrye.config.ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name) { + return super.getValue(new ConfigSourceInterceptorContext() { + @Override + public io.smallrye.config.ConfigValue proceed(final String name) { + io.smallrye.config.ConfigValue configValue = context.proceed(name); + if (configValue == null) { + configValue = (io.smallrye.config.ConfigValue) ConfigProvider.getConfig().getConfigValue(name); + if (configValue.getValue() == null) { + return null; + } + } + return configValue; + } + + @Override + public Iterator<String> iterateNames() { + return context.iterateNames(); + } + + @Override + public Iterator<io.smallrye.config.ConfigValue> iterateValues() { + return context.iterateValues(); + } + }, name); + } + }); SmallRyeConfig config = configBuilder.build(); List<String> mismatches = new ArrayList<>(); for (Map.Entry<String, ConfigValue> entry : buildTimeRuntimeValues.entrySet()) { ConfigValue currentValue = config.getConfigValue(entry.getKey()); + // Check for changes. Also, we only have a change if the source ordinal is higher if (currentValue.getValue() != null && !entry.getValue().getValue().equals(currentValue.getValue()) && entry.getValue().getSourceOrdinal() < currentValue.getSourceOrdinal()) { mismatches.add( diff --git a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/config/BuildTimeRunTimeConfigTest.java b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/config/BuildTimeRunTimeConfigTest.java index 8e8f985f932..09e307bff0d 100644 --- a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/config/BuildTimeRunTimeConfigTest.java +++ b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/config/BuildTimeRunTimeConfigTest.java @@ -35,7 +35,9 @@ public class BuildTimeRunTimeConfigTest { return ShrinkWrap.create(JavaArchive.class) .addClasses(DevBean.class) - .addAsResource(new StringAsset(props + "\\nquarkus.application.name=my-app\\n"), + .addAsResource(new StringAsset(props + "\\n" + + "quarkus.application.name=my-app\\n" + + "quarkus.application.version=${quarkus.http.ssl.client-auth}"), "application.properties"); } catch (IOException e) { throw new RuntimeException(e); @@ -45,7 +47,7 @@ public class BuildTimeRunTimeConfigTest { @Test void buildTimeRunTimeConfig() { // A combination of QuarkusUnitTest and QuarkusProdModeTest tests ordering may mess with the port leaving it in - // 8081 and QuarkusDevModeTest does not changes to the right port. + // 8081 and QuarkusDevModeTest does not change to the right port. RestAssured.port = -1; RestAssured.when().get("/application").then()
['core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigRecorder.java', 'integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/config/BuildTimeRunTimeConfigTest.java']
{'.java': 2}
2
2
0
0
2
22,316,020
4,367,705
568,876
5,310
2,105
340
37
1
3,404
217
774
77
1
2
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,371
quarkusio/quarkus/27580/27487
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27487
https://github.com/quarkusio/quarkus/pull/27580
https://github.com/quarkusio/quarkus/pull/27580
1
fixes
"Directly injecting a ConfigProperty into a javax.ws.rs.ext.Provider may lead to unexpected results" warning for OidcClientRequestFilter in Quarkus 2.12
### Describe the bug Starting my app (in dev mode) logs the following message three times: > 2022-08-24 21:07:54,704 WARN [io.qua.arc.dep.ConfigBuildStep] (build-37) Directly injecting a org.eclipse.microprofile.config.inject.ConfigProperty into a javax.ws.rs.ext.Provider may lead to unexpected results. To ensure proper results, please change the type of the field to javax.enterprise.inject.Instance<java.util.Optional>. Offending field is 'clientName' of class 'io.quarkus.oidc.client.filter.OidcClientRequestFilter' This wasn't there in 2.11. Btw, we have two subclasses of that filter, e.g.: ```java /** * Filter that configures using {@code foobar} {@link NamedOidcClient} for accessing a rest api. * * @see <a href="https://github.com/quarkusio/quarkus/issues/16397">Quarkus: Enhance OidcClientFilter to select named OIDC clients</a> */ public class FoobarOidcClientRequestFilter extends OidcClientRequestFilter { @Override protected Optional<String> clientId() { return Optional.of("foobar"); // has to match configured oidc-client id } } ``` ### Expected behavior No such warning ### Actual behavior Warning pointing to Quarkus code (not even my own one) ### How to Reproduce? n/a for now ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.12.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Maven 3.8.6 ### Additional information _No response_
b7f85ce220a8cd56d6f709e7cb61e9ed67daa078
99e0134cf4cb9091a287d3cfd55508a181e73806
https://github.com/quarkusio/quarkus/compare/b7f85ce220a8cd56d6f709e7cb61e9ed67daa078...99e0134cf4cb9091a287d3cfd55508a181e73806
diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java index 7f8461e8e8a..2f2bf5cc46b 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java @@ -177,6 +177,7 @@ void validateConfigInjectionPoints(ValidationPhaseBuildItem validationPhase, || DotNames.OPTIONAL_INT.equals(injectedType.name()) || DotNames.OPTIONAL_LONG.equals(injectedType.name()) || DotNames.OPTIONAL_DOUBLE.equals(injectedType.name()) + || DotNames.INSTANCE.equals(injectedType.name()) || DotNames.PROVIDER.equals(injectedType.name()) || SUPPLIER_NAME.equals(injectedType.name()) || SR_CONFIG_VALUE_NAME.equals(injectedType.name()) diff --git a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java index fa93fe79baf..f470551e44d 100644 --- a/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java +++ b/extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java @@ -9,7 +9,9 @@ import java.util.OptionalInt; import java.util.OptionalLong; +import javax.enterprise.inject.Instance; import javax.inject.Inject; +import javax.inject.Provider; import javax.inject.Singleton; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -56,6 +58,9 @@ public void testOptionals() { assertFalse(usingOptionals.missingOptionalInt.isPresent()); assertFalse(usingOptionals.missingOptionalLong.isPresent()); assertFalse(usingOptionals.missingOptionalDouble.isPresent()); + + assertFalse(usingOptionals.instanceOptional.get().isPresent()); + assertFalse(usingOptionals.providerOptional.get().isPresent()); } @Singleton @@ -107,6 +112,13 @@ static class UsingOptionals { @Inject @ConfigProperty(name = "missing") OptionalDouble missingOptionalDouble; - } + @Inject + @ConfigProperty(name = "missing") + Instance<Optional<String>> instanceOptional; + + @Inject + @ConfigProperty(name = "missing") + Provider<Optional<String>> providerOptional; + } } diff --git a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java index 2c982efd17a..5da589248d3 100644 --- a/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java +++ b/extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java @@ -13,9 +13,9 @@ import javax.ws.rs.core.Response; import javax.ws.rs.ext.Provider; -import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.logging.Logger; +import io.quarkus.oidc.client.filter.runtime.OidcClientFilterConfig; import io.quarkus.oidc.client.runtime.AbstractTokensProducer; import io.quarkus.oidc.client.runtime.DisabledOidcClientException; import io.quarkus.oidc.common.runtime.OidcConstants; @@ -26,10 +26,8 @@ public class OidcClientRequestFilter extends AbstractTokensProducer implements ClientRequestFilter { private static final Logger LOG = Logger.getLogger(OidcClientRequestFilter.class); private static final String BEARER_SCHEME_WITH_SPACE = OidcConstants.BEARER_SCHEME + " "; - @Inject - @ConfigProperty(name = "quarkus.oidc-client-filter.client-name") - Optional<String> clientName; + OidcClientFilterConfig oidcClientFilterConfig; @Override public void filter(ClientRequestContext requestContext) throws IOException { @@ -50,6 +48,6 @@ private String getAccessToken() { } protected Optional<String> clientId() { - return clientName; + return oidcClientFilterConfig.clientName; } } diff --git a/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java b/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java index 8c8f22f025d..420fefbce27 100644 --- a/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java +++ b/extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java @@ -4,6 +4,7 @@ import java.io.IOException; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -56,11 +57,11 @@ public String hello(@Context HttpRequest request) { @Provider public static class MappingFilter implements ContainerRequestFilter { @Inject - Mapping mapping; + Instance<Mapping> mapping; @Override public void filter(final ContainerRequestContext requestContext) throws IOException { - requestContext.setProperty("mapping.hello", mapping.hello()); + requestContext.setProperty("mapping.hello", mapping.get().hello()); } } diff --git a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java index 8a1e5132fd9..b38f6a77f6c 100644 --- a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java +++ b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java @@ -1,5 +1,6 @@ package io.quarkus.it.smallrye.config; +import javax.enterprise.inject.Instance; import javax.inject.Inject; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; @@ -12,17 +13,17 @@ implements ExceptionMapper<ConfigurableExceptionMapper.ConfigurableExceptionMapperException> { @Inject @ConfigProperty(name = "exception.message") - String message; + Instance<String> message; @Inject - ExceptionConfig exceptionConfig; + Instance<ExceptionConfig> exceptionConfig; @Override public Response toResponse(final ConfigurableExceptionMapperException exception) { - if (!message.equals(exceptionConfig.message())) { + if (!message.get().equals(exceptionConfig.get().message())) { return Response.serverError().build(); } - return Response.ok().entity(message).build(); + return Response.ok().entity(message.get()).build(); } public static class ConfigurableExceptionMapperException extends RuntimeException {
['extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java', 'integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigurableExceptionMapper.java', 'extensions/oidc-client-filter/runtime/src/main/java/io/quarkus/oidc/client/filter/OidcClientRequestFilter.java', 'extensions/resteasy-classic/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/config/ConfigMappingWithProviderTest.java', 'extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigOptionalsTest.java']
{'.java': 5}
5
5
0
0
5
22,316,020
4,367,705
568,876
5,310
442
92
9
2
1,621
196
413
58
1
1
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,370
quarkusio/quarkus/27617/27352
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27352
https://github.com/quarkusio/quarkus/pull/27617
https://github.com/quarkusio/quarkus/pull/27617
1
fixes
RedPanda + kafka-streams stop working in upstream
### Describe the bug Related to commit: https://github.com/quarkusio/quarkus/commit/f9f8b9236683d21bc5fe39f505880ca46e96a133 Quarkus version: upstream Extension: quarkus-kafka-streams Kafka devService (Redpanda) is throwing the following error when is trying to consume a topic through Kafka streams ``` 10:06:11,786 INFO [app] Written offsets would not be recorded and no more records would be sent since this is a fatal error.: org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request. 10:06:11,787 INFO [app] 10:06:09,219 stream-thread [login-denied-aggregator-b69141f2-360b-414e-8877-694c6a43b22a-StreamThread-1] task [0_0] Failed to flush cache of store login-aggregation-store: : org.apache.kafka.streams.errors.StreamsException: Error encountered sending record to topic login-denied-aggregator-login-aggregation-store-changelog for task 0_0 due to: 10:06:11,788 INFO [app] org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request. 10:06:11,788 INFO [app] Written offsets would not be recorded and no more records would be sent since this is a fatal error. 10:06:11,789 INFO [app] at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.recordSendError(RecordCollectorImpl.java:209) 10:06:11,790 INFO [app] at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.lambda$send$0(RecordCollectorImpl.java:196) 10:06:11,791 INFO [app] at org.apache.kafka.clients.producer.KafkaProducer$InterceptorCallback.onCompletion(KafkaProducer.java:1418) 10:06:11,792 INFO [app] at org.apache.kafka.clients.producer.internals.ProducerBatch.completeFutureAndFireCallbacks(ProducerBatch.java:273) 10:06:11,793 INFO [app] at org.apache.kafka.clients.producer.internals.ProducerBatch.done(ProducerBatch.java:234) 10:06:11,794 INFO [app] at org.apache.kafka.clients.producer.internals.ProducerBatch.completeExceptionally(ProducerBatch.java:198) 10:06:11,794 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.failBatch(Sender.java:758) 10:06:11,795 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.failBatch(Sender.java:743) 10:06:11,796 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.failBatch(Sender.java:695) 10:06:11,796 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.completeBatch(Sender.java:634) 10:06:11,797 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.lambda$null$1(Sender.java:575) 10:06:11,797 INFO [app] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) 10:06:11,798 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.lambda$handleProduceResponse$2(Sender.java:562) 10:06:11,798 INFO [app] at java.base/java.lang.Iterable.forEach(Iterable.java:75) 10:06:11,799 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.handleProduceResponse(Sender.java:562) 10:06:11,800 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.lambda$sendProduceRequest$5(Sender.java:836) 10:06:11,800 INFO [app] at org.apache.kafka.clients.ClientResponse.onComplete(ClientResponse.java:109) 10:06:11,801 INFO [app] at org.apache.kafka.clients.NetworkClient.completeResponses(NetworkClient.java:583) 10:06:11,801 INFO [app] at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:575) 10:06:11,801 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:328) 10:06:11,802 INFO [app] at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:243) 10:06:11,802 INFO [app] at java.base/java.lang.Thread.run(Thread.java:829) 10:06:11,802 INFO [app] Caused by: org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request. ``` Could be related to Kafka 3.2.1 ### Expected behavior Events are consumed from a Kafka stream consumer ### Actual behavior Events are not consumed from a Kafka stream consumer ### How to Reproduce? `git clone git@github.com:quarkus-qe/quarkus-test-suite.git` `mvn clean verify -Dall-modules -pl messaging/kafka-streams-reactive-messaging -Dit.test=DevModeKafkaStreamIT#testAlertMonitorEventStream` Note: be sure that `testAlertMonitorEventStream` that is located on class `BaseKafkaStreamTest` is not disabled ### Output of `uname -a` or `ver` Linux localhost.localdomain 5.18.13-100.fc35.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 22 14:20:24 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment Temurin-11.0.16+8 (build 11.0.16+8) OpenJDK 64-Bit Server VM Temurin-11.0.16+8 (build 11.0.16+8, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev upstream ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.3 ### Additional information _No response_
8ad597b66b065ddd3b58e6c6bf350cbdf090b358
9b53e291373e88df377dae81ed4d393922c783c6
https://github.com/quarkusio/quarkus/compare/8ad597b66b065ddd3b58e6c6bf350cbdf090b358...9b53e291373e88df377dae81ed4d393922c783c6
diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java index af79c55869f..a0501b7093a 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java @@ -45,7 +45,7 @@ public class KafkaDevServicesBuildTimeConfig { * See https://github.com/strimzi/test-container and https://quay.io/repository/strimzi-test-container/test-container * <p> */ - @ConfigItem(defaultValue = "docker.io/vectorized/redpanda:v21.11.3") + @ConfigItem(defaultValue = "docker.io/vectorized/redpanda:v22.1.7") public String imageName; /** diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java index 265a113e8a1..e885b936d3b 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java @@ -57,6 +57,7 @@ protected void containerIsStarting(InspectContainerResponse containerInfo, boole command += "--memory 1G --overprovisioned --reserve-memory 0M "; command += String.format("--kafka-addr %s ", getKafkaAddresses()); command += String.format("--advertise-kafka-addr %s ", getKafkaAdvertisedAddresses()); + command += "--set redpanda.auto_create_topics_enabled=true "; if (redpandaConfig.transactionEnabled) { command += "--set redpanda.enable_idempotence=true "; command += "--set redpanda.enable_transactions=true ";
['extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java', 'extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java']
{'.java': 2}
2
2
0
0
2
22,328,612
4,370,066
569,205
5,313
216
58
3
2
5,174
396
1,408
82
1
1
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,369
quarkusio/quarkus/27633/27589
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27589
https://github.com/quarkusio/quarkus/pull/27633
https://github.com/quarkusio/quarkus/pull/27633
1
fix
Quarkus startup hangs after upgrade to version 2.11.x.Final
### Describe the bug After upgrading our services one of the service isn't starting up anymore, at first even the build hangs. The other services are working correctly, but this one repository ([CoMPAS SCL Validator](https://github.com/com-pas/compas-scl-validator)) doesn't work anymore. This repository is using a Library (RiseClipse) that's based on the Eclipse Framework and Eclipse OCL. To make it compile and run we are using the plugin 'tycho-eclipserun-plugin' to create a local maven mirror from a Eclipse P2 Site. Maybe this is causing the problem in the new version or the way the Eclipse Framework is working. First the build stopped at the goal 'generate-code-tests' from the Quarkus plugin. after adding some configuration (skipSourceGeneration) to the plugin ``` <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.platform.version}</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> <goal>generate-code-tests</goal> </goals> </execution> </executions> <configuration> <skipSourceGeneration>true</skipSourceGeneration> </configuration> </plugin> ``` The build continued but next hangs when trying to execute the HealthCheckTest where Quarkus is started and we first check if the server starts. In all situation the CPU is running at 100%, so something is happening. ### Expected behavior Build runs correctly and application starts. ### Actual behavior It look when the application tries to startup it comes in a loop, because the CPU stays at 100%. ### How to Reproduce? The problem is that it only occurs in this specific repository ([CoMPAS SCL Validator](https://github.com/com-pas/compas-scl-validator)) after upgrading from the latest 2.10.x.Final to all version of 2.1.x.Final. And see the Additional information, there isn't much info to go for. ### Output of `uname -a` or `ver` Linux ubuntu 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing) ### GraalVM version (if different from Java) - ### Quarkus version or git rev 2.11.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) ### Additional information In this PR [#98](https://github.com/com-pas/compas-scl-validator/pull/98) of the project I tried some different changes to make it work and investigate if I could figure out what is going wrong. When starting the application without executing the tests in development mode it stays running at 100% without any output. ``` [INFO] [INFO] --- quarkus-maven-plugin:2.11.3.Final:dev (default-cli) @ app --- ^C% ``` I needed to cancel the command to stop it. When setting the log level for test on debug this is the last logging that is shown ``` 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "GET /com-pas/*/org/eclipse/jdt/org.eclipse.jdt.annotation/maven-metadata.xml HTTP/1.1[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Cache-control: no-cache[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Pragma: no-cache[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "User-Agent: Apache-Maven/3.8.6 (Java 17.0.4; Linux 5.15.0-46-generic)[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Host: maven.pkg.github.com[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Connection: Keep-Alive[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "Authorization: Basic ZGxhYm9yZHVzOmdocF94SmFwcHZ3aDRYanc1RURwdDE0TUpBZjhkV0cyUHEzejBjTTA=[\\r][\\n]" 2022-08-30 11:06:21,224 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 >> "[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "HTTP/1.1 404 Not Found[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "access-control-allow-methods: GET, HEAD, OPTIONS[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Access-Control-Allow-Origin: *[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Content-Security-Policy: default-src 'none';[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Content-Type: text/plain; charset=utf-8[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Server: GitHub Registry[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Strict-Transport-Security: max-age=31536000;[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "X-Content-Type-Options: nosniff[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "X-Frame-Options: DENY[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Date: Tue, 30 Aug 2022 09:06:21 GMT[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "Content-Length: 143[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "X-GitHub-Request-Id: A99C:F9C0:62FE6:6950A:630DD30D[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "[\\r][\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.wire] (main) http-outgoing-0 << "unable to fetch maven-metadata for package : "maven package "org.eclipse.jdt.org.eclipse.jdt.annotation" does not exist under owner "com-pas""[\\n]" 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << HTTP/1.1 404 Not Found 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << access-control-allow-methods: GET, HEAD, OPTIONS 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Access-Control-Allow-Origin: * 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Content-Security-Policy: default-src 'none'; 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Content-Type: text/plain; charset=utf-8 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Server: GitHub Registry 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Strict-Transport-Security: max-age=31536000; 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << X-Content-Type-Options: nosniff 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << X-Frame-Options: DENY 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << X-XSS-Protection: 1; mode=block 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Date: Tue, 30 Aug 2022 09:06:21 GMT 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << Content-Length: 143 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.headers] (main) http-outgoing-0 << X-GitHub-Request-Id: A99C:F9C0:62FE6:6950A:630DD30D 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.imp.exe.MainClientExec] (main) Connection can be kept alive indefinitely 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.imp.aut.HttpAuthenticator] (main) Authentication succeeded 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.imp.cli.TargetAuthenticationStrategy] (main) Caching 'basic' auth scheme for https://maven.pkg.github.com:443 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.imp.con.PoolingHttpClientConnectionManager] (main) Connection [id: 0][route: {s}->https://maven.pkg.github.com:443] can be kept alive indefinitely 2022-08-30 11:06:21,445 DEBUG [org.apa.htt.imp.con.DefaultManagedHttpClientConnection] (main) http-outgoing-0: set socket timeout to 0 2022-08-30 11:06:21,446 DEBUG [org.apa.htt.imp.con.PoolingHttpClientConnectionManager] (main) Connection released: [id: 0][route: {s}->https://maven.pkg.github.com:443][total available: 2; route allocated: 1 of 20; total allocated: 2 of 40] 2022-08-30 11:06:21,446 DEBUG [org.ecl.aet.int.imp.TrackingFileManager] (main) Writing tracking file /home/dlabordus/.m2/repository/org/eclipse/jdt/org.eclipse.jdt.annotation/resolver-status.properties 2022-08-30 11:06:21,747 DEBUG [org.ecl.aet.int.imp.DefaultRemoteRepositoryManager] (main) Using mirror maven-default-http-blocker (http://0.0.0.0/) for jboss-public-repository-group (http://repository.jboss.org/nexus/content/groups/public/). 2022-08-30 11:06:21,841 DEBUG [org.ecl.aet.int.imp.DefaultRemoteRepositoryManager] (main) Using mirror maven-default-http-blocker (http://0.0.0.0/) for apache.snapshots (http://repository.apache.org/snapshots). 2022-08-30 11:06:21,856 DEBUG [org.ecl.aet.int.imp.DefaultRemoteRepositoryManager] (main) Using mirror maven-default-http-blocker (http://0.0.0.0/) for ow2-snapshot (http://repository.ow2.org/nexus/content/repositories/snapshots). ^C% ``` And then the CPU is again at 100% and I need to cancel the command.
8ad597b66b065ddd3b58e6c6bf350cbdf090b358
067e88811c98fcf75b38c92c32c283d11960ce01
https://github.com/quarkusio/quarkus/compare/8ad597b66b065ddd3b58e6c6bf350cbdf090b358...067e88811c98fcf75b38c92c32c283d11960ce01
diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java index e9e8c6d3d2a..fbae3d08f32 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java @@ -27,6 +27,7 @@ import java.util.Deque; import java.util.HashMap; import java.util.HashSet; +import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -282,28 +283,23 @@ private DependencyNode resolveRuntimeDeps(CollectRequest request) throws AppMode @Override public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) throws RepositoryException { - final Set<ArtifactKey> visited = new HashSet<>(); + final Map<DependencyNode, DependencyNode> visited = new IdentityHashMap<>(); for (DependencyNode c : node.getChildren()) { walk(c, visited); } return resolver.getSession().getDependencyGraphTransformer().transformGraph(node, context); } - private void walk(DependencyNode node, Set<ArtifactKey> visited) { - if (node.getChildren().isEmpty()) { + private void walk(DependencyNode node, Map<DependencyNode, DependencyNode> visited) { + if (visited.put(node, node) != null || node.getChildren().isEmpty()) { return; } final Set<ArtifactKey> deps = artifactDeps .computeIfAbsent(DependencyUtils.getCoords(node.getArtifact()), k -> new HashSet<>(node.getChildren().size())); for (DependencyNode c : node.getChildren()) { - final ArtifactKey key = getKey(c.getArtifact()); - if (!visited.add(key)) { - continue; - } - deps.add(key); + deps.add(getKey(c.getArtifact())); walk(c, visited); - visited.remove(key); } } });
['independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java']
{'.java': 1}
1
1
0
0
1
22,328,612
4,370,066
569,205
5,313
875
141
14
1
9,967
912
3,253
129
12
3
1970-01-01T00:27:41
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,367
quarkusio/quarkus/27764/27259
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27259
https://github.com/quarkusio/quarkus/pull/27764
https://github.com/quarkusio/quarkus/pull/27764
1
close
In a Gradle Quarkus application build, quarkusGenerateCode triggers a deprecation warning when sourcesJar is enabled
### Describe the bug In a simple Quarkus app build, by simply enabling sources JAR, Gradle produces deprecation warnings: ```groovy java { withSourcesJar() } ``` This is a sample of the error: ` Reason: Task ':app:sourcesJar' uses this output of task ':app:quarkusGenerateCode' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.1/userguide/validation_problems.html#implicit_dependency for more details about this problem. ` ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? Reproducer: https://github.com/jskillin-idt/quarkusio-quarkus-issues-27259 ### Output of `uname -a` or `ver` Linux jacob-ubuntu-dev 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-122.04) OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.4.1 ### Additional information _No response_
9423ba114bfb66525112ffd8bd99e09e1f7d640e
330fa4f8f7bbedbf9639c006c048e01463863356
https://github.com/quarkusio/quarkus/compare/9423ba114bfb66525112ffd8bd99e09e1f7d640e...330fa4f8f7bbedbf9639c006c048e01463863356
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java index 398111194bf..a30ec2aa012 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java @@ -233,6 +233,9 @@ private void registerTasks(Project project, QuarkusPluginExtension quarkusExt) { SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); + mainSourceSet.getJava().srcDirs(quarkusGenerateCode, quarkusGenerateCodeDev); + testSourceSet.getJava().srcDirs(quarkusGenerateCodeTests); + quarkusGenerateCode.configure(task -> task.setSourcesDirectories(getSourcesParents(mainSourceSet))); quarkusGenerateCodeDev.configure(task -> task.setSourcesDirectories(getSourcesParents(mainSourceSet))); quarkusGenerateCodeTests.configure(task -> task.setSourcesDirectories(getSourcesParents(testSourceSet)));
['devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/QuarkusPlugin.java']
{'.java': 1}
1
1
0
0
1
22,423,072
4,388,636
571,592
5,335
180
38
3
1
1,389
171
391
49
2
1
1970-01-01T00:27:42
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,366
quarkusio/quarkus/27802/27166
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27166
https://github.com/quarkusio/quarkus/pull/27802
https://github.com/quarkusio/quarkus/pull/27802
1
fixes
Connection pool exhaustion for lazy entity association (acquisition timeout)
### Describe the bug Hi guys! I've noticed that some async processing in our project exhausts a database connection pool, and it never recovers. The problem can be fixed by adding @Transactional annotation to @Incoming event handler, but 1) I am not changing anything in the database during this process, using only "findById" method and getting some info from an entity 2) for some methods, performance is the case, so I would rather not add transactional processing there Please check the reproducer. There are two related entities and two tests: 1) GreetingResourceTest: we are calling the HTTP endpoint repeatedly 50 times, and everything is ok. The connection pool works fine and gives us all entities to process 2) GreetingKafkaTest: we are sending an event to the topic and waiting for it to be processed. After the 4th repeat, it starts to fail because the connection pool max-size is set to 5 Please notice that when you set EAGER association between two entities, everything works fine for both tests. I believe something is wrong with releasing DB connection during async execution. ### Expected behavior LAZY association between entities works the same as EAGER one for non-transactional processing: connections are reused in the pool ### Actual behavior "Unable to acquire JDBC Connection" after some calls (max pool size) Caused by: java.sql.SQLException: Sorry, acquisition timeout! ### How to Reproduce? [cp-reproducer.zip](https://github.com/quarkusio/quarkus/files/9275380/cp-reproducer.zip) ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` java version "11.0.12" 2021-07-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.2 and smaller ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
c376d276fb4fc6642cf7191b00ed632dbfa846f2
0f32c84c61d0edd54223c69c7c5cdd8d37c0b313
https://github.com/quarkusio/quarkus/compare/c376d276fb4fc6642cf7191b00ed632dbfa846f2...0f32c84c61d0edd54223c69c7c5cdd8d37c0b313
diff --git a/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/SmallRyeReactiveMessagingLifecycle.java b/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/SmallRyeReactiveMessagingLifecycle.java index b42cd10fda0..8ad0e75d8dc 100644 --- a/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/SmallRyeReactiveMessagingLifecycle.java +++ b/extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/SmallRyeReactiveMessagingLifecycle.java @@ -10,6 +10,9 @@ import javax.inject.Inject; import javax.interceptor.Interceptor; +import io.quarkus.arc.Arc; +import io.quarkus.arc.InjectableContext; +import io.quarkus.arc.ManagedContext; import io.quarkus.runtime.StartupEvent; import io.smallrye.reactive.messaging.EmitterConfiguration; import io.smallrye.reactive.messaging.providers.extension.ChannelConfiguration; @@ -37,6 +40,14 @@ void onStaticInit(@Observes @Initialized(ApplicationScoped.class) Object event, } void onApplicationStart(@Observes @Priority(Interceptor.Priority.LIBRARY_BEFORE) StartupEvent event) { + // We do not want a request scope during the wiring, or it will be propagated and never terminated. + ManagedContext requestContext = Arc.container().requestContext(); + boolean isRequestScopeActive = requestContext.isActive(); + InjectableContext.ContextState state = null; + if (isRequestScopeActive) { + state = requestContext.getState(); + requestContext.deactivate(); + } try { mediatorManager.start(); } catch (Exception e) { @@ -44,6 +55,10 @@ void onApplicationStart(@Observes @Priority(Interceptor.Priority.LIBRARY_BEFORE) throw e; } throw new DeploymentException(e); + } finally { + if (state != null) { + requestContext.activate(state); + } } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ActivateRequestContextInterceptor.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ActivateRequestContextInterceptor.java index 284de44f354..44bb09bbe00 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ActivateRequestContextInterceptor.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ActivateRequestContextInterceptor.java @@ -1,6 +1,7 @@ package io.quarkus.arc.impl; import io.quarkus.arc.Arc; +import io.quarkus.arc.InjectableContext; import io.quarkus.arc.ManagedContext; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; @@ -38,14 +39,16 @@ private CompletionStage<?> invokeStage(InvocationContext ctx) { } return activate(requestContext) - .thenCompose(v -> proceedWithStage(ctx)) - .whenComplete((r, t) -> requestContext.terminate()); + .thenCompose(state -> proceedWithStage(ctx).whenComplete((r, t) -> { + requestContext.destroy(state); + requestContext.deactivate(); + })); } - private static CompletionStage<ManagedContext> activate(ManagedContext requestContext) { + private static CompletionStage<InjectableContext.ContextState> activate(ManagedContext requestContext) { try { requestContext.activate(); - return CompletableFuture.completedStage(requestContext); + return CompletableFuture.completedStage(requestContext.getState()); } catch (Throwable t) { return CompletableFuture.failedStage(t); } @@ -68,8 +71,13 @@ private Multi<?> invokeMulti(InvocationContext ctx) { return Multi.createFrom().deferred(() -> { requestContext.activate(); - return proceedWithMulti(ctx); - }).onTermination().invoke(requestContext::terminate); + InjectableContext.ContextState state = requestContext.getState(); + return proceedWithMulti(ctx) + .onTermination().invoke(() -> { + requestContext.destroy(state); + requestContext.deactivate(); + }); + }); }); } @@ -90,8 +98,13 @@ private Uni<?> invokeUni(InvocationContext ctx) { return Uni.createFrom().deferred(() -> { requestContext.activate(); - return proceedWithUni(ctx); - }).eventually(requestContext::terminate); + InjectableContext.ContextState state = requestContext.getState(); + return proceedWithUni(ctx) + .eventually(() -> { + requestContext.destroy(state); + requestContext.deactivate(); + }); + }); }); } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/contexts/request/propagation/ActivateRequestContextInterceptorTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/contexts/request/propagation/ActivateRequestContextInterceptorTest.java index bfb2e696b90..29766a92dbf 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/contexts/request/propagation/ActivateRequestContextInterceptorTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/contexts/request/propagation/ActivateRequestContextInterceptorTest.java @@ -13,6 +13,9 @@ import io.smallrye.mutiny.Uni; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.RequestScoped; import javax.enterprise.context.control.ActivateRequestContext; @@ -23,6 +26,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -32,74 +36,143 @@ public class ActivateRequestContextInterceptorTest { @RegisterExtension - public ArcTestContainer container = new ArcTestContainer(FakeSessionProducer.class, SessionClient.class); + public ArcTestContainer container = new ArcTestContainer(FakeSessionProducer.class, SessionClient.class, + ExecutorProducer.class, SessionClientCompletingOnDifferentThread.class); - InstanceHandle<SessionClient> clientHandler; + @Nested + class CompletingActivateRequestContext { - @BeforeEach - public void reset() { - FakeSession.state = INIT; - clientHandler = Arc.container().instance(SessionClient.class); - } + InstanceHandle<SessionClient> clientHandler; - @AfterEach - public void terminate() { - clientHandler.close(); - clientHandler.destroy(); - } + @BeforeEach + void reset() { + FakeSession.state = INIT; + clientHandler = Arc.container().instance(SessionClient.class); + } - @Test - public void testUni() throws Exception { - Assertions.assertEquals(INIT, FakeSession.getState()); - FakeSession.State result = clientHandler.get().openUniSession().await().indefinitely(); + @AfterEach + void terminate() { + clientHandler.close(); + clientHandler.destroy(); + } - // Closed in the dispose method - Assertions.assertEquals(CLOSED, FakeSession.getState()); - Assertions.assertEquals(OPENED, result); - } + @Test + public void testUni() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = clientHandler.get().openUniSession().await().indefinitely(); - @Test - public void testMulti() throws Exception { - Assertions.assertEquals(INIT, FakeSession.getState()); - FakeSession.State result = clientHandler.get().openMultiSession() - .toUni() - .await().indefinitely(); + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } - // Closed in the dispose method - Assertions.assertEquals(CLOSED, FakeSession.getState()); - Assertions.assertEquals(OPENED, result); - } + @Test + public void testMulti() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = clientHandler.get().openMultiSession() + .toUni() + .await().indefinitely(); - @Test - public void testFuture() throws Exception { - Assertions.assertEquals(INIT, FakeSession.getState()); - FakeSession.State result = clientHandler.get() - .openFutureSession().toCompletableFuture().join(); + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } - // Closed in the dispose method - Assertions.assertEquals(CLOSED, FakeSession.getState()); - Assertions.assertEquals(OPENED, result); - } + @Test + public void testFuture() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = clientHandler.get() + .openFutureSession().toCompletableFuture().join(); - @Test - public void testStage() throws Exception { - Assertions.assertEquals(INIT, FakeSession.getState()); - FakeSession.State result = clientHandler.get().openStageSession() - .toCompletableFuture().join(); + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } + + @Test + public void testStage() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = clientHandler.get().openStageSession() + .toCompletableFuture().join(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } + + @Test + public void testNonReactive() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = clientHandler.get().openSession(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } - // Closed in the dispose method - Assertions.assertEquals(CLOSED, FakeSession.getState()); - Assertions.assertEquals(OPENED, result); } - @Test - public void testNonReactive() throws Exception { - Assertions.assertEquals(INIT, FakeSession.getState()); - FakeSession.State result = clientHandler.get().openSession(); + @Nested + class AsyncCompletingActivateRequestContext { + + InstanceHandle<SessionClientCompletingOnDifferentThread> asyncClientHandler; + + @BeforeEach + void reset() { + FakeSession.state = INIT; + asyncClientHandler = Arc.container().instance(SessionClientCompletingOnDifferentThread.class); + } + + @AfterEach + void terminate() { + asyncClientHandler.close(); + asyncClientHandler.destroy(); + } + + @Test + public void testUni() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = asyncClientHandler.get().openUniSession().await().indefinitely(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } + + @Test + public void testMulti() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = asyncClientHandler.get().openMultiSession() + .toUni() + .await().indefinitely(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } + + @Test + public void testFuture() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = asyncClientHandler.get() + .openFutureSession().toCompletableFuture().join(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } + + @Test + public void testStage() throws Exception { + Assertions.assertEquals(INIT, FakeSession.getState()); + FakeSession.State result = asyncClientHandler.get().openStageSession() + .toCompletableFuture().join(); + + // Closed in the dispose method + Assertions.assertEquals(CLOSED, FakeSession.getState()); + Assertions.assertEquals(OPENED, result); + } - // Closed in the dispose method - Assertions.assertEquals(CLOSED, FakeSession.getState()); - Assertions.assertEquals(OPENED, result); } @ApplicationScoped @@ -139,6 +212,48 @@ public State openSession() { } } + @ApplicationScoped + static class SessionClientCompletingOnDifferentThread { + @Inject + FakeSession session; + + @Inject + Executor executor; + + @ActivateRequestContext + public Uni<State> openUniSession() { + return Uni.createFrom() + .item(() -> session) + .map(FakeSession::open) + .emitOn(executor); + } + + @ActivateRequestContext + public Multi<State> openMultiSession() { + return Multi.createFrom() + .item(() -> session) + .map(FakeSession::open) + .emitOn(executor); + } + + @ActivateRequestContext + public CompletionStage<State> openStageSession() { + return CompletableFuture.completedStage(session.open()) + .thenApplyAsync(s -> s, executor); + } + + @ActivateRequestContext + public CompletableFuture<State> openFutureSession() { + return CompletableFuture.completedFuture(session.open()) + .thenApplyAsync(s -> s, executor); + } + + @ActivateRequestContext + public State openSession() { + return session.open(); + } + } + static class FakeSession { enum State { INIT, @@ -177,4 +292,19 @@ void disposeSession(@Disposes FakeSession session) { } } + @Singleton + static class ExecutorProducer { + + @Produces + @ApplicationScoped + ExecutorService produceExecutor() { + return Executors.newSingleThreadExecutor(); + } + + void disposeSession(@Disposes ExecutorService executor) { + executor.shutdown(); + } + + } + }
['independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/contexts/request/propagation/ActivateRequestContextInterceptorTest.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ActivateRequestContextInterceptor.java', 'extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/SmallRyeReactiveMessagingLifecycle.java']
{'.java': 3}
3
3
0
0
3
22,442,621
4,392,371
572,039
5,338
2,304
370
44
2
2,076
299
492
53
1
0
1970-01-01T00:27:42
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,365
quarkusio/quarkus/27811/27698
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27698
https://github.com/quarkusio/quarkus/pull/27811
https://github.com/quarkusio/quarkus/pull/27811
1
fixes
'The supplier returned null' message if OIDC server connection fails
### Describe the bug Is it really fixed here https://github.com/quarkusio/quarkus/pull/26661 ? I am using oidc-client and followed this [guide](https://quarkus.io/guides/security-openid-connect-client-reference) for config. I am hitting head for many hours without knowing where is error and why NPE. I don't know why there is no explicit message. **Error:** {"timestamp":"2022-09-02T15:22:14.35Z","sequence":99,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus.runtime.Application","level":"ERROR","message":"Failed to start application (with profile prod)","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"powo-backend-staging-7c8f5f7787-vf7xb","processName":"quarkus-run.jar","processId":1,"stackTrace":"java.lang.NullPointerException: The supplier returned `null`\\n\\tat io.smallrye.mutiny.operators.uni.UniOnFailureTransform$UniOnFailureTransformProcessor.onFailure(UniOnFailureTransform.java:62)\\n\\tat io.smallrye.mutiny.operators.uni.builders.UniCreateFromPublisher$PublisherSubscriber.onError(UniCreateFromPublisher.java:81)\\n\\tat io.smallrye.mutiny.helpers.HalfSerializer.onError(HalfSerializer.java:56)\\n\\tat io.smallrye.mutiny.helpers.StrictMultiSubscriber.onFailure(StrictMultiSubscriber.java:91)\\n\\tat io.smallrye.mutiny.subscription.MultiSubscriber.onError(MultiSubscriber.java:73)\\n\\tat io.smallrye.mutiny.subscription.SerializedSubscriber.onFailure(SerializedSubscriber.java:102)\\n\\tat io.smallrye.mutiny.operators.multi.MultiRetryWhenOp$RetryWhenOperator.testOnFailurePredicate(MultiRetryWhenOp.java:136)\\n\\tat io.smallrye.mutiny.operators.multi.MultiRetryWhenOp$RetryWhenOperator.onFailure(MultiRetryWhenOp.java:119)\\n\\tat io.smallrye.mutiny.subscription.MultiSubscriber.onError(MultiSubscriber.java:73)\\n\\tat io.smallrye.mutiny.converters.uni.UniToMultiPublisher$UniToMultiSubscription.onFailure(UniToMultiPublisher.java:103)\\n\\tat io.smallrye.mutiny.operators.uni.UniOperatorProcessor.onFailure(UniOperatorProcessor.java:54)\\n\\tat io.smallrye.mutiny.vertx.AsyncResultUni.lambda$subscribe$1(AsyncResultUni.java:37)\\n\\tat io.smallrye.mutiny.vertx.DelegatingHandler.handle(DelegatingHandler.java:25)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.handleFailure(HttpContext.java:386)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.execute(HttpContext.java:380)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.next(HttpContext.java:355)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.fire(HttpContext.java:322)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.fail(HttpContext.java:303)\\n\\tat io.vertx.ext.web.client.impl.HttpContext.lambda$handleCreateRequest$6(HttpContext.java:486)\\n\\tat io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153)\\n\\tat io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)\\n\\tat io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)\\n\\tat io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23)\\n\\tat io.vertx.core.http.impl.HttpClientImpl.lambda$doRequest$8(HttpClientImpl.java:645)\\n\\tat io.vertx.core.net.impl.pool.Endpoint.lambda$getConnection$0(Endpoint.java:52)\\n\\tat io.vertx.core.http.impl.SharedClientHttpStreamEndpoint$Request.handle(SharedClientHttpStreamEndpoint.java:162)\\n\\tat io.vertx.core.http.impl.SharedClientHttpStreamEndpoint$Request.handle(SharedClientHttpStreamEndpoint.java:123)\\n\\tat io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:55)\\n\\tat io.vertx.core.impl.ContextBase.emit(ContextBase.java:239)\\n\\tat io.vertx.core.net.impl.pool.SimpleConnectionPool$ConnectFailed$1.run(SimpleConnectionPool.java:384)\\n\\tat io.vertx.core.net.impl.pool.CombinerExecutor.submit(CombinerExecutor.java:50)\\n\\tat io.vertx.core.net.impl.pool.SimpleConnectionPool.execute(SimpleConnectionPool.java:245)\\n\\tat io.vertx.core.net.impl.pool.SimpleConnectionPool.lambda$connect$2(SimpleConnectionPool.java:259)\\n\\tat io.vertx.core.http.impl.SharedClientHttpStreamEndpoint.lambda$connect$2(SharedClientHttpStreamEndpoint.java:104)\\n\\tat io.vertx.core.impl.future.FutureImpl$3.onFailure(FutureImpl.java:153)\\n\\tat io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)\\n\\tat io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)\\n\\tat io.vertx.core.impl.future.Composition$1.onFailure(Composition.java:66)\\n\\tat io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)\\n\\tat io.vertx.core.impl.future.FailedFuture.addListener(FailedFuture.java:98)\\n\\tat io.vertx.core.impl.future.Composition.onFailure(Composition.java:55)\\n\\tat io.vertx.core.impl.future.FutureBase.emitFailure(FutureBase.java:75)\\n\\tat io.vertx.core.impl.future.FutureImpl.tryFail(FutureImpl.java:230)\\n\\tat io.vertx.core.impl.future.PromiseImpl.tryFail(PromiseImpl.java:23)\\n\\tat io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:55)\\n\\tat io.vertx.core.impl.ContextBase.emit(ContextBase.java:239)\\n\\tat io.vertx.core.net.impl.NetClientImpl.failed(NetClientImpl.java:302)\\n\\tat io.vertx.core.net.impl.NetClientImpl.lambda$connectInternal$4(NetClientImpl.java:270)\\n\\tat io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)\\n\\tat io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552)\\n\\tat io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)\\n\\tat io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:184)\\n\\tat io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:35)\\n\\tat io.vertx.core.net.impl.NetClientImpl.connectInternal(NetClientImpl.java:256)\\n\\tat io.vertx.core.net.impl.NetClientImpl.lambda$connectInternal$5(NetClientImpl.java:275)\\n\\tat io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)\\n\\tat io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)\\n\\tat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)\\n\\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)\\n\\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)\\n\\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\\n\\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\\n\\tat java.base/java.lang.Thread.run(Thread.java:833)\\n"} {"timestamp":"2022-09-02T15:22:14.351Z","sequence":100,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus.runtime.Application","level":"DEBUG","message":"Stopping application","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"powo-backend-staging-7c8f5f7787-vf7xb","processName":"quarkus-run.jar","processId":1} {"timestamp":"2022-09-02T15:22:14.352Z","sequence":101,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus.runtime.Application","level":"DEBUG","message":"Shutting down with exit code 1","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"powo-backend-staging-7c8f5f7787-vf7xb","processName":"quarkus-run.jar","processId":1} ### Expected behavior The message "OIDC Server is not available" should be thrown instead of NPE ### Actual behavior java.lang.NullPointerException: The supplier returned `null` ### How to Reproduce? **My code :** @Path("/auth") public class LoginResource { @Inject OidcClient oidcClient; public Response ssoAuthentication(@QueryParam("code") String code) { Map<String, String> grantParams = new HashMap<>(); grantParams.put(OidcConstants.CODE_FLOW_CODE, code); grantParams.put(OidcConstants.CODE_FLOW_REDIRECT_URI, redirectUriParam); Tokens tokens = oidcClient.getTokens(grantParams).await().indefinitely(); Cookie cookieAccessToken = Cookie.cookie("accesstoken", accessToken).setSameSite(CookieSameSite.STRICT).setMaxAge(tokens.getAccessTokenExpiresAt()); return Response.status(RestResponse.Status.FOUND).location(uri) .header(HttpHeaders.SET_COOKIE, cookieAccessToken.encode()) } } **My application.properties:** quarkus.oidc-client.auth-server-url=https://auth.tech.okta quarkus.oidc-client.client-id=aaaaa-bbbbbb-cccc-dddd-fffff quarkus.oidc-client.credentials.client-secret.value=zsdsfdazerty quarkus.oidc-client.credentials.client-secret.method=post quarkus.oidc-client.grant.type=code ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.11.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
1983f5ee635d4fc2578b29583f2d31e0d1906ef1
9becad4b6d71d93f3700060f6ac09f1d9e49e874
https://github.com/quarkusio/quarkus/compare/1983f5ee635d4fc2578b29583f2d31e0d1906ef1...9becad4b6d71d93f3700060f6ac09f1d9e49e874
diff --git a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java index bbb62b55b0c..38b79326312 100644 --- a/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java +++ b/extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java @@ -124,7 +124,7 @@ public Uni<Tokens> get() { .atMost(oidcConfig.connectionRetryCount) .onFailure().transform(t -> { LOG.warn("OIDC Server is not available:", t.getCause() != null ? t.getCause() : t); - // don't wrap t to avoid information leak + // don't wrap it to avoid information leak return new OidcClientException("OIDC Server is not available"); }); return response.onItem() diff --git a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java index 8d81feff307..6afd8a46642 100644 --- a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java +++ b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java @@ -409,7 +409,11 @@ public static Uni<JsonObject> discoverMetadata(WebClient client, String authServ .retry() .withBackOff(CONNECTION_BACKOFF_DURATION, CONNECTION_BACKOFF_DURATION) .expireIn(connectionDelayInMillisecs) - .onFailure().transform(t -> t.getCause()); + .onFailure().transform(t -> { + LOG.warn("OIDC Server is not available:", t.getCause() != null ? t.getCause() : t); + // don't wrap it to avoid information leak + return new RuntimeException("OIDC Server is not available"); + }); } private static byte[] getFileContent(Path path) throws IOException { diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index dce213e2786..817a1a5b206 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -578,7 +578,10 @@ private void createRealm(String keycloakUrl, RealmRepresentation realm) { .retry() .withBackOff(Duration.ofSeconds(2), Duration.ofSeconds(2)) .expireIn(10 * 1000) - .onFailure().transform(t -> t.getCause()); + .onFailure().transform(t -> { + return new RuntimeException("Keycloak server is not available" + + (t.getMessage() != null ? (": " + t.getMessage()) : "")); + }); realmStatusCodeUni.await().atMost(Duration.ofSeconds(10)); } catch (Throwable t) { LOG.errorf("Realm %s can not be created: %s", realm.getRealm(), t.getMessage());
['extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java', 'extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java', 'extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java']
{'.java': 3}
3
3
0
0
3
22,442,173
4,392,294
572,033
5,338
840
147
13
3
8,711
255
2,180
67
3
0
1970-01-01T00:27:42
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,364
quarkusio/quarkus/27891/27870
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27870
https://github.com/quarkusio/quarkus/pull/27891
https://github.com/quarkusio/quarkus/pull/27891
1
fix
Stork custom serviceDiscovery default Host is not working anymore
### Describe the bug Quarkus version: Upstream Extension: `stork-core` and `stork-configuration-generator` If no `quarkus.stork.<SERVICE_NAME>.service-discovery.host` is provided then by default `localhost/127.0.0.1:80` is used as a service discovery host, and then an exception is thrown ``` 2022-09-12 13:55:41,835 ERROR [io.qua.mut.run.MutinyInfrastructure] (vert.x-eventloop-thread-1) Mutiny had to drop the following exception: javax.ws.rs.WebApplicationException: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:80 at io.quarkus.ts.stork.custom.PingResource.lambda$pong$0(PingResource.java:22) at io.smallrye.context.impl.wrappers.SlowContextualFunction.apply(SlowContextualFunction.java:21) at io.smallrye.mutiny.operators.uni.UniOnFailureTransform$UniOnFailureTransformProcessor.onFailure(UniOnFailureTransform.java:54) at io.smallrye.mutiny.operators.uni.builders.UniCreateFromCompletionStage$CompletionStageUniSubscription.forwardResult(UniCreateFromCompletionStage.java:58) at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ``` In previous upstream version, the default host was `localhost`. Work around: Define on your application.properties the required Host with the expected format ### Expected behavior Default stork service discovery host should be `localhost` ### Actual behavior Default stork service is set to `localhost/127.0.0.1:80` ### How to Reproduce? `git clone git@github.com:quarkus-qe/quarkus-test-suite.git` Go to the following module `https://github.com/quarkus-qe/quarkus-test-suite/tree/main/service-discovery/stork-custom` and set this application.properties ``` #quarkus.stork.pong.load-balancer.type=simplelb quarkus.stork.pong.service-discovery.type=simple # this properties make sense if you have a global service discovery state as a DB, for this scenario we are going to use an in-memory Map #quarkus.stork.pong.service-discovery.host=localhost quarkus.stork.pong.service-discovery.port=8080 #quarkus.stork.pong.service-discovery.pongServiceHost=localhost quarkus.stork.pong.service-discovery.pongServicePort=8080 #quarkus.stork.pong-replica.load-balancer.type=simplelb quarkus.stork.pong-replica.service-discovery.type=simple # this properties make sense if you have a global service discovery state as a DB, for this scenario we are going to use an in-memory Map #quarkus.stork.pong-replica.service-discovery.host=localhost quarkus.stork.pong-replica.service-discovery.port=8080 #quarkus.stork.pong-replica.service-discovery.pongReplicaServiceHost=localhost quarkus.stork.pong-replica.service-discovery.pongReplicaServicePort=8080 ``` Then start the app in dev mode: `mvn quarkus:dev` and finally run: `curl -v Http://localhost:8080/ping/pong` **Note**: service discovery `host`properties are commented
13b15b1f87f40cf262a767fc7e6d9f34e37c778b
66a11c4b2fde52dfc70482ba07564c38eefe0904
https://github.com/quarkusio/quarkus/compare/13b15b1f87f40cf262a767fc7e6d9f34e37c778b...66a11c4b2fde52dfc70482ba07564c38eefe0904
diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java index 43c8c218eb4..eeb59d0e0ab 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java @@ -34,7 +34,8 @@ public void filter(ResteasyReactiveClientRequestContext requestContext) { try { serviceInstance = Stork.getInstance() .getService(serviceName) - .selectInstanceAndRecordStart(measureTime); + .selectInstanceAndRecordStart(measureTime) + .log(); } catch (Throwable e) { log.error("Error selecting service instance for serviceName: " + serviceName, e); requestContext.resume(e); @@ -46,8 +47,18 @@ public void filter(ResteasyReactiveClientRequestContext requestContext) { boolean isHttps = instance.isSecure() || "storks".equals(uri.getScheme()); String scheme = isHttps ? "https" : "http"; try { + // In the case the service instance does not set the host and/or port + String host = instance.getHost() == null ? "localhost" : instance.getHost(); + int port = instance.getPort(); + if (instance.getPort() == 0) { + if (isHttps) { + port = 433; + } else { + port = 80; + } + } URI newUri = new URI(scheme, - uri.getUserInfo(), instance.getHost(), instance.getPort(), + uri.getUserInfo(), host, port, uri.getPath(), uri.getQuery(), uri.getFragment()); requestContext.setUri(newUri); if (measureTime && instance.gatherStatistics()) {
['independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/StorkClientRequestFilter.java']
{'.java': 1}
1
1
0
0
1
22,539,560
4,415,411
574,809
5,351
911
125
15
1
3,038
213
775
63
1
2
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,363
quarkusio/quarkus/27914/27906
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27906
https://github.com/quarkusio/quarkus/pull/27914
https://github.com/quarkusio/quarkus/pull/27914
1
fixes
@TransientReference results in @Dispose method being called multiple times
### Describe the bug If I use TransientReference the injected bean gets disposed more than once. ### Expected behavior Produced beans should be disposed once and only once. ### Actual behavior Produced beans are disposed of multiple times if TransientReference is used. ### How to Reproduce? 1. Have a produce method require a different TransientReference bean that has a dispose method. 2. Watch that bean get disposed multiple times. ### Output of `uname -a` or `ver` Linux fivecorners 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-122.04) OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.12.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /home/sixcorners/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.4, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-46-generic", arch: "amd64", family: "unix" ### Additional information [example.zip](https://github.com/quarkusio/quarkus/files/9560450/example.zip)
4a2a5cb28a38d245ee970a0e24cc5a93a0b2473a
bcffcb43e27f1d6666c2813ffc94c9f12d2b687a
https://github.com/quarkusio/quarkus/compare/4a2a5cb28a38d245ee970a0e24cc5a93a0b2473a...bcffcb43e27f1d6666c2813ffc94c9f12d2b687a
diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java index 90833e4c539..75189ab6064 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java @@ -47,16 +47,17 @@ public synchronized boolean hasDependentInstances() { return dependentInstances != null && !dependentInstances.isEmpty(); } - boolean destroyDependentInstance(Object dependentInstance) { - synchronized (this) { - if (dependentInstances != null) { - for (Iterator<InstanceHandle<?>> iterator = dependentInstances.iterator(); iterator.hasNext();) { - InstanceHandle<?> instanceHandle = iterator.next(); - if (instanceHandle.get() == dependentInstance) { - instanceHandle.destroy(); - iterator.remove(); - return true; + public synchronized boolean removeDependentInstance(Object dependentInstance, boolean destroy) { + if (dependentInstances != null) { + for (Iterator<InstanceHandle<?>> it = dependentInstances.iterator(); it.hasNext();) { + InstanceHandle<?> handle = it.next(); + // The reference equality is used on purpose! + if (handle.get() == dependentInstance) { + if (destroy) { + handle.destroy(); } + it.remove(); + return true; } } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectableReferenceProviders.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectableReferenceProviders.java index 61845fa72ac..4633cbe6ff8 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectableReferenceProviders.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectableReferenceProviders.java @@ -11,6 +11,8 @@ private InjectableReferenceProviders() { /** * Unwraps the provider if necessary and invokes {@link Contextual#destroy(Object, CreationalContext)}. + * <p> + * If there is a parent context available then attempt to remove the dependent instance. * * @param <T> * @param provider @@ -18,15 +20,20 @@ private InjectableReferenceProviders() { * @param creationalContext * @throws IllegalArgumentException If the specified provider is not a bean */ - @SuppressWarnings("unchecked") public static <T> void destroy(InjectableReferenceProvider<T> provider, T instance, CreationalContext<T> creationalContext) { if (provider instanceof CurrentInjectionPointProvider) { provider = ((CurrentInjectionPointProvider<T>) provider).getDelegate(); } if (provider instanceof Contextual) { + @SuppressWarnings("unchecked") Contextual<T> contextual = (Contextual<T>) provider; contextual.destroy(instance, creationalContext); + CreationalContextImpl<T> ctx = CreationalContextImpl.unwrap(creationalContext); + CreationalContextImpl<?> parent = ctx.getParent(); + if (parent != null) { + parent.removeDependentInstance(instance, false); + } } else { throw new IllegalArgumentException("Injetable reference provider is not a bean: " + provider.getClass()); } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java index 7c5f4b124f8..00104c0ed26 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java @@ -138,7 +138,7 @@ public void destroy(Object instance) { context.destroy(proxy.arc_bean()); } else { // First try to destroy a dependent instance - if (!creationalContext.destroyDependentInstance(instance)) { + if (!creationalContext.removeDependentInstance(instance, true)) { // If not successful then try the singleton context SingletonContext singletonContext = (SingletonContext) Arc.container().getActiveContext(Singleton.class); singletonContext.destroyInstance(instance); diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/transientreference/TransientReferenceDestroyedTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/transientreference/TransientReferenceDestroyedTest.java index 1433c5311f0..d5136cbd90a 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/transientreference/TransientReferenceDestroyedTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/transientreference/TransientReferenceDestroyedTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; import io.quarkus.arc.test.ArcTestContainer; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -30,7 +31,8 @@ public class TransientReferenceDestroyedTest { @Test public void testTransientReferences() { - Controller controller = Arc.container().instance(Controller.class).get(); + InstanceHandle<Controller> controllerHandle = Arc.container().instance(Controller.class); + Controller controller = controllerHandle.get(); assertNotNull(controller.theBeer); assertTrue(Arc.container().instance(Integer.class).get() > 0); assertEquals(3, BeerProducer.DESTROYED.size(), "Destroyed beers: " + BeerProducer.DESTROYED); @@ -38,16 +40,26 @@ public void testTransientReferences() { assertTrue(BeerProducer.DESTROYED.contains(2)); assertTrue(BeerProducer.DESTROYED.contains(3)); + controllerHandle.destroy(); + // Controller.theBeer is also destroyed + assertEquals(4, BeerProducer.DESTROYED.size()); + BeerProducer.COUNTER.set(0); BeerProducer.DESTROYED.clear(); - InterceptedController interceptedController = Arc.container().instance(InterceptedController.class).get(); + InstanceHandle<InterceptedController> interceptedControllerHandle = Arc.container() + .instance(InterceptedController.class); + InterceptedController interceptedController = interceptedControllerHandle.get(); assertNotNull(interceptedController.getTheBeer()); assertTrue(Arc.container().instance(Long.class).get() > 0); assertEquals(3, BeerProducer.DESTROYED.size(), "Destroyed beers: " + BeerProducer.DESTROYED); assertTrue(BeerProducer.DESTROYED.contains(1)); assertTrue(BeerProducer.DESTROYED.contains(2)); assertTrue(BeerProducer.DESTROYED.contains(3)); + + interceptedControllerHandle.destroy(); + // InterceptedController.theBeer is also destroyed + assertEquals(4, BeerProducer.DESTROYED.size()); } @Singleton
['independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/transientreference/TransientReferenceDestroyedTest.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/CreationalContextImpl.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InjectableReferenceProviders.java']
{'.java': 4}
4
4
0
0
4
22,644,820
4,435,845
577,649
5,391
1,711
282
30
3
1,457
175
448
41
1
0
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,362
quarkusio/quarkus/27916/27913
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27913
https://github.com/quarkusio/quarkus/pull/27916
https://github.com/quarkusio/quarkus/pull/27916
1
fix
quarkus-redis-client: 'fromCoordinate(double, double)' has private access in 'io.quarkus.redis.datasource.geo.GeoSearchArgs' blocking my usage of geosearch FROMLONLAT
### Describe the bug According to the manual of Redis geosearch command, it supports to calculate the nearist points from the given longitude and latitude as below. However when I want to use this command via quarkus-redis-client, I found the GeoSearchArgs.fromCoordinate() had private access thus I couldn't use it in my code. I believe this method should have public access as the same as GeoSearchArgs.fromMember(). GEOSEARCH key <FROMMEMBER member | FROMLONLAT longitude latitude> <BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM | FT | MI>> [ASC | DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST] [WITHHASH] ### Expected behavior GeoSearchArgs.fromCoordinate() should have public access as the same as GeoSearchArgs.fromMember(). ### Actual behavior GeoSearchArgs.fromCoordinate() has private access so I cannot use geosearch FROMLONLAT. ### How to Reproduce? n/a ### Output of `uname -a` or `ver` Linux a176656f74a6 5.4.0-117-generic ### Output of `java -version` openjdk version "17.0.4" 2022-07-19 ### GraalVM version (if different from Java) OpenJDK 64-Bit Server VM GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06, mixed mode, sharing) ### Quarkus version or git rev 2.12.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) mavem 3.8.6 ### Additional information _No response_
6e10b215fa2689171c9c3bb9fd3cc7986fe1e2ff
33c8625210a7691d7439d3df351bd771fe72b2a5
https://github.com/quarkusio/quarkus/compare/6e10b215fa2689171c9c3bb9fd3cc7986fe1e2ff...33c8625210a7691d7439d3df351bd771fe72b2a5
diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java index 2070507f362..29b2cd9140f 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java @@ -56,7 +56,7 @@ public GeoSearchArgs<V> fromMember(V member) { * @param latitude the latitude * @return the current {@code GeoSearchArgs} */ - private GeoSearchArgs<V> fromCoordinate(double longitude, double latitude) { + public GeoSearchArgs<V> fromCoordinate(double longitude, double latitude) { this.longitude = longitude; this.latitude = latitude; return this; diff --git a/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/GeoCommandsTest.java b/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/GeoCommandsTest.java index 0d2a365de53..ea34b4ef21c 100644 --- a/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/GeoCommandsTest.java +++ b/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/GeoCommandsTest.java @@ -494,6 +494,17 @@ void geosearchWithArgs() { assertThat(gv.geohash).isEmpty(); }); + args = new GeoSearchArgs<Place>().fromCoordinate(CRUSSOL_LONGITUDE, CRUSSOL_LATITUDE) + .byRadius(5, GeoUnit.KM).withCoordinates().withDistance().descending(); + places = geo.geosearch(key, args); + assertThat(places).hasSize(1).allSatisfy(gv -> { + assertThat(gv.member).isEqualTo(Place.crussol); + assertThat(gv.longitude).isNotEmpty(); + assertThat(gv.latitude).isNotEmpty(); + assertThat(gv.distance).isNotEmpty(); + assertThat(gv.geohash).isEmpty(); + }); + } @Test
['extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/GeoCommandsTest.java', 'extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java']
{'.java': 2}
2
2
0
0
2
22,622,380
4,431,494
577,039
5,382
162
32
2
1
1,362
196
389
44
0
0
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,358
quarkusio/quarkus/27993/27987
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27987
https://github.com/quarkusio/quarkus/pull/27993
https://github.com/quarkusio/quarkus/pull/27993
1
fixes
New Info Log Messages since 2.13.0.CR1
### Describe the bug Relates to #26161 On quarkus dev startup, I get info log messages related to recovery service starting up. Are these messages really needed? ``` __ ____ __ _____ ___ __ ____ ______ --/ __ \\/ / / / _ | / _ \\/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\\ \\ --\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/ 2022-09-16 07:43:28,364 INFO [com.arj.ats.jbossatx] (Quarkus Main Thread) ARJUNA032010: JBossTS Recovery Service (tag: 518c8dd50a9ae8e70eb15dfe8fc764adcabef8ab) - JBoss Inc. 2022-09-16 07:43:28,381 INFO [com.arj.ats.jbossatx] (Quarkus Main Thread) ARJUNA032013: Starting transaction recovery manager 2022-09-16 07:43:30,079 WARN [com.rab.cli.TrustEverythingTrustManager] (Quarkus Main Thread) SECURITY ALERT: this trust manager trusts every certificate, effectively disabling peer verification. This is convenient for local development but offers no protection against man-in-t he-middle attacks. Please see https://www.rabbitmq.com/ssl.html to learn more about peer certificate verification. 2022-09-16 07:43:36,200 INFO [io.quarkus] (Quarkus Main Thread) xxx-backend 1.60.0-RC01-SNAPSHOT on JVM (powered by Quarkus 2.13.0.CR1) started in 16.049s. Listening on: http://localhost:9095 2022-09-16 07:43:36,200 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2022-09-16 07:43:36,200 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [agroal, cdi, config-yaml, hibernate-orm, hibernate-validator, jdbc-postgresql, narayana-jta, rest-client, rest-client-jackson, resteasy-reactive, resteasy-reactive-jackson, resteasy-reactive-j axb, scheduler, smallrye-context-propagation, smallrye-fault-tolerance, smallrye-health, smallrye-metrics, vertx] ``` ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` windows 10 ### Output of `java -version` openjdk 18.0.2 2022-07-19 OpenJDK Runtime Environment Temurin-18.0.2+9 (build 18.0.2+9) OpenJDK 64-Bit Server VM Temurin-18.0.2+9 (build 18.0.2+9, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.0.CR1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\\eclipse\\tools\\java\\maven Java version: 18.0.2, vendor: Eclipse Adoptium, runtime: C:\\eclipse\\tools\\java\\18 Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" ### Additional information _No response_
0595c55e793f02503d195b8a199e67932b6969fe
d5c15902e5623181b7cb2f22e7d2b1c48b511a35
https://github.com/quarkusio/quarkus/compare/0595c55e793f02503d195b8a199e67932b6969fe...d5c15902e5623181b7cb2f22e7d2b1c48b511a35
diff --git a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java index 18e88ec3121..abd0b310441 100644 --- a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java +++ b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java @@ -48,6 +48,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; +import io.quarkus.deployment.logging.LogCleanupFilterBuildItem; import io.quarkus.gizmo.ClassCreator; import io.quarkus.narayana.jta.runtime.CDIDelegatingTransactionManager; import io.quarkus.narayana.jta.runtime.NarayanaJtaProducers; @@ -173,4 +174,8 @@ void unremovableBean(BuildProducer<UnremovableBeanBuildItem> unremovableBeans) { unremovableBeans.produce(UnremovableBeanBuildItem.beanTypes(TransactionManager.class)); } + @BuildStep + void logCleanupFilters(BuildProducer<LogCleanupFilterBuildItem> logCleanupFilters) { + logCleanupFilters.produce(new LogCleanupFilterBuildItem("com.arjuna.ats.jbossatx", "ARJUNA032010:", "ARJUNA032013:")); + } }
['extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java']
{'.java': 1}
1
1
0
0
1
22,658,409
4,438,334
577,989
5,391
305
80
5
1
2,675
314
865
57
2
1
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,357
quarkusio/quarkus/28000/27884
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27884
https://github.com/quarkusio/quarkus/pull/28000
https://github.com/quarkusio/quarkus/pull/28000
1
fixes
quarkus-config: Maven-Property conflicts with 'prefix' (Regression since Quarkus 2.12)
### Describe the bug __Regression Quarkus 2.11 -> Quarkus 2.12__ If the `prefix` in `ConfigMapping` has the same name as a Maven-Property, you will get the following error on startup (see reproducer): ```bash 2022-09-13 06:54:14,561 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): io.smallrye.config.ConfigValidationException: Configuration validation failed: xyz.version does not map to any root at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:967) at io.smallrye.config.ConfigMappingProvider.lambda$mapConfiguration$3(ConfigMappingProvider.java:923) at io.smallrye.config.SecretKeys.lambda$doUnlocked$0(SecretKeys.java:20) at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:29) at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:19) at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:923) at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:450) at io.quarkus.runtime.generated.Config.readConfig(Unknown Source) at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source) at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) at io.quarkus.runtime.Application.start(Application.java:101) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110) at io.quarkus.runtime.Quarkus.run(Quarkus.java:67) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runtime.Quarkus.run(Quarkus.java:120) at io.quarkus.runner.GeneratedMain.main(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103) at java.base/java.lang.Thread.run(Thread.java:829) 2022-09-13 06:54:14,561 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): io.smallrye.config.ConfigValidationException: Configuration validation failed: xyz.version does not map to any root at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:967) at io.smallrye.config.ConfigMappingProvider.lambda$mapConfiguration$3(ConfigMappingProvider.java:923) at io.smallrye.config.SecretKeys.lambda$doUnlocked$0(SecretKeys.java:20) at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:29) at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:19) at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:923) at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:450) at io.quarkus.runtime.generated.Config.readConfig(Unknown Source) at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source) at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) at io.quarkus.runtime.Application.start(Application.java:101) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110) at io.quarkus.runtime.Quarkus.run(Quarkus.java:67) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runtime.Quarkus.run(Quarkus.java:120) at io.quarkus.runner.GeneratedMain.main(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103) at java.base/java.lang.Thread.run(Thread.java:829) 2022-09-13 06:54:14,562 INFO [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure 2022-09-13 06:54:14,562 INFO [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure Press [space] to restart, [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle test output, [h] for more options> ``` Note: At the moment i cannot upgrade my Quarkus projects to Quarkus 2.12.1.Final because the property is defined in a parent pom over which i have no control. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? [reproducer.zip](https://github.com/quarkusio/quarkus/files/9553721/reproducer.zip) ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` Java 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev Quarkus 2.12.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Maven ### Additional information _No response_
617503ed6c7d81c27e5cbed13cb9e3d1cf4aa538
62bb79c9c5869ed8e0267e6ed88a081f1f28d129
https://github.com/quarkusio/quarkus/compare/617503ed6c7d81c27e5cbed13cb9e3d1cf4aa538...62bb79c9c5869ed8e0267e6ed88a081f1f28d129
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java index 65d7f096a8f..9fd912d9e7c 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java @@ -878,13 +878,16 @@ private Converter<?> getConverter(SmallRyeConfig config, Field field, ConverterT * We collect all properties from eligible ConfigSources, because Config#getPropertyNames exclude the active * profiled properties, meaning that the property is written in the default config source without the profile * prefix. This may cause issues if we run with a different profile and fallback to defaults. - * + * <br> * We also filter the properties coming from the System with the registered roots, because we don't want to * record properties set by the compiling JVM (or other properties that are only related to the build). + * <br> + * Properties coming from the Environment are ignored. */ private Set<String> getAllProperties(final Set<String> registeredRoots) { Set<String> properties = new HashSet<>(); for (ConfigSource configSource : config.getConfigSources()) { + // This is a BuildTimeSysPropConfigSource if (configSource instanceof SysPropConfigSource) { for (String propertyName : configSource.getProperties().keySet()) { NameIterator ni = new NameIterator(propertyName); @@ -893,6 +896,7 @@ private Set<String> getAllProperties(final Set<String> registeredRoots) { } } } else { + // The BuildTimeEnvConfigSource returns an empty Set properties.addAll(configSource.getPropertyNames()); } } @@ -906,10 +910,10 @@ private Set<String> getAllProperties(final Set<String> registeredRoots) { * Use this Config instance to record the runtime default values. We cannot use the main Config * instance because it may record values coming from the EnvSource in build time. Environment variable values * may be completely different between build and runtime, so it doesn't make sense to record these. - * + * <br> * We do exclude the properties coming from the EnvSource, but a call to getValue may still provide a result * coming from the EnvSource, so we need to exclude it from the sources when recording values for runtime. - * + * <br> * We also do not want to completely exclude the EnvSource, because it may provide values for the build. This * is only specific when recording the defaults. * diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index bfd2968ee22..e9b1b274eb1 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -1,5 +1,7 @@ package io.quarkus.maven; +import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX; +import static io.smallrye.common.expression.Expression.Flag.NO_TRIM; import static java.util.function.Predicate.not; import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId; import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration; @@ -105,6 +107,7 @@ import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.PathList; import io.quarkus.runtime.LaunchMode; +import io.smallrye.common.expression.Expression; /** * The dev mojo, that runs a quarkus app in a forked process. A background compilation process is launched and any changes are @@ -983,7 +986,31 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { } builder.projectDir(project.getFile().getParentFile()); - builder.buildSystemProperties((Map) project.getProperties()); + + Properties projectProperties = project.getProperties(); + Map<String, String> effectiveProperties = new HashMap<>(); + for (String name : projectProperties.stringPropertyNames()) { + if (name.startsWith("quarkus.")) { + effectiveProperties.put(name, projectProperties.getProperty(name)); + } + } + + // Add other properties that may be required for expansion + for (String value : effectiveProperties.values()) { + for (String reference : Expression.compile(value, LENIENT_SYNTAX, NO_TRIM).getReferencedStrings()) { + String referenceValue = session.getUserProperties().getProperty(reference); + if (referenceValue != null) { + effectiveProperties.put(reference, referenceValue); + continue; + } + + referenceValue = projectProperties.getProperty(reference); + if (referenceValue != null) { + effectiveProperties.put(reference, referenceValue); + } + } + } + builder.buildSystemProperties(effectiveProperties); builder.applicationName(project.getArtifactId()); builder.applicationVersion(project.getVersion());
['core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java', 'devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 2}
2
2
0
0
2
22,663,556
4,439,192
578,079
5,391
1,744
297
39
2
5,229
335
1,271
102
1
1
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,356
quarkusio/quarkus/28025/27982
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/27982
https://github.com/quarkusio/quarkus/pull/28025
https://github.com/quarkusio/quarkus/pull/28025
1
fixes
Unused Narayana is started upon application start
### Describe the bug `mongodb-panache-common` adds the `narayana-jta` extension. Although added, the transaction manager was never used and thus not started. As of `2.13.0.CR1` the transaction manager is started nearly immediately at startup ### Expected behavior Narayana is not started if not used. Additionally, it would be nice to not have it included if it's not going to be used. ### Actual behavior Narayana JTA is started almost immediately on startup. In an application with Flyway enabled, the JTA is started prior to running migrations and a message is produced. ``` 20:29:15 INFO ARJUNA032010: JBossTS Recovery Service (tag: 518c8dd50a9ae8e70eb15dfe8fc764adcabef8ab) - JBoss Inc. 20:29:15 INFO ARJUNA032013: Starting transaction recovery manager 20:29:15 INFO Flyway Community Edition 9.3.0 by Redgate ``` In applications without Flyway **no message is produced** but the application creates the telltale `ObjectStore` directory indicating that some portion of the JTA is starting. ### How to Reproduce? Add `mongodb-panache` to an application to you'll see `ObjectStore` directories. Additionally add Flyway and observe the logging related to started the JTA. ### Output of `uname -a` or `ver` macOS 12.6 ### Output of `java -version` OpenJDK 17.0.1 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.0.CR1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.5.1 ### Additional information _No response_
9ed77a64d671b65db866ea6759a7cb06c94bd7d5
31d3cb78a5cf4e47a680944683b32a14f1c37b0f
https://github.com/quarkusio/quarkus/compare/9ed77a64d671b65db866ea6759a7cb06c94bd7d5...31d3cb78a5cf4e47a680944683b32a14f1c37b0f
diff --git a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java index 9adbe0abf06..28172208ff0 100644 --- a/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java +++ b/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java @@ -49,6 +49,7 @@ import io.quarkus.datasource.runtime.DataSourceRuntimeConfig; import io.quarkus.datasource.runtime.DataSourcesBuildTimeConfig; import io.quarkus.datasource.runtime.DataSourcesRuntimeConfig; +import io.quarkus.narayana.jta.runtime.TransactionManagerConfiguration; /** * This class is sort of a producer for {@link AgroalDataSource}. @@ -72,6 +73,7 @@ public class DataSources { private final DataSourcesRuntimeConfig dataSourcesRuntimeConfig; private final DataSourcesJdbcBuildTimeConfig dataSourcesJdbcBuildTimeConfig; private final DataSourcesJdbcRuntimeConfig dataSourcesJdbcRuntimeConfig; + private final TransactionManagerConfiguration transactionRuntimeConfig; private final TransactionManager transactionManager; private final XAResourceRecoveryRegistry xaResourceRecoveryRegistry; private final TransactionSynchronizationRegistry transactionSynchronizationRegistry; @@ -83,6 +85,7 @@ public class DataSources { public DataSources(DataSourcesBuildTimeConfig dataSourcesBuildTimeConfig, DataSourcesRuntimeConfig dataSourcesRuntimeConfig, DataSourcesJdbcBuildTimeConfig dataSourcesJdbcBuildTimeConfig, DataSourcesJdbcRuntimeConfig dataSourcesJdbcRuntimeConfig, + TransactionManagerConfiguration transactionRuntimeConfig, TransactionManager transactionManager, XAResourceRecoveryRegistry xaResourceRecoveryRegistry, TransactionSynchronizationRegistry transactionSynchronizationRegistry, DataSourceSupport dataSourceSupport, @@ -91,6 +94,7 @@ public DataSources(DataSourcesBuildTimeConfig dataSourcesBuildTimeConfig, this.dataSourcesRuntimeConfig = dataSourcesRuntimeConfig; this.dataSourcesJdbcBuildTimeConfig = dataSourcesJdbcBuildTimeConfig; this.dataSourcesJdbcRuntimeConfig = dataSourcesJdbcRuntimeConfig; + this.transactionRuntimeConfig = transactionRuntimeConfig; this.transactionManager = transactionManager; this.xaResourceRecoveryRegistry = xaResourceRecoveryRegistry; this.transactionSynchronizationRegistry = transactionSynchronizationRegistry; @@ -215,8 +219,10 @@ public AgroalDataSource doCreateDataSource(String dataSourceName) { .connectionFactoryConfiguration(); boolean mpMetricsPresent = dataSourceSupport.mpMetricsPresent; - applyNewConfiguration(dataSourceConfiguration, poolConfiguration, connectionFactoryConfiguration, driver, jdbcUrl, - dataSourceJdbcBuildTimeConfig, dataSourceRuntimeConfig, dataSourceJdbcRuntimeConfig, mpMetricsPresent); + applyNewConfiguration(dataSourceName, dataSourceConfiguration, poolConfiguration, connectionFactoryConfiguration, + driver, jdbcUrl, + dataSourceJdbcBuildTimeConfig, dataSourceRuntimeConfig, dataSourceJdbcRuntimeConfig, transactionRuntimeConfig, + mpMetricsPresent); if (dataSourceSupport.disableSslSupport) { agroalConnectionConfigurer.disableSslSupport(resolvedDbKind, dataSourceConfiguration); @@ -255,11 +261,12 @@ public AgroalDataSource doCreateDataSource(String dataSourceName) { return dataSource; } - private void applyNewConfiguration(AgroalDataSourceConfigurationSupplier dataSourceConfiguration, + private void applyNewConfiguration(String dataSourceName, AgroalDataSourceConfigurationSupplier dataSourceConfiguration, AgroalConnectionPoolConfigurationSupplier poolConfiguration, AgroalConnectionFactoryConfigurationSupplier connectionFactoryConfiguration, Class<?> driver, String jdbcUrl, DataSourceJdbcBuildTimeConfig dataSourceJdbcBuildTimeConfig, DataSourceRuntimeConfig dataSourceRuntimeConfig, - DataSourceJdbcRuntimeConfig dataSourceJdbcRuntimeConfig, boolean mpMetricsPresent) { + DataSourceJdbcRuntimeConfig dataSourceJdbcRuntimeConfig, TransactionManagerConfiguration transactionRuntimeConfig, + boolean mpMetricsPresent) { connectionFactoryConfiguration.jdbcUrl(jdbcUrl); connectionFactoryConfiguration.connectionProviderClass(driver); connectionFactoryConfiguration.trackJdbcResources(dataSourceJdbcRuntimeConfig.detectStatementLeaks); @@ -274,8 +281,15 @@ private void applyNewConfiguration(AgroalDataSourceConfigurationSupplier dataSou TransactionIntegration txIntegration = new NarayanaTransactionIntegration(transactionManager, transactionSynchronizationRegistry, null, false, dataSourceJdbcBuildTimeConfig.transactions == io.quarkus.agroal.runtime.TransactionIntegration.XA - ? xaResourceRecoveryRegistry - : null); + && transactionRuntimeConfig.enableRecovery + ? xaResourceRecoveryRegistry + : null); + if (dataSourceJdbcBuildTimeConfig.transactions == io.quarkus.agroal.runtime.TransactionIntegration.XA + && !transactionRuntimeConfig.enableRecovery) { + log.warnv( + "Datasource {0} enables XA but transaction recovery is not enabled. Please enable transaction recovery by setting quarkus.transaction-manager.enable-recovery=true, otherwise data may be lost if the application is terminated abruptly", + dataSourceName); + } poolConfiguration.transactionIntegration(txIntegration); } diff --git a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java index abd0b310441..2ca5d25e337 100644 --- a/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java +++ b/extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java @@ -82,7 +82,7 @@ public void build(NarayanaJtaRecorder recorder, BuildProducer<RuntimeInitializedClassBuildItem> runtimeInit, BuildProducer<FeatureBuildItem> feature, TransactionManagerConfiguration transactions, ShutdownContextBuildItem shutdownContextBuildItem) { - recorder.handleShutdown(shutdownContextBuildItem); + recorder.handleShutdown(shutdownContextBuildItem, transactions); feature.produce(new FeatureBuildItem(Feature.NARAYANA_JTA)); additionalBeans.produce(new AdditionalBeanBuildItem(NarayanaJtaProducers.class)); additionalBeans.produce(new AdditionalBeanBuildItem(CDIDelegatingTransactionManager.class)); diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaProducers.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaProducers.java index abfb7d0d36f..77bbaa4f0f2 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaProducers.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaProducers.java @@ -34,10 +34,12 @@ public javax.transaction.UserTransaction userTransaction() { @Produces @Singleton - public XAResourceRecoveryRegistry xaResourceRecoveryRegistry() { + public XAResourceRecoveryRegistry xaResourceRecoveryRegistry(TransactionManagerConfiguration config) { RecoveryManagerService recoveryManagerService = new RecoveryManagerService(); - recoveryManagerService.create(); - recoveryManagerService.start(); + if (config.enableRecovery) { + recoveryManagerService.create(); + recoveryManagerService.start(); + } return recoveryManagerService; } diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java index 82d2e61b95e..ac859f35023 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java @@ -86,11 +86,13 @@ public void setConfig(final TransactionManagerConfiguration transactions) { .setXaResourceOrphanFilterClassNames(transactions.xaResourceOrphanFilters); } - public void handleShutdown(ShutdownContext context) { + public void handleShutdown(ShutdownContext context, TransactionManagerConfiguration transactions) { context.addLastShutdownTask(new Runnable() { @Override public void run() { - RecoveryManager.manager().terminate(true); + if (transactions.enableRecovery) { + RecoveryManager.manager().terminate(true); + } TransactionReaper.terminate(false); } }); diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java index b4f8ab1ee8c..be182bd3d76 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java @@ -32,6 +32,12 @@ public final class TransactionManagerConfiguration { @ConfigItem(defaultValue = "ObjectStore") public String objectStoreDirectory; + /** + * Start the recovery service on startup. + */ + @ConfigItem(defaultValue = "false") + public boolean enableRecovery; + /** * The list of recovery modules */
['extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java', 'extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java', 'extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaProducers.java', 'extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java', 'extensions/narayana-jta/deployment/src/main/java/io/quarkus/narayana/jta/deployment/NarayanaJtaProcessor.java']
{'.java': 5}
5
5
0
0
5
22,668,252
4,439,819
578,134
5,390
3,191
515
48
5
1,539
219
417
58
0
1
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,355
quarkusio/quarkus/28036/28029
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/28029
https://github.com/quarkusio/quarkus/pull/28036
https://github.com/quarkusio/quarkus/pull/28036
1
fix
Redis GET with byte[] as type leads to unmarshaling exception
### Describe the bug I'm using this example <https://quarkus.io/guides/redis-reference#storing-binary-data> to get a value storing byte data and I'm getting this exception: ``` io.vertx.core.json.DecodeException: Failed to decode:Illegal character ((CTRL-CHAR, code 5)): only regular white space (\\r, \\n, \\t) is allowed between tokens at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 2] at io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec.fromParser(QuarkusJacksonJsonCodec.java:128) at io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec.fromBuffer(QuarkusJacksonJsonCodec.java:100) at io.vertx.core.json.Json.decodeValue(Json.java:119) at io.quarkus.redis.datasource.codecs.Codecs$JsonCodec.decode(Codecs.java:44) at io.quarkus.redis.runtime.datasource.Marshaller.decode(Marshaller.java:92) at io.quarkus.redis.runtime.datasource.Marshaller.decode(Marshaller.java:83) at io.quarkus.redis.runtime.datasource.AbstractStringCommands.decodeV(AbstractStringCommands.java:59) at io.smallrye.context.impl.wrappers.SlowContextualFunction.apply(SlowContextualFunction.java:21) at io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:36) at io.smallrye.mutiny.vertx.AsyncResultUni.lambda$subscribe$1(AsyncResultUni.java:35) ``` It seems that even if I'm using a byte[] type it tries to unmarshall the value as JSON. In `io.quarkus.redis.datasource.codecs.Codecs.getDefaultCodecFor` it defaults to `JsonCodec`, maybe we need a new codec doing nothing for byte[]? ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` Java 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.12.2 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
8634c51dac1a7085547dae82fd94fe0a37ed37eb
4a2546e5e82a15d10a6e75316b9c487f300c2e1a
https://github.com/quarkusio/quarkus/compare/8634c51dac1a7085547dae82fd94fe0a37ed37eb...4a2546e5e82a15d10a6e75316b9c487f300c2e1a
diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/codecs/Codecs.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/codecs/Codecs.java index f08485acd66..4c99de87a09 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/codecs/Codecs.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/codecs/Codecs.java @@ -22,6 +22,9 @@ public static <T> Codec<T> getDefaultCodecFor(Class<T> clazz) { if (clazz.equals(String.class)) { return (Codec<T>) StringCodec.INSTANCE; } + if (clazz.equals(byte[].class)) { + return (Codec<T>) ByteArrayCodec.INSTANCE; + } // JSON by default return new JsonCodec<>(clazz); } @@ -114,4 +117,23 @@ public Integer decode(byte[] item) { } } + public static class ByteArrayCodec implements Codec<byte[]> { + + public static ByteArrayCodec INSTANCE = new ByteArrayCodec(); + + private ByteArrayCodec() { + // Avoid direct instantiation; + } + + @Override + public byte[] encode(byte[] item) { + return item; + } + + @Override + public byte[] decode(byte[] item) { + return item; + } + } + } diff --git a/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/ValueCommandsTest.java b/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/ValueCommandsTest.java index 0bd8815e307..387794660d7 100644 --- a/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/ValueCommandsTest.java +++ b/extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/ValueCommandsTest.java @@ -20,6 +20,8 @@ import io.quarkus.redis.datasource.value.SetArgs; import io.quarkus.redis.datasource.value.ValueCommands; import io.quarkus.redis.runtime.datasource.BlockingRedisDataSourceImpl; +import io.vertx.core.json.DecodeException; +import io.vertx.core.json.Json; public class ValueCommandsTest extends DatasourceTestBase { @@ -274,5 +276,10 @@ void binary() { commands.set(key, content); byte[] bytes = commands.get(key); assertThat(bytes).isEqualTo(content); + + // Verify that we do not get through the JSON codec (which would base64 encode the byte[]) + ValueCommands<String, String> cmd = ds.value(String.class); + String str = cmd.get(key); + assertThatThrownBy(() -> Json.decodeValue(str, byte[].class)).isInstanceOf(DecodeException.class); } }
['extensions/redis-client/runtime/src/test/java/io/quarkus/redis/datasource/ValueCommandsTest.java', 'extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/codecs/Codecs.java']
{'.java': 2}
2
2
0
0
2
22,663,255
4,439,112
578,074
5,391
557
100
22
1
2,007
169
506
57
1
1
1970-01-01T00:27:43
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,288
quarkusio/quarkus/30286/30101
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30101
https://github.com/quarkusio/quarkus/pull/30286
https://github.com/quarkusio/quarkus/pull/30286
1
closes
testNative tag ignores binary name generated by using quarkus.package.output-name/add-runner-suffix
### Describe the bug If the properties `quarkus.package.output-name=<binary-name>` or `quarkus.package.add-runner-suffix=false` are used to modify the binary name generated by the `quarkusBuild`, the `testNative` task fails to find the executable to run. Once both properties are removed from the configuration, the `testNative` task works again. ### Expected behavior The `testNative` task correctly finds the native binary with the custom name and is able to run the native tests. ### Actual behavior The `testNative` tasks fails. After opening the generated test results report, the following exception is listed: ``` java.lang.RuntimeException: java.io.IOException: Cannot run program "/private/tmp/test/build/test-1.0.0-SNAPSHOT-runner": error=2, No such file or directory at io.quarkus.test.junit.QuarkusIntegrationTestExtension.throwBootFailureException(QuarkusIntegrationTestExtension.java:337) at io.quarkus.test.junit.QuarkusIntegrationTestExtension.beforeEach(QuarkusIntegrationTestExtension.java:110) [...] ``` ### How to Reproduce? Steps to reproduce: 1. Create a simple quarkus application. The default example comes with a native test: `quarkus create app --gradle test`. 2. Verify native tests work by default by running: `./gradlew -Dquarkus.package.type=native build testNative`. 3. Make sure to clean the previous build so the currently generated binary is deleted, by running: `./gradlew clean`. 4. Use any of the two properties `quarkus.package.output-name` or `quarkus.package.add-runner-suffix` while building: `./gradlew -Dquarkus.package.type=native -Dquarkus.package.output-name=test -Dquarkus.package.add-runner-suffix=false build testNative`. 5. Open the generated native test report to see the exception: `file:///private/tmp/test/build/reports/tests/testNative/index.html` ### Output of `uname -a` or `ver` Darwin rrivas-mac 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64 ### Output of `java -version` openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.15.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.5.1 ### Additional information Although I chose `gradle` for the reproduction steps, it can be reproduced with both `gradle` and `maven`.
fbbb5e8ad00f116898bdb6938a055bf2c1e8a392
dfabbd6459245029ee3c0e35cb1732176c6ecc43
https://github.com/quarkusio/quarkus/compare/fbbb5e8ad00f116898bdb6938a055bf2c1e8a392...dfabbd6459245029ee3c0e35cb1732176c6ecc43
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java index 925eec91f09..ee4fd9f4100 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java @@ -7,6 +7,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Objects; +import java.util.Properties; import java.util.Set; import java.util.StringJoiner; import java.util.stream.Collectors; @@ -85,7 +86,8 @@ public void beforeTest(Test task) { task.environment(BootstrapConstants.TEST_TO_MAIN_MAPPINGS, fileList); project.getLogger().debug("test dir mapping - {}", fileList); - final String nativeRunner = task.getProject().getBuildDir().toPath().resolve(finalName() + "-runner") + final String nativeRunner = task.getProject().getBuildDir().toPath() + .resolve(buildNativeRunnerName(props)) .toAbsolutePath() .toString(); props.put("native.image.path", nativeRunner); @@ -94,6 +96,30 @@ public void beforeTest(Test task) { } } + public String buildNativeRunnerName(final Map<String, Object> taskSystemProps) { + Properties properties = new Properties(taskSystemProps.size()); + properties.putAll(taskSystemProps); + quarkusBuildProperties.entrySet() + .forEach(buildEntry -> properties.putIfAbsent(buildEntry.getKey(), buildEntry.getValue())); + System.getProperties().entrySet() + .forEach(propEntry -> properties.putIfAbsent(propEntry.getKey(), propEntry.getValue())); + System.getenv().entrySet().forEach( + envEntry -> properties.putIfAbsent(envEntry.getKey(), envEntry.getValue())); + StringBuilder nativeRunnerName = new StringBuilder(); + + if (properties.containsKey("quarkus.package.output-name")) { + nativeRunnerName.append(properties.get("quarkus.package.output-name")); + } else { + nativeRunnerName.append(finalName()); + } + if (!properties.containsKey("quarkus.package.add-runner-suffix") + || (properties.containsKey("quarkus.package.add-runner-suffix") + && Boolean.parseBoolean((String) properties.get("quarkus.package.add-runner-suffix")))) { + nativeRunnerName.append("-runner"); + } + return nativeRunnerName.toString(); + } + public Property<String> getFinalName() { return finalName; } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java index ff7f3372ccd..5013ce21a66 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java @@ -129,12 +129,12 @@ public QuarkusBuild manifest(Action<Manifest> action) { @OutputFile public File getRunnerJar() { - return new File(getProject().getBuildDir(), extension().finalName() + "-runner.jar"); + return new File(getProject().getBuildDir(), String.format("%s.jar", extension().buildNativeRunnerName(Map.of()))); } @OutputFile public File getNativeRunner() { - return new File(getProject().getBuildDir(), extension().finalName() + "-runner"); + return new File(getProject().getBuildDir(), extension().buildNativeRunnerName(Map.of())); } @OutputDirectory diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java index c61f9c8135d..b846cb793f5 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java @@ -48,6 +48,76 @@ public void shouldBuildNativeImage() throws Exception { } + @Test + public void shouldBuildNativeImageWithCustomName() throws Exception { + final File projectDir = getProjectDir("basic-java-native-module"); + + final BuildResult build = runGradleWrapper(projectDir, "clean", "quarkusBuild", "-Dquarkus.package.type=native", + "-Dquarkus.package.output-name=test"); + + assertThat(build.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME); + final String buildOutput = build.getOutput(); + // make sure the output log during the build contains some expected logs from the native-image process + CharSequence[] expectedOutput; + if (buildOutput.contains("Version info:")) { // Starting with 22.0 the native-image output changed + expectedOutput = new CharSequence[] { "Initializing...", "Performing analysis...", + "Finished generating 'test-runner' in" }; + } else { + expectedOutput = new CharSequence[] { "(clinit):", "(typeflow):", "[total]:" }; + } + assertThat(buildOutput) + .withFailMessage("native-image build log is missing certain expected log messages: \\n\\n %s", buildOutput) + .contains(expectedOutput) + .doesNotContain("Finished generating '" + NATIVE_IMAGE_NAME + "' in"); + Path nativeImagePath = projectDir.toPath().resolve("build").resolve("test-runner"); + assertThat(nativeImagePath).exists(); + Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString()); + try { + final String response = DevModeTestUtils.getHttpResponse("/hello"); + assertThat(response) + .withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response) + .contains("hello"); + } finally { + nativeImageProcess.destroy(); + } + + } + + @Test + public void shouldBuildNativeImageWithCustomNameWithoutSuffix() throws Exception { + final File projectDir = getProjectDir("basic-java-native-module"); + + final BuildResult build = runGradleWrapper(projectDir, "clean", "quarkusBuild", "-Dquarkus.package.type=native", + "-Dquarkus.package.output-name=test", "-Dquarkus.package.add-runner-suffix=false"); + + assertThat(build.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME); + final String buildOutput = build.getOutput(); + // make sure the output log during the build contains some expected logs from the native-image process + CharSequence[] expectedOutput; + if (buildOutput.contains("Version info:")) { // Starting with 22.0 the native-image output changed + expectedOutput = new CharSequence[] { "Initializing...", "Performing analysis...", + "Finished generating 'test' in" }; + } else { + expectedOutput = new CharSequence[] { "(clinit):", "(typeflow):", "[total]:" }; + } + assertThat(buildOutput) + .withFailMessage("native-image build log is missing certain expected log messages: \\n\\n %s", buildOutput) + .contains(expectedOutput) + .doesNotContain("Finished generating '" + NATIVE_IMAGE_NAME + "' in"); + Path nativeImagePath = projectDir.toPath().resolve("build").resolve("test"); + assertThat(nativeImagePath).exists(); + Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString()); + try { + final String response = DevModeTestUtils.getHttpResponse("/hello"); + assertThat(response) + .withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response) + .contains("hello"); + } finally { + nativeImageProcess.destroy(); + } + + } + private Process runNativeImage(String nativeImage) throws IOException { final ProcessBuilder processBuilder = new ProcessBuilder(nativeImage); processBuilder.inheritIO(); diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/NativeIntegrationTestIT.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/NativeIntegrationTestIT.java index b387532b8ab..b22b4eab2df 100644 --- a/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/NativeIntegrationTestIT.java +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/NativeIntegrationTestIT.java @@ -19,4 +19,22 @@ public void nativeTestShouldRunIntegrationTest() throws Exception { assertThat(testResult.getTasks().get(":testNative")).isEqualTo(BuildResult.SUCCESS_OUTCOME); } + @Test + public void runNativeTestsWithOutputName() throws Exception { + final File projectDir = getProjectDir("it-test-basic-project"); + + final BuildResult testResult = runGradleWrapper(projectDir, "clean", "testNative", + "-Dquarkus.package.output-name=test"); + assertThat(testResult.getTasks().get(":testNative")).isEqualTo(BuildResult.SUCCESS_OUTCOME); + } + + @Test + public void runNativeTestsWithoutRunnerSuffix() throws Exception { + final File projectDir = getProjectDir("it-test-basic-project"); + + final BuildResult testResult = runGradleWrapper(projectDir, "clean", "testNative", + "-Dquarkus.package.add-runner-suffix=false"); + assertThat(testResult.getTasks().get(":testNative")).isEqualTo(BuildResult.SUCCESS_OUTCOME); + } + }
['devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java', 'devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java', 'integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/NativeIntegrationTestIT.java', 'integration-tests/gradle/src/test/java/io/quarkus/gradle/nativeimage/BasicJavaNativeBuildIT.java']
{'.java': 4}
4
4
0
0
4
24,278,625
4,780,981
619,372
5,677
2,022
378
32
2
2,571
293
697
53
0
1
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,387
quarkusio/quarkus/26898/26776
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26776
https://github.com/quarkusio/quarkus/pull/26898
https://github.com/quarkusio/quarkus/pull/26898
1
fixes
OpenTelemetry: High span name cardinality for invalid HTTP request spans
### Describe the bug This is about the remaining issue from #26216: When using the `quarkus-opentelemetry` extension and observing Vert.x HTTP server request spans, the span names for **invalid HTTP requests** (resulting in status 400 or also 501 responses) contain the full request URI path. The [OTEL spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#name) declares such high cardinality span names as unsuitable. In practice, this means the span selection combobox in the Jaeger UI gets fill with all kinds of weird URI paths of bot requests trying to exploit some vulnerability. ``` /someWeirdPathTryingToExploitSomeVulnerability?someParamX ``` _Some_ of these span names still can get renamed by using a "match-all" Vert.x route with a failure handler (invoking `ctx.request().routed(name)` there), But there are kinds of invalid HTTP requests, for which no route failure handler will get invoked. This happens for example with HTTP requests with an invalid `Content-Length` header value. ### Expected behavior I would expect some fixed span name (e.g. the HTTP request method name) to be used as span name for such invalid HTTP requests - **if** no request route name got set/applied (i.e. no named route got matched and `ctx.request().routed(name)` wasn't invoked). ### Actual behavior High cardinality span names are used. ### How to Reproduce? Make invalid HTTP requests to a quarkus-opentelemetry application having a Vert.x HTTP server endpoint and observe created span names. Examples: `printf 'GET invalid__no_leading_slash HTTP/1.0\\r\\n\\r\\n' | nc -q 3 localhost 80` `printf 'GET /something%%%%3 HTTP/1.0\\r\\n\\r\\n' | nc -q 3 localhost 80` `printf 'GET /something HTTP/1.1\\r\\nContent-Length: 18446744073709551615\\r\\n\\r\\n' | nc -q 3 localhost 80` => no Vert.x route getting invoked `printf 'GET /something HTTP/5.0\\r\\n\\r\\n' | nc -q 3 localhost 80` => this actually returns status 501; no Vert.x route getting invoked ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` openjdk 17.0.3 2022-04-19 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.10.2 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
99269bdc367dcb0ebbb8d0905a56f9837a470b31
9572d44e7261de7be027d4d45c7752d101e2685e
https://github.com/quarkusio/quarkus/compare/99269bdc367dcb0ebbb8d0905a56f9837a470b31...9572d44e7261de7be027d4d45c7752d101e2685e
diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/HelloResource.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/HelloResource.java index 0e9fc7e0722..7d12639ffc5 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/HelloResource.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/HelloResource.java @@ -11,6 +11,7 @@ public class HelloResource { @GET public String get() { + // The span name is not updated with the route yet. return ((ReadableSpan) Span.current()).getName(); } } diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java index 80066dd997d..4ffca2350f3 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java @@ -23,7 +23,7 @@ void testDevMode() { //and the hot replacement stuff is not messing things up RestAssured.when().get("/hello").then() .statusCode(200) - .body(is("/hello")); + .body(is("HTTP GET")); RestAssured.when().get("/tracer").then() .statusCode(200) diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropNamesSampler.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java similarity index 63% rename from extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropNamesSampler.java rename to extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java index e0418cfbdc1..53966c53032 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropNamesSampler.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java @@ -8,14 +8,15 @@ import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingResult; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; -public class DropNamesSampler implements Sampler { +public class DropTargetsSampler implements Sampler { private final Sampler sampler; - private final List<String> dropNames; + private final List<String> dropTargets; - public DropNamesSampler(Sampler sampler, List<String> dropNames) { + public DropTargetsSampler(Sampler sampler, List<String> dropTargets) { this.sampler = sampler; - this.dropNames = dropNames; + this.dropTargets = dropTargets; } @Override @@ -23,10 +24,10 @@ public SamplingResult shouldSample(Context parentContext, String traceId, String Attributes attributes, List<LinkData> parentLinks) { if (spanKind.equals(SpanKind.SERVER)) { - for (String dropName : dropNames) { - if (name.startsWith(dropName)) { - return SamplingResult.drop(); - } + String target = attributes.get(SemanticAttributes.HTTP_TARGET); + // TODO - radcortez - Match /* endpoints + if (target != null && dropTargets.contains(target)) { + return SamplingResult.drop(); } } diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java index 89990890731..31ea877a544 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java @@ -139,14 +139,14 @@ public void setupSampler( List<String> dropStaticResources) { LateBoundSampler lateBoundSampler = CDI.current().select(LateBoundSampler.class, Any.Literal.INSTANCE).get(); - List<String> dropNames = new ArrayList<>(); + List<String> dropTargets = new ArrayList<>(); if (config.suppressNonApplicationUris) { - dropNames.addAll(dropNonApplicationUris); + dropTargets.addAll(dropNonApplicationUris); } if (!config.includeStaticResources) { - dropNames.addAll(dropStaticResources); + dropTargets.addAll(dropStaticResources); } - Sampler samplerBean = TracerUtil.mapSampler(config.sampler, dropNames); + Sampler samplerBean = TracerUtil.mapSampler(config.sampler, dropTargets); lateBoundSampler.setSamplerDelegate(samplerBean); } } diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtil.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtil.java index 632e649c87a..154dc717139 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtil.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtil.java @@ -38,15 +38,15 @@ private static Sampler getBaseSampler(String samplerName, Optional<Double> ratio } public static Sampler mapSampler(TracerRuntimeConfig.SamplerConfig samplerConfig, - List<String> dropNames) { + List<String> dropTargets) { Sampler sampler = CDI.current() .select(Sampler.class, Any.Literal.INSTANCE) .stream() .filter(o -> !(o instanceof LateBoundSampler)) .findFirst().orElseGet(() -> getBaseSampler(samplerConfig.samplerName, samplerConfig.ratio)); - if (!dropNames.isEmpty()) { - sampler = new DropNamesSampler(sampler, dropNames); + if (!dropTargets.isEmpty()) { + sampler = new DropTargetsSampler(sampler, dropTargets); } if (samplerConfig.parentBased) { diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java index cbc01516f96..7ce2937f708 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java @@ -190,7 +190,7 @@ public String target(final HttpRequest request) { @Override public String route(final HttpRequest request) { - return request.uri().length() > 1 ? request.uri() : null; + return null; } @Override diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java index ee81cea9987..55105a03635 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java @@ -1,5 +1,6 @@ package io.quarkus.vertx.http.deployment; +import static io.quarkus.runtime.TemplateHtmlBuilder.adjustRoot; import static io.quarkus.vertx.http.deployment.RouteBuildItem.RouteType.FRAMEWORK_ROUTE; import java.io.IOException; @@ -51,6 +52,7 @@ import io.quarkus.vertx.http.deployment.devmode.HttpRemoteDevClientProvider; import io.quarkus.vertx.http.deployment.devmode.NotFoundPageDisplayableEndpointBuildItem; import io.quarkus.vertx.http.deployment.spi.FrameworkEndpointsBuildItem; +import io.quarkus.vertx.http.runtime.BasicRoute; import io.quarkus.vertx.http.runtime.CurrentRequestProducer; import io.quarkus.vertx.http.runtime.CurrentVertxRequest; import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; @@ -93,8 +95,19 @@ FrameworkEndpointsBuildItem frameworkEndpoints(NonApplicationRootPathBuildItem n List<RouteBuildItem> routes) { List<String> frameworkEndpoints = new ArrayList<>(); for (RouteBuildItem route : routes) { - if (FRAMEWORK_ROUTE.equals(route.getRouteType()) && route.getConfiguredPathInfo() != null) { - frameworkEndpoints.add(route.getConfiguredPathInfo().getEndpointPath(nonApplicationRootPath)); + if (FRAMEWORK_ROUTE.equals(route.getRouteType())) { + if (route.getConfiguredPathInfo() != null) { + frameworkEndpoints.add(route.getConfiguredPathInfo().getEndpointPath(nonApplicationRootPath)); + continue; + } + if (route.getRouteFunction() != null && route.getRouteFunction() instanceof BasicRoute) { + BasicRoute basicRoute = (BasicRoute) route.getRouteFunction(); + if (basicRoute.getPath() != null) { + // Calling TemplateHtmlBuilder does not see very correct here, but it is the underlying API for ConfiguredPathInfo + frameworkEndpoints + .add(adjustRoot(nonApplicationRootPath.getNonApplicationRootPath(), basicRoute.getPath())); + } + } } } return new FrameworkEndpointsBuildItem(frameworkEndpoints);
['extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtil.java', 'extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java', 'extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java', 'extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/HelloResource.java', 'extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java', 'extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java', 'extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropNamesSampler.java']
{'.java': 7}
7
7
0
0
7
22,187,464
4,343,232
565,851
5,289
2,099
383
33
5
2,376
327
603
59
1
1
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,268
quarkusio/quarkus/30737/30690
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30690
https://github.com/quarkusio/quarkus/pull/30737
https://github.com/quarkusio/quarkus/pull/30737
1
fix
Json stream item is not processed immediately after receiving in ChunkedStreamingMultiSubscriber.class
### Describe the bug When using rest endpoint with `application/stream+json` content type, after receiving json object is not processed immediately. Client is expecting stream element separator to process element. Separator is sent as prefix with subsequent elements. This means that stream element is processed after receiving next one. ### Expected behavior Stream element should be processed immediately after receiving. Maybe ChunkedStreamingMultiSubscriber should add separator as postfix, not as prefix with next item. ### Actual behavior Strem element is processed after receiving next one (or stream closed). ### How to Reproduce? Reproducer: https://github.com/paloliska/json-stream steps: 1. Run test in reproducer project. ### Output of `uname -a` or `ver` Linux user 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "17.0.5" 2022-10-18 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.16.0.Final, 3.0.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.6.3 ### Additional information _No response_
3e6b2a557205e7b726885792c9d616fd28042b08
1187551063c62ff694bb36be85bbe4b90fc7eba3
https://github.com/quarkusio/quarkus/compare/3e6b2a557205e7b726885792c9d616fd28042b08...1187551063c62ff694bb36be85bbe4b90fc7eba3
diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamTestCase.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamTestCase.java index 8c7704d24c4..2ae2a7f2895 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamTestCase.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamTestCase.java @@ -153,7 +153,6 @@ public void testStreamJsonMultiFromMulti() { private void testJsonMulti(String path) { Client client = ClientBuilder.newBuilder().register(new JacksonBasicMessageBodyReader(new ObjectMapper())).build(); - WebTarget target = client.target(uri.toString() + path); Multi<Message> multi = target.request().rx(MultiInvoker.class).get(Message.class); List<Message> list = multi.collect().asList().await().atMost(Duration.ofSeconds(30)); diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/StreamJsonTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/StreamJsonTest.java index 07344da0fae..21ae3dd8b2e 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/StreamJsonTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/StreamJsonTest.java @@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.fail; import java.net.URI; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -32,10 +33,14 @@ import io.quarkus.vertx.web.ReactiveRoutes; import io.quarkus.vertx.web.Route; import io.smallrye.mutiny.Multi; +import io.smallrye.mutiny.helpers.test.AssertSubscriber; import io.vertx.core.Vertx; import io.vertx.ext.web.RoutingContext; public class StreamJsonTest { + + private static final long TICK_EVERY_MS = 200; + @RegisterExtension static final QuarkusUnitTest TEST = new QuarkusUnitTest() .withApplicationRoot((jar) -> jar.addClasses(TestJacksonBasicMessageBodyReader.class)); @@ -109,6 +114,21 @@ void shouldReadNdjsonFromSingleMessage() throws InterruptedException { assertThat(collected).hasSize(4).containsAll(expected); } + /** + * Reproduce <a href="https://github.com/quarkusio/quarkus/issues/30690">#30690</a>. + */ + @Test + public void shouldReadUpToThreeTicks() { + createClient(uri) + .ticks() + .onItem() + .invoke(Objects::nonNull) + .subscribe() + .withSubscriber(AssertSubscriber.create(3)) + // wait for 3 ticks plus some half tick ms of extra time (this should not be necessary, but CI is slow) + .awaitItems(3, Duration.ofMillis((TICK_EVERY_MS * 3) + (TICK_EVERY_MS / 2))); + } + private Client createClient(URI uri) { return RestClientBuilder.newBuilder().baseUri(uri).register(new TestJacksonBasicMessageBodyReader()) .build(Client.class); @@ -133,6 +153,12 @@ public interface Client { @Produces(RestMediaType.APPLICATION_STREAM_JSON) @RestStreamElementType(MediaType.APPLICATION_JSON) Multi<Message> readPojoSingle(); + + @GET + @Path("/ticks") + @Produces(RestMediaType.APPLICATION_STREAM_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) + Multi<String> ticks(); } public static class ReactiveRoutesResource { @@ -199,6 +225,19 @@ public String getPojosAsString() throws JsonProcessingException { } return result.toString(); } + + @GET + @Path("/ticks") + @Produces(RestMediaType.APPLICATION_STREAM_JSON) + @RestStreamElementType(MediaType.APPLICATION_JSON) + public Multi<String> getTicks() { + return Multi.createFrom() + .ticks() + .every(Duration.ofMillis(TICK_EVERY_MS)) + .log() + .onItem() + .transform((Long tick) -> "tick " + tick); + } } public static class Message { diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java index e3a8820add5..e84f30da72e 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java @@ -199,12 +199,9 @@ public void handle(Buffer buffer) { charset = charset == null ? "UTF-8" : charset; byte[] separator = "\\n".getBytes(charset); int start = 0; - if (startsWith(bytes, separator)) { - start += separator.length; - } while (start < bytes.length) { int end = bytes.length; - for (int i = start; i < bytes.length - separator.length; i++) { + for (int i = start; i < end; i++) { if (bytes[i] == separator[0]) { int j; boolean matches = true; @@ -222,7 +219,7 @@ public void handle(Buffer buffer) { } if (start < end) { - ByteArrayInputStream in = new ByteArrayInputStream(bytes, start, end - start); + ByteArrayInputStream in = new ByteArrayInputStream(bytes, start, end); R item = restClientRequestContext.readEntity(in, responseType, mediaType, response.getMetadata()); multiRequest.emitter.emit(item); @@ -241,18 +238,6 @@ public void handle(Buffer buffer) { multiRequest.emitter.fail(t); } } - - private boolean startsWith(byte[] array, byte[] prefix) { - if (array.length < prefix.length) { - return false; - } - for (int i = 0; i < prefix.length; i++) { - if (array[i] != prefix[i]) { - return false; - } - } - return true; - } }); // this captures the end of the response diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/StreamingUtil.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/StreamingUtil.java index b32281d6833..fbcec897700 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/StreamingUtil.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/StreamingUtil.java @@ -24,7 +24,8 @@ public class StreamingUtil { public static CompletionStage<?> send(ResteasyReactiveRequestContext context, - List<PublisherResponseHandler.StreamingResponseCustomizer> customizers, Object entity, String prefix) { + List<PublisherResponseHandler.StreamingResponseCustomizer> customizers, Object entity, String prefix, + String suffix) { ServerHttpResponse response = context.serverResponse(); if (response.closed()) { // FIXME: check spec @@ -46,6 +47,13 @@ public static CompletionStage<?> send(ResteasyReactiveRequestContext context, System.arraycopy(data, 0, prefixedData, prefixBytes.length, data.length); data = prefixedData; } + if (suffix != null) { + byte[] suffixBytes = suffix.getBytes(StandardCharsets.US_ASCII); + byte[] suffixedData = new byte[data.length + suffixBytes.length]; + System.arraycopy(data, 0, suffixedData, 0, data.length); + System.arraycopy(suffixBytes, 0, suffixedData, data.length, suffixBytes.length); + data = suffixedData; + } return response.write(data); } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java index 1791a388da2..12c8f2722e7 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java @@ -90,18 +90,18 @@ private static class ChunkedStreamingMultiSubscriber extends StreamingMultiSubsc @Override protected String messagePrefix() { // When message is chunked, we don't need to add prefixes at first - if (isFirstItem) { - isFirstItem = false; - return null; - } + return null; + } - // If it's not the first message, we need to append the messages with end of line delimiter. + @Override + protected String messageSuffix() { return LINE_SEPARATOR; } @Override protected String onCompleteText() { - return LINE_SEPARATOR; + // When message is chunked, we don't need to add text at the end of the messages + return null; } } @@ -128,7 +128,7 @@ private static class StreamingMultiSubscriber extends AbstractMultiSubscriber { public void onNext(Object item) { List<StreamingResponseCustomizer> customizers = determineCustomizers(!hadItem); hadItem = true; - StreamingUtil.send(requestContext, customizers, item, messagePrefix()) + StreamingUtil.send(requestContext, customizers, item, messagePrefix(), messageSuffix()) .handle(new BiFunction<Object, Throwable, Object>() { @Override public Object apply(Object v, Throwable t) { @@ -182,11 +182,15 @@ public void onComplete() { } if (json) { String postfix = onCompleteText(); - byte[] postfixBytes = postfix.getBytes(StandardCharsets.US_ASCII); - requestContext.serverResponse().write(postfixBytes).handle((v, t) -> { + if (postfix != null) { + byte[] postfixBytes = postfix.getBytes(StandardCharsets.US_ASCII); + requestContext.serverResponse().write(postfixBytes).handle((v, t) -> { + super.onComplete(); + return null; + }); + } else { super.onComplete(); - return null; - }); + } } else { super.onComplete(); } @@ -209,6 +213,10 @@ protected String messagePrefix() { // if it's json, the message prefix starts with `[`. return json ? nextJsonPrefix : null; } + + protected String messageSuffix() { + return null; + } } static abstract class AbstractMultiSubscriber implements Subscriber<Object> {
['independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/StreamJsonTest.java', 'extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/streams/StreamTestCase.java', 'independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/MultiInvoker.java', 'independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/StreamingUtil.java']
{'.java': 5}
5
5
0
0
5
26,539,358
5,234,320
674,887
6,233
2,934
516
59
3
1,249
166
307
45
1
0
1970-01-01T00:27:55
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,269
quarkusio/quarkus/30722/30625
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30625
https://github.com/quarkusio/quarkus/pull/30722
https://github.com/quarkusio/quarkus/pull/30722
1
fixes
OIDC authentication loop if Cookie Policy sameSite=strict
### Description Using the OIDC authentication code workflow may lead to a loop of authentication requests, if not properly configured and currently there is no hint to that in the Documentation. If the user visits the app for the first time, the current default setting of `quarkus.oidc.authentication.cookie-same-site=strict` leads to the following chain: 1. user is not authenticated, goes to https://example.org/login, response is ``` 302 Found location: https://provider.org/oauth/authorize?response_type=code&client_id=XXXX&state=YYYY&... set-cookie: q_auth=YYYY|/login?code=XYZ&state=YYYY; Max-Age=1800; Path=/; HTTPOnly; SameSite=Strict ``` 2. User is redirected to provider.org and has to grant the new App permissions for authentication 3. Provider redirects the user to example.org with code & state (Not 302 calls, as user action required!) 4. Because of the sameSite=Strict policy, the q_auth cookie is not send to example.org. So it retriggers an authentication with similar request as in 1 5. User is redirected to provider.org 6. provider.org sends 302 redirect to example.org with code & state, as already logged in 7. 302s were originally started from example.org, so cookie is sent and user is successfully authenticated (could not test that, just my understanding) So after an additional roundtrip, the user is authenticated and everything is ok (if it works as I understand it). However, if provider.org does not send a 302 for the redirection but an html page with a javascript redirect (e.g. gitlab, the only provider I currently test with) this leads to a loop, since the request is originated always from provider.org and with sameSite=strict the cookie will never be send. It's not a bug as it can be configured and many providers probably do the redirect with a 302, but I think it is worth noting in the documentation. The following setting solved the issue for me: ``` quarkus.oidc.authentication.cookie-same-site=lax ``` ### Implementation ideas _No response_
ac9e7eec3837e51419e1373684ec3426329e365e
c4c40bee92ed6301e4841e832c55ceb896b0a39b
https://github.com/quarkusio/quarkus/compare/ac9e7eec3837e51419e1373684ec3426329e365e...c4c40bee92ed6301e4841e832c55ceb896b0a39b
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java index e25c963ca59..ebe214e2d7e 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java @@ -603,7 +603,7 @@ public static enum Source { public static class Authentication { /** - * SameSite attribute values for the session, state and post logout cookies. + * SameSite attribute values for the session cookie. */ public enum CookieSameSite { STRICT, @@ -767,7 +767,7 @@ public enum ResponseMode { public Optional<String> cookieDomain = Optional.empty(); /** - * SameSite attribute for the session, state and post logout cookies. + * SameSite attribute for the session cookie. */ @ConfigItem(defaultValue = "strict") public CookieSameSite cookieSameSite = CookieSameSite.STRICT; diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java index 4dd98f19432..fdf6a4fb4df 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java @@ -799,7 +799,7 @@ public Uni<? extends Void> apply(Void t) { public Void apply(String cookieValue) { String sessionCookie = createCookie(context, configContext.oidcConfig, getSessionCookieName(configContext.oidcConfig), - cookieValue, sessionMaxAge).getValue(); + cookieValue, sessionMaxAge, true).getValue(); if (sessionCookie.length() >= MAX_COOKIE_VALUE_LENGTH) { LOG.warnf( "Session cookie length for the tenant %s is equal or greater than %d bytes." @@ -914,6 +914,11 @@ private String generatePostLogoutState(RoutingContext context, TenantConfigConte static ServerCookie createCookie(RoutingContext context, OidcTenantConfig oidcConfig, String name, String value, long maxAge) { + return createCookie(context, oidcConfig, name, value, maxAge, false); + } + + static ServerCookie createCookie(RoutingContext context, OidcTenantConfig oidcConfig, + String name, String value, long maxAge, boolean sessionCookie) { ServerCookie cookie = new CookieImpl(name, value); cookie.setHttpOnly(true); cookie.setSecure(oidcConfig.authentication.cookieForceSecure || context.request().isSSL()); @@ -924,7 +929,9 @@ static ServerCookie createCookie(RoutingContext context, OidcTenantConfig oidcCo if (auth.cookieDomain.isPresent()) { cookie.setDomain(auth.getCookieDomain().get()); } - cookie.setSameSite(CookieSameSite.valueOf(auth.cookieSameSite.name())); + if (sessionCookie) { + cookie.setSameSite(CookieSameSite.valueOf(auth.cookieSameSite.name())); + } context.response().addCookie(cookie); return cookie; } diff --git a/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java b/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java index e35ee29a41b..67f549bef42 100644 --- a/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java +++ b/integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java @@ -55,9 +55,9 @@ public void testCodeFlowNoConsent() throws IOException { .loadWebResponse(new WebRequest(URI.create("http://localhost:8081/index.html").toURL())); verifyLocationHeader(webClient, webResponse.getResponseHeaderValue("location"), null, "web-app", false); - String stateCookieString = webResponse.getResponseHeaderValue("Set-Cookie"); - assertTrue(stateCookieString.startsWith("q_auth_Default_test=")); - assertTrue(stateCookieString.contains("SameSite=Strict")); + Cookie stateCookie = getStateCookie(webClient, null); + assertNotNull(stateCookie); + assertNull(stateCookie.getSameSite()); webClient.getCookieManager().clearCookies(); @@ -95,6 +95,7 @@ public void testCodeFlowNoConsent() throws IOException { Cookie sessionCookie = getSessionCookie(webClient, null); assertNotNull(sessionCookie); + assertEquals("strict", sessionCookie.getSameSite()); webClient.getCookieManager().clearCookies(); } @@ -176,10 +177,6 @@ public void testCodeFlowForceHttpsRedirectUriAndPkce() throws Exception { verifyLocationHeader(webClient, keycloakUrl, "tenant-https_test", "xforwarded%2Ftenant-https", true); - String stateCookieString = webResponse.getResponseHeaderValue("Set-Cookie"); - assertTrue(stateCookieString.startsWith("q_auth_tenant-https_test=")); - assertTrue(stateCookieString.contains("SameSite=Lax")); - HtmlPage page = webClient.getPage(keycloakUrl); assertEquals("Sign in to quarkus", page.getTitleText()); @@ -195,6 +192,7 @@ public void testCodeFlowForceHttpsRedirectUriAndPkce() throws Exception { String endpointLocation = webResponse.getResponseHeaderValue("location"); Cookie stateCookie = getStateCookie(webClient, "tenant-https_test"); + assertNull(stateCookie.getSameSite()); verifyCodeVerifier(stateCookie, keycloakUrl); assertTrue(endpointLocation.startsWith("https")); @@ -222,6 +220,7 @@ public void testCodeFlowForceHttpsRedirectUriAndPkce() throws Exception { assertEquals("tenant-https:reauthenticated", page.getBody().asNormalizedText()); Cookie sessionCookie = getSessionCookie(webClient, "tenant-https_test"); assertNotNull(sessionCookie); + assertEquals("lax", sessionCookie.getSameSite()); webClient.getCookieManager().clearCookies(); } }
['integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java']
{'.java': 3}
3
3
0
0
3
24,511,260
4,826,460
624,903
5,726
928
172
15
2
2,032
292
464
33
2
2
1970-01-01T00:27:55
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,270
quarkusio/quarkus/30709/30697
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30697
https://github.com/quarkusio/quarkus/pull/30709
https://github.com/quarkusio/quarkus/pull/30709
1
fixes
Erroneous warnings after #30620
### Describe the bug https://github.com/quarkusio/quarkus/pull/30620 results in erroneous warnings, e.g.: ``` [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.smallrye-jwt.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo ``` while `quarkus-smallrye-jwt` is properly set as a dependency. ### Expected behavior Build should complete without warnings for properly configured apps. ### Actual behavior Build completes but prints the following erroneous warnings: ``` [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.native.additional-build-args" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.endpoint" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.sampler-type" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.ssl.native" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.smallrye-jwt.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.sampler-param" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.jaeger.service-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo [WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.rest-client."com.example.quarkus.client.Service".url" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo ``` ### How to Reproduce? ``` git clone https://github.com/Karm/mandrel-integration-tests.git cd mandrel-integration-tests/apps/quarkus-full-microprofile mvn clean package -Dquarkus.version=999-SNAPSHOT ``` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev b1ecd0b065bdc0f783b55581ea872aee38152db3 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
0d6eac7f9557ff9be8352f2b8687feca18209853
f81b774cc62ead96e88ba245789f71d377e5c75e
https://github.com/quarkusio/quarkus/compare/0d6eac7f9557ff9be8352f2b8687feca18209853...f81b774cc62ead96e88ba245789f71d377e5c75e
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java index 32918f8aead..1af98cc2cd3 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java @@ -443,6 +443,7 @@ ReadResult run() { if (ni.hasNext() && PropertiesUtil.isPropertyInRoot(registeredRoots, ni)) { // build time patterns Container matched = buildTimePatternMap.match(ni); + boolean knownProperty = matched != null; if (matched instanceof FieldContainer) { ConfigValue configValue = config.getConfigValue(propertyName); if (configValue.getValue() != null) { @@ -471,6 +472,7 @@ ReadResult run() { // build time (run time visible) patterns ni.goToStart(); matched = buildTimeRunTimePatternMap.match(ni); + knownProperty = knownProperty || matched != null; if (matched instanceof FieldContainer) { ConfigValue configValue = config.getConfigValue(propertyName); if (configValue.getValue() != null) { @@ -501,6 +503,7 @@ ReadResult run() { // run time patterns ni.goToStart(); matched = runTimePatternMap.match(ni); + knownProperty = knownProperty || matched != null; if (matched != null) { // it's a run-time default (record for later) ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName)); @@ -511,6 +514,7 @@ ReadResult run() { // also check for the bootstrap properties since those need to be added to runTimeDefaultValues as well ni.goToStart(); matched = bootstrapPatternMap.match(ni); + knownProperty = knownProperty || matched != null; if (matched != null) { // it's a run-time default (record for later) ConfigValue configValue = withoutExpansion(() -> runtimeDefaultsConfig.getConfigValue(propertyName)); @@ -519,7 +523,7 @@ ReadResult run() { } } - if (matched == null) { + if (!knownProperty) { unknownBuildProperties.add(propertyName); } } else { diff --git a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java index 490a1ff9f18..2bb9c6a755c 100644 --- a/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java +++ b/integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java @@ -1,10 +1,12 @@ package io.quarkus.extest; -import static java.util.Arrays.asList; +import static java.util.stream.Collectors.toSet; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -28,11 +30,22 @@ public class UnknownBuildConfigTest { void unknownBuildConfig() { List<LogRecord> logRecords = prodModeTestResults.getRetainedBuildLogRecords(); - Optional<LogRecord> unknownBuildKey = logRecords.stream() - .filter(logRecord -> asList(Optional.ofNullable(logRecord.getParameters()).orElse(new Object[0])) - .contains("quarkus.build.unknown.prop")) - .findFirst(); - assertTrue(unknownBuildKey.isPresent()); - assertTrue(unknownBuildKey.get().getMessage().startsWith("Unrecognized configuration key")); + // These are the expected unknown properties in the test extension. This could probably be improved, because + // these are generated with the rename test. If there is a change we know that something happened. + Set<Object> unrecognized = logRecords.stream() + .filter(logRecord -> logRecord.getMessage().startsWith("Unrecognized configuration key")) + .map(logRecord -> Optional.ofNullable(logRecord.getParameters()) + .map(parameters -> parameters[0]) + .orElse(new Object[0])) + .collect(toSet()); + + assertEquals(7, logRecords.size()); + assertTrue(unrecognized.contains("quarkus.unknown.prop")); + assertTrue(unrecognized.contains("quarkus.build.unknown.prop")); + assertTrue(unrecognized.contains("quarkus.rename-old.prop")); + assertTrue(unrecognized.contains("quarkus.rename-old.only-in-new")); + assertTrue(unrecognized.contains("quarkus.rename-old.only-in-old")); + assertTrue(unrecognized.contains("quarkus.rename-old.in-both")); + assertTrue(unrecognized.contains("quarkus.rename-old.with-default")); } }
['core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java', 'integration-tests/test-extension/extension/deployment/src/test/java/io/quarkus/extest/UnknownBuildConfigTest.java']
{'.java': 2}
2
2
0
0
2
24,514,739
4,826,981
624,916
5,724
361
57
6
1
3,000
380
710
61
2
3
1970-01-01T00:27:55
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,398
quarkusio/quarkus/26605/26603
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26603
https://github.com/quarkusio/quarkus/pull/26605
https://github.com/quarkusio/quarkus/pull/26605
1
fixes
Kafka dev service redpanda container failing with Text file busy
### Describe the bug While using the Kafka Dev service I entered into a racing condition on the writing of the startup redpanda.sh script and its execution resulting in the following stacktrace: ``` 2022-07-07 09:04:17,861 INFO [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final-redhat-00001 2022-07-07 09:04:18,933 WARN [org.tes.uti.TestcontainersConfiguration] (build-11) Attempted to read Testcontainers configuration file at file:/home/acs_dev/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: /home/acs_dev/.testcontainers.properties (No such file or directory) 2022-07-07 09:04:19,179 WARN [io.qua.mic.dep.bin.mpm.MicroprofileMetricsProcessor] (build-21) This application uses the MP Metrics API. The micrometer extension currently provides a compatibility layer that supports the MP Metrics API, but metric names and recorded values will be different. Note that the MP Metrics compatibility layer will move to a different extension in the future. 2022-07-07 09:04:19,193 INFO [io.qua.sma.rea.kaf.dep.SmallRyeReactiveMessagingKafkaProcessor] (build-33) Generating Jackson serializer for type com.amadeus.middleware.multipayload.MultiPayload 2022-07-07 09:04:19,681 INFO [org.tes.doc.DockerClientProviderStrategy] (build-11) Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=unix:///var/run/swb_docker.sock 2022-07-07 09:04:19,704 INFO [org.tes.DockerClientFactory] (build-11) Docker host IP address is 192.168.0.1 2022-07-07 09:04:19,743 INFO [org.tes.DockerClientFactory] (build-11) Connected to docker: Server Version: 20.10.17 API Version: 1.41 Operating System: RHEV Total Memory: 16027 MB 2022-07-07 09:04:19,752 INFO [org.tes.uti.ImageNameSubstitutor] (build-11) Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor') 2022-07-07 09:04:19,754 WARN [org.tes.uti.ConfigurationFileImageNameSubstitutor] (build-11) Image name testcontainers/ryuk:0.3.3 was substituted by configuration to dockerhub.rnd.amadeus.net:5002/testcontainers/ryuk:0.3.3. This approach is deprecated and will be removed in the future 2022-07-07 09:04:19,755 INFO [org.tes.uti.ImageNameSubstitutor] (build-11) Using dockerhub.rnd.amadeus.net:5002/testcontainers/ryuk:0.3.3 as a substitute image for testcontainers/ryuk:0.3.3 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')) 2022-07-07 09:04:19,798 INFO [org.tes.uti.RegistryAuthLocator] (build-11) Failure when attempting to lookup auth config. Please ignore if you don't have images in an authenticated registry. Details: (dockerImageName: dockerhub.rnd.amadeus.net:5002/testcontainers/ryuk:0.3.3, configFile: /home/acs_dev/.docker/config.json. Falling back to docker-java default behaviour. Exception message: /home/acs_dev/.docker/config.json (No such file or directory) 2022-07-07 09:04:20,382 INFO [org.tes.DockerClientFactory] (build-11) Ryuk started - will monitor and terminate Testcontainers containers on JVM exit 2022-07-07 09:04:20,383 INFO [org.tes.DockerClientFactory] (build-11) Checking the system... 2022-07-07 09:04:20,384 INFO [org.tes.DockerClientFactory] (build-11) ?? Docker server version should be at least 1.6.0 2022-07-07 09:04:20,466 INFO [org.tes.DockerClientFactory] (build-11) ?? Docker environment should have more than 2GB free disk space 2022-07-07 09:04:20,654 INFO [doc.rnd.ama.net.1.3]] (build-11) Creating container for image: dockerhub.rnd.amadeus.net:5002/vectorized/redpanda:v22.1.3 2022-07-07 09:04:20,788 INFO [doc.rnd.ama.net.1.3]] (build-11) Container dockerhub.rnd.amadeus.net:5002/vectorized/redpanda:v22.1.3 is starting: e5dd590d0ec804d7c41a6a10e639e9eeed49c4fe14a2b036dc3337e27e2766d5 2022-07-07 09:04:21,531 ERROR [doc.rnd.ama.net.1.3]] (build-11) Could not start container: java.lang.IllegalStateException: Container did not start correctly. at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:463) at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:331) at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81) at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:329) at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317) at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.lambda$startKafka$5(DevServicesKafkaProcessor.java:240) at java.base/java.util.Optional.orElseGet(Optional.java:364) at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.startKafka(DevServicesKafkaProcessor.java:248) at io.quarkus.kafka.client.deployment.DevServicesKafkaProcessor.startKafkaDevService(DevServicesKafkaProcessor.java:103) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) 2022-07-07 09:04:21,554 ERROR [doc.rnd.ama.net.1.3]] (build-11) Log output from the failed container: sh: 1: /var/lib/redpanda/redpanda.sh: Text file busy ``` ### Expected behavior The dev services / redpanda container start correctly and the QuarkusTest depending on it executes correctly. ### Actual behavior In a racing condition the following startup line: ```sh sh -c "while [ ! -f /var/lib/redpanda/redpanda.sh ]; do sleep 0.1; done; /var/lib/redpanda/redpanda.sh ``` fails with: ``` sh: 1: /var/lib/redpanda/redpanda.sh: Text file busy ``` In DevservicesKafkaProcessor we can see that a methods transfers this shell script contents after the docker container has been started, probably to inject configuration from Java. I think the pb is that in my case is that the contents are still being written on disk while the condition of existence already becomes true and the startup comand gets executed. Indeed the Test file busy error is raised when executing an executable file that is being edited. ### How to Reproduce? As said it is not systematic... Happens only rarely. ### Output of `uname -a` or `ver` Linux 5.13.0-52-generic #59~20.04.1-Ubuntu SMP Thu Jun 16 21:21:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1) OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 8ecbe2c5282b26227139798e610cb98a176db974 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0) Maven home: /home/edeweerd/bin/apache-maven-3.8.5 Java version: 11.0.13.0.1, vendor: Oracle Corporation, runtime: /home/edeweerd/bin/java-11.0.3-oracle Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.13.0-52-generic", arch: "amd64", family: "unix" ### Additional information _No response_
e12dde57ca09f0dd001bb5f00d88906b64987cd5
7606630598f749192c69e27bb1f19c43eb86076b
https://github.com/quarkusio/quarkus/compare/e12dde57ca09f0dd001bb5f00d88906b64987cd5...7606630598f749192c69e27bb1f19c43eb86076b
diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java index 02f3179f02a..265a113e8a1 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java @@ -42,7 +42,8 @@ final class RedPandaKafkaContainer extends GenericContainer<RedPandaKafkaContain withCreateContainerCmdModifier(cmd -> { cmd.withEntrypoint("sh"); }); - withCommand("-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT); + withCommand("-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; sleep 0.1; " + + STARTER_SCRIPT); waitingFor(Wait.forLogMessage(".*Started Kafka API server.*", 1)); }
['extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java']
{'.java': 1}
1
1
0
0
1
22,059,350
4,319,043
562,700
5,244
243
77
3
1
7,914
687
2,296
100
0
3
1970-01-01T00:27:37
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,397
quarkusio/quarkus/26624/24308
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/24308
https://github.com/quarkusio/quarkus/pull/26624
https://github.com/quarkusio/quarkus/pull/26624
1
fixes
Apicurio Devservice can not be configured with apicurio-registry-mem images from outside of DockerHub
### Describe the bug Apicurio DevServices requires images from apicurio/apicurio-registry-mem. Due to this constraint we cannot use the Apicurio images copied to our own container registry. In order to avoid reaching our DockerHub download limits, we try to use as much as possible images copied to our own registry. ### Expected behavior It should be possible to start the Apicurio DevService using Apicurio images from any repository ### Actual behavior ``` ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor#startApicurioRegistryDevService threw an exception: java.lang.RuntimeException: java.lang.IllegalArgumentException: Only apicurio/apicurio-registry-mem images are supported at io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor.startApicurioRegistryDevService(DevServicesApicurioRegistryProcessor.java:92) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) Caused by: java.lang.IllegalArgumentException: Only apicurio/apicurio-registry-mem images are supported at io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor$ApicurioRegistryContainer.<init>(DevServicesApicurioRegistryProcessor.java:273) at io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor.lambda$startApicurioRegistry$1(DevServicesApicurioRegistryProcessor.java:165) at java.base/java.util.Optional.orElseGet(Optional.java:364) at io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor.startApicurioRegistry(DevServicesApicurioRegistryProcessor.java:162) at io.quarkus.apicurio.registry.avro.DevServicesApicurioRegistryProcessor.startApicurioRegistryDevService(DevServicesApicurioRegistryProcessor.java:83) ``` ### How to Reproduce? 1. In the Avro Kafka quickstart project (https://github.com/quarkusio/quarkus-quickstarts/tree/main/kafka-avro-schema-quickstart) configure the following property in the `application.properties` `quarkus.apicurio-registry.devservices.image-name=quay.io/apicurio/apicurio-registry-mem:2.2.1.Final` You can substitute this image for any similar images stored in a container registry different from DockerHub 2. Start the quickstart service with `mvn quarkus:dev` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 11.0.14 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.7.4.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.2 ### Additional information There is an solved issue similar to this one but for the Kafka DevService : https://github.com/quarkusio/quarkus/issues/23978
19cba3c274d13cba28d7f54274d93902f7c5c8a5
d0e1915dc36ffe6e3bbe9da967b6e50ba08878e6
https://github.com/quarkusio/quarkus/compare/19cba3c274d13cba28d7f54274d93902f7c5c8a5...d0e1915dc36ffe6e3bbe9da967b6e50ba08878e6
diff --git a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java index 215893702e3..8a9e06a4a9b 100644 --- a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java +++ b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java @@ -29,6 +29,7 @@ public class ApicurioRegistryDevServicesBuildTimeConfig { /** * The Apicurio Registry image to use. * Note that only Apicurio Registry 2.x images are supported. + * Specifically, the image repository must end with {@code apicurio/apicurio-registry-mem}. */ @ConfigItem(defaultValue = "quay.io/apicurio/apicurio-registry-mem:2.2.3.Final") public String imageName; diff --git a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java index 89019e19ccf..7328d978c35 100644 --- a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java +++ b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java @@ -259,7 +259,7 @@ private ApicurioRegistryContainer(DockerImageName dockerImageName, int fixedExpo withLabel(DEV_SERVICE_LABEL, serviceName); } withEnv("QUARKUS_PROFILE", "prod"); - if (!dockerImageName.getRepository().equals("apicurio/apicurio-registry-mem")) { + if (!dockerImageName.getRepository().endsWith("apicurio/apicurio-registry-mem")) { throw new IllegalArgumentException("Only apicurio/apicurio-registry-mem images are supported"); } } diff --git a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java index e5b8527883b..8ff1ec29002 100644 --- a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java +++ b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java @@ -27,7 +27,8 @@ public class AmqpDevServicesBuildTimeConfig { /** * The image to use. - * Note that only {@code quay.io/artemiscloud/activemq-artemis-broker} images are supported. + * Note that only ActiveMQ Artemis images are supported. + * Specifically, the image repository must end with {@code artemiscloud/activemq-artemis-broker}. * * Check https://quay.io/repository/artemiscloud/activemq-artemis-broker to find the available versions. */ diff --git a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java index 3ba67d99a20..7203c06c099 100644 --- a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java +++ b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java @@ -282,7 +282,7 @@ private ArtemisContainer(DockerImageName dockerImageName, String extra, int fixe if (serviceName != null) { // Only adds the label in dev mode. withLabel(DEV_SERVICE_LABEL, serviceName); } - if (dockerImageName.getRepository().equals("artemiscloud/activemq-artemis-broker")) { + if (dockerImageName.getRepository().endsWith("artemiscloud/activemq-artemis-broker")) { waitingFor(Wait.forLogMessage(".*AMQ241004.*", 1)); // Artemis console available. } else { throw new IllegalArgumentException("Only artemiscloud/activemq-artemis-broker images are supported"); diff --git a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java index 8f677373d33..ff4617cdd6d 100644 --- a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java +++ b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java @@ -122,6 +122,8 @@ public static class Binding { /** * The image to use. + * Note that only official RabbitMQ images are supported. + * Specifically, the image repository must end with {@code rabbitmq}. */ @ConfigItem(defaultValue = "rabbitmq:3.9-management") public String imageName; diff --git a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java index 666ff26f498..9698887ca2f 100644 --- a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java +++ b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java @@ -374,7 +374,7 @@ private ConfiguredRabbitMQContainer(DockerImageName dockerImageName, int fixedEx if (serviceName != null) { // Only adds the label in dev mode. withLabel(DEV_SERVICE_LABEL, serviceName); } - if (!dockerImageName.getRepository().equals("rabbitmq")) { + if (!dockerImageName.getRepository().endsWith("rabbitmq")) { throw new IllegalArgumentException("Only official rabbitmq images are supported"); } }
['extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java', 'extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java', 'extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java', 'extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java', 'extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java', 'extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java']
{'.java': 6}
6
6
0
0
6
22,078,439
4,322,406
563,098
5,245
1,028
251
12
6
3,780
254
939
66
2
1
1970-01-01T00:27:37
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,395
quarkusio/quarkus/26729/26586
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26586
https://github.com/quarkusio/quarkus/pull/26729
https://github.com/quarkusio/quarkus/pull/26729
1
close
workingDir in quarkusDev not respected by gradle anymore
### Describe the bug We set the workingDir in gradle like the following: ```gradle quarkusDev { workingDir = rootProject.projectDir } ``` We use this, so that the configuration `config/application.properies` is found and loaded for dev-mode. Since 1.10.x this isn't working anymore and it tries to load the config `\\build\\classes\\java\\main\\config\\application.properties` like when the workingDir is not set. ### Expected behavior It should load the configuration from the `workingDir/config/application.properties` ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 1.10.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) gradle 7.4.2 ### Additional information _No response_
32ff92ac09514b47499aab4deec29c4e30cefbab
cffa07225f50cded82b391d4933282c69f3e2f39
https://github.com/quarkusio/quarkus/compare/32ff92ac09514b47499aab4deec29c4e30cefbab...cffa07225f50cded82b391d4933282c69f3e2f39
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index 63b8fbd7c5b..88193badc9d 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -279,7 +279,7 @@ public void startDev() { String outputFile = System.getProperty(IO_QUARKUS_DEVMODE_ARGS); if (outputFile == null) { getProject().exec(action -> { - action.commandLine(runner.args()).workingDir(QuarkusPluginExtension.getLastFile(getCompilationOutput())); + action.commandLine(runner.args()).workingDir(getWorkingDirectory().get()); action.setStandardInput(System.in) .setErrorOutput(System.out) .setStandardOutput(System.out);
['devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java']
{'.java': 1}
1
1
0
0
1
22,081,704
4,322,520
563,131
5,247
222
38
2
1
944
127
229
47
0
1
1970-01-01T00:27:37
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,272
quarkusio/quarkus/30673/20228
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/20228
https://github.com/quarkusio/quarkus/pull/30673
https://github.com/quarkusio/quarkus/pull/30673
1
fixes
RestAssured not configured to use the correct port when `quarkus.http.test-ssl-port` is set
### Describe the bug When a custom value for `quarkus.http.test-ssl-port` is set, RestAssured seems to not be configured to use it. Digging into the code, it appears that it's actually attempting to be set by resolving config property `quarkus.https.test-port`. https://github.com/quarkusio/quarkus/blob/main/test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java#L118-L120 There's also a couple of other references to it in the codebase: https://github.com/quarkusio/quarkus/search?q=%22quarkus.https.test-port%22 ### Expected behavior The RestAssured port is configured to use the value of `quarkus.http.test-ssl-port`. ### Actual behavior `RestAssured.port` evaluates to `8444` and not the value of `quarkus.http.test-ssl-port`. ### How to Reproduce? Create a unit test where `quarkus.http.test-ssl-port` is configured. Then use RestAssured to try and hit a server endpoint. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
24bae5822342b2bec5e81b16fe5d0e53793b3389
3b631a587c981e610f6e86e7d9b3d1ce7549edd9
https://github.com/quarkusio/quarkus/compare/24bae5822342b2bec5e81b16fe5d0e53793b3389...3b631a587c981e610f6e86e7d9b3d1ce7549edd9
diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 18f5922d014..46574597ede 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -1348,8 +1348,8 @@ public void stop(Promise<Void> stopFuture) { } if (clearHttpsProperty) { - String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.https.test-port" - : "quarkus.https.port"; + String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.http.test-ssl-port" + : "quarkus.http.ssl-port"; System.clearProperty(portPropertyName); if (launchMode.isDevOrTest()) { System.clearProperty(propertyWithProfilePrefix(portPropertyName)); diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java b/test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java index 977ebad843e..a6e4dac9d4f 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java @@ -115,7 +115,7 @@ public static void setURL(boolean useSecureConnection, Integer port, String addi try { oldPort = (Integer) portField.get(null); if (port == null) { - port = useSecureConnection ? getPortFromConfig(DEFAULT_HTTPS_PORT, "quarkus.https.test-port") + port = useSecureConnection ? getPortFromConfig(DEFAULT_HTTPS_PORT, "quarkus.http.test-ssl-port") : getPortFromConfig(DEFAULT_HTTP_PORT, "quarkus.lambda.mock-event-server.test-port", "quarkus.http.test-port"); } diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java index 23ff28ca549..2284f19120c 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java @@ -655,7 +655,7 @@ private void setupRestAssured() { .map(Integer::parseInt) .orElse(DEFAULT_HTTP_PORT_INT); - // If http port is 0, then we need to set the port to null in order to use the `quarkus.https.test-port` property + // If http port is 0, then we need to set the port to null in order to use the `quarkus.http.test-ssl-port` property // which is done in `RestAssuredURLManager.setURL`. if (httpPort == 0) { httpPort = null;
['test-framework/common/src/main/java/io/quarkus/test/common/RestAssuredURLManager.java', 'test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java']
{'.java': 3}
3
3
0
0
3
24,472,525
4,818,469
623,934
5,717
337
63
4
1
1,259
153
322
45
2
0
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,273
quarkusio/quarkus/30578/30571
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30571
https://github.com/quarkusio/quarkus/pull/30578
https://github.com/quarkusio/quarkus/pull/30578
1
fixes
fix the set of bean types when one of supertypes is a raw type
### Describe the bug If a bean class has a _raw type_ as one of its supertypes, ArC does not construct the set of bean types correctly. The JLS says: > The superclass types (respectively, superinterface types) of a raw type are the erasures of the superclass types (superinterface types) of the named class or interface. But ArC does not reflect this. ### Expected behavior Erasures of supertypes of a raw type should be present in the set of bean types. ### Actual behavior Not erased supertypes of a raw type are present in the set of bean types. ### How to Reproduce? CDI TCK, test `org.jboss.cdi.tck.tests.definition.bean.BeanDefinitionTest#testRawBeanTypes`. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
93ec8e6590834f9ffd2a63b479a85a8da1d71606
8ba81382036634645f8326f3952d2ca3ab5f91ba
https://github.com/quarkusio/quarkus/compare/93ec8e6590834f9ffd2a63b479a85a8da1d71606...8ba81382036634645f8326f3952d2ca3ab5f91ba
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java index 54f0af4547b..5066d07f874 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java @@ -517,12 +517,13 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr boolean throwOnProducerWildcard, Map<String, Type> resolvedTypeParameters, BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer, - Set<Type> unrestrictedBeanTypes) { + Set<Type> unrestrictedBeanTypes, boolean rawGeneric) { Set<Type> types = new HashSet<>(); List<TypeVariable> typeParameters = classInfo.typeParameters(); if (typeParameters.isEmpty() - || !typeParameters.stream().allMatch(it -> resolvedTypeParameters.containsKey(it.identifier()))) { + || !typeParameters.stream().allMatch(it -> resolvedTypeParameters.containsKey(it.identifier())) + || rawGeneric) { // Not a parameterized type or a raw type types.add(Type.create(classInfo.name(), Kind.CLASS)); } else { @@ -562,7 +563,8 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr interfaceClassInfo.typeParameters(), resolvedTypeParameters, beanDeployment.getBeanArchiveIndex()); } types.addAll(getTypeClosure(interfaceClassInfo, producerFieldOrMethod, false, resolved, beanDeployment, - resolvedTypeVariablesConsumer, unrestrictedBeanTypes)); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes, + rawGeneric || isRawGeneric(interfaceType, interfaceClassInfo))); } } // Superclass @@ -576,19 +578,25 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr resolvedTypeParameters, beanDeployment.getBeanArchiveIndex()); } types.addAll(getTypeClosure(superClassInfo, producerFieldOrMethod, false, resolved, beanDeployment, - resolvedTypeVariablesConsumer, unrestrictedBeanTypes)); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes, + rawGeneric || isRawGeneric(classInfo.superClassType(), superClassInfo))); } } unrestrictedBeanTypes.addAll(types); return types; } + // if the superclass type is CLASS *AND* and superclass info has type parameters, then it's raw type + private static boolean isRawGeneric(Type superClassType, ClassInfo superClassInfo) { + return Kind.CLASS.equals(superClassType.kind()) && !superClassInfo.typeParameters().isEmpty(); + } + static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget producerFieldOrMethod, Map<String, Type> resolvedTypeParameters, BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer, Set<Type> unrestrictedBeanTypes) { return getTypeClosure(classInfo, producerFieldOrMethod, true, resolvedTypeParameters, beanDeployment, - resolvedTypeVariablesConsumer, unrestrictedBeanTypes); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes, false); } static Set<Type> getDelegateTypeClosure(InjectionPointInfo delegateInjectionPoint, BeanDeployment beanDeployment) { diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java index 86ddf65858e..64f9539567b 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java @@ -30,7 +30,8 @@ public class TypesTest { @Test public void testGetTypeClosure() throws IOException { IndexView index = Basics.index(Foo.class, Baz.class, Producer.class, Object.class, List.class, Collection.class, - Iterable.class, Set.class, Eagle.class, Bird.class, Animal.class, AnimalHolder.class); + Iterable.class, Set.class, Eagle.class, Bird.class, Animal.class, AnimalHolder.class, MyRawBean.class, + MyBean.class, MyInterface.class, MySuperInterface.class); DotName bazName = DotName.createSimple(Baz.class.getName()); DotName fooName = DotName.createSimple(Foo.class.getName()); DotName producerName = DotName.createSimple(Producer.class.getName()); @@ -93,6 +94,17 @@ public void testGetTypeClosure() throws IOException { assertDoesNotThrow( () -> verifyEagleTypes(Types.getClassBeanTypeClosure(index.getClassByName(DotName.createSimple(Eagle.class)), dummyDeployment))); + + // raw type bean + Set<Type> rawBeanTypes = Types.getClassBeanTypeClosure(index.getClassByName(DotName.createSimple(MyRawBean.class)), + dummyDeployment); + assertEquals(rawBeanTypes.size(), 5); + assertContainsType(MyRawBean.class, rawBeanTypes); + assertContainsType(MyBean.class, rawBeanTypes); + assertContainsType(MyInterface.class, rawBeanTypes); + // according to JLS, for raw type generics, their superclasses have erasure applied so this should be a match + assertContainsType(MySuperInterface.class, rawBeanTypes); + assertContainsType(Object.class, rawBeanTypes); } private void verifyEagleTypes(Set<Type> types) { @@ -104,6 +116,10 @@ private void verifyEagleTypes(Set<Type> types) { assertEquals(3, types.size()); } + private void assertContainsType(Class<?> clazz, Set<Type> rawBeanTypes) { + assertTrue(rawBeanTypes.contains(Type.create(DotName.createSimple(clazz.getName()), Kind.CLASS))); + } + static class Foo<T> { T field; @@ -149,4 +165,16 @@ public Eagle<T> eagleProducer() { static class AnimalHolder<T extends Animal> { } + + static class MyRawBean extends MyBean { + } + + static class MyBean<T> implements MyInterface { + } + + interface MyInterface extends MySuperInterface<Number> { + } + + interface MySuperInterface<T> { + } }
['independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java', 'independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java']
{'.java': 2}
2
2
0
0
2
24,448,717
4,813,716
623,363
5,708
1,347
220
18
1
1,048
158
250
43
0
0
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,274
quarkusio/quarkus/30576/30343
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30343
https://github.com/quarkusio/quarkus/pull/30576
https://github.com/quarkusio/quarkus/pull/30576
1
fixes
Trailing comma is lost from prometheus metrics
### Describe the bug In all released versions (including 2.15.3.Final), prometheus metrics (accessible at 'q/metrics') has format of json object with a trailing comma. In the current main branch (tested on dc85cd0d16c44a264507529c9ee26e26c7ffe175) the format is changed, and the comma was lost. Is this an expected change? Prometheus format allows[1] for both options, but that change may broke parsing of logs and therefore it would be nice to have it documented [1] https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators ### Expected behavior Example: `http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/hello",} 1.0` ### Actual behavior `http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/hello"} 6.0` ### How to Reproduce? 1. `mvn io.quarkus.platform:quarkus-maven-plugin:2.15.3.Final:create -DprojectGroupId=org.acme -DprojectArtifactId=micrometer-quickstart -Dextensions='resteasy-reactive,micrometer-registry-prometheus'` 2. `cd micrometer-quickstart` 3. `mvn quarkus:dev -Dquarkus.platform.version=999-SNAPSHOT` 4. `curl http://localhost:8080/hello/` 5. `curl http://localhost:8080/q/metrics | grep http_server_requests_seconds_count # example, many (all?) other metrics also changed` for comparision, replace step 3 with `mvn quarkus:dev -Dquarkus.platform.version=2.15.3.Final` ### Output of `uname -a` or `ver` 6.0.18-300.fc37.x86_64 ### Output of `java -version` 17.0.4, vendor: GraalVM Community ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev dc85cd0d16c44a264507529c9ee26e26c7ffe175 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) ### Additional information _No response_
d004bcf15723446cb012194b86e6e0fb1ee1eb98
1191b165fe771b545fbe21e4bf582273cf8c0d29
https://github.com/quarkusio/quarkus/compare/d004bcf15723446cb012194b86e6e0fb1ee1eb98...1191b165fe771b545fbe21e4bf582273cf8c0d29
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonRecorder.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonRecorder.java index 9ab0a33fb7d..af127457e7d 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonRecorder.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonRecorder.java @@ -22,7 +22,7 @@ public Consumer<Route> route() { return new Consumer<Route>() { @Override public void accept(Route route) { - route.order(2).produces("application/json"); + route.order(3).produces("application/json"); } }; } diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusRecorder.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusRecorder.java index 43add789032..f6efecf5d9b 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusRecorder.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusRecorder.java @@ -2,6 +2,7 @@ import java.util.function.Consumer; +import io.prometheus.client.exporter.common.TextFormat; import io.quarkus.micrometer.runtime.export.handlers.PrometheusHandler; import io.quarkus.runtime.annotations.Recorder; import io.vertx.core.Handler; @@ -26,6 +27,7 @@ public Consumer<Route> route() { @Override public void accept(Route route) { route.order(1).produces("text/plain"); + route.order(2).produces(TextFormat.CONTENT_TYPE_OPENMETRICS_100); } }; } diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java index 391452fb929..71409f51d82 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java @@ -34,12 +34,13 @@ public void handle(RoutingContext routingContext) { .setStatusMessage("Unable to resolve Prometheus registry instance"); } else { ManagedContext requestContext = Arc.container().requestContext(); + var acceptHeader = chooseContentType(routingContext.request().getHeader("Accept")); if (requestContext.isActive()) { - doHandle(response); + doHandle(response, acceptHeader); } else { requestContext.activate(); try { - doHandle(response); + doHandle(response, acceptHeader); } finally { requestContext.terminate(); } @@ -47,9 +48,19 @@ public void handle(RoutingContext routingContext) { } } - private void doHandle(HttpServerResponse response) { - response.putHeader("Content-Type", TextFormat.CONTENT_TYPE_OPENMETRICS_100) - .end(Buffer.buffer(registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100))); + private String chooseContentType(String acceptHeader) { + if (acceptHeader == null) { + return TextFormat.CONTENT_TYPE_OPENMETRICS_100; + } + if (acceptHeader.startsWith("text/plain")) { + return TextFormat.CONTENT_TYPE_004; + } + return TextFormat.CONTENT_TYPE_OPENMETRICS_100; + } + + private void doHandle(HttpServerResponse response, String acceptHeader) { + response.putHeader("Content-Type", acceptHeader) + .end(Buffer.buffer(registry.scrape(acceptHeader))); } private void setup() { diff --git a/integration-tests/micrometer-prometheus/src/test/java/io/quarkus/it/micrometer/prometheus/PrometheusMetricsRegistryTest.java b/integration-tests/micrometer-prometheus/src/test/java/io/quarkus/it/micrometer/prometheus/PrometheusMetricsRegistryTest.java index 944c7ab8dce..ce9ceef711f 100644 --- a/integration-tests/micrometer-prometheus/src/test/java/io/quarkus/it/micrometer/prometheus/PrometheusMetricsRegistryTest.java +++ b/integration-tests/micrometer-prometheus/src/test/java/io/quarkus/it/micrometer/prometheus/PrometheusMetricsRegistryTest.java @@ -9,7 +9,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; +import io.prometheus.client.exporter.common.TextFormat; import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; /** * Test functioning prometheus endpoint. @@ -86,8 +88,102 @@ void testTemplatedPathOnClass() { @Test @Order(10) - void testPrometheusScrapeEndpoint() { - when().get("/q/metrics").then().statusCode(200) + void testPrometheusScrapeEndpointTextPlain() { + RestAssured.given().header("Accept", TextFormat.CONTENT_TYPE_004) + .when().get("/q/metrics") + .then().statusCode(200) + + // Prometheus body has ALL THE THINGS in no particular order + + .body(containsString("registry=\\"prometheus\\"")) + .body(containsString("env=\\"test\\"")) + .body(containsString("http_server_requests")) + + .body(containsString("status=\\"404\\"")) + .body(containsString("uri=\\"NOT_FOUND\\"")) + .body(containsString("outcome=\\"CLIENT_ERROR\\"")) + + .body(containsString("status=\\"500\\"")) + .body(containsString("uri=\\"/message/fail\\"")) + .body(containsString("outcome=\\"SERVER_ERROR\\"")) + + .body(containsString("status=\\"200\\"")) + .body(containsString("uri=\\"/message\\"")) + .body(containsString("uri=\\"/message/item/{id}\\"")) + .body(containsString("outcome=\\"SUCCESS\\"")) + .body(containsString("uri=\\"/message/match/{id}/{sub}\\"")) + .body(containsString("uri=\\"/message/match/{other}\\"")) + + .body(containsString( + "http_server_requests_seconds_count{env=\\"test\\",method=\\"GET\\",outcome=\\"SUCCESS\\",registry=\\"prometheus\\",status=\\"200\\",uri=\\"/template/path/{value}\\"")) + + // Verify Hibernate Metrics + .body(containsString( + "hibernate_sessions_open_total{entityManagerFactory=\\"<default>\\",env=\\"test\\",registry=\\"prometheus\\",} 2.0")) + .body(containsString( + "hibernate_sessions_closed_total{entityManagerFactory=\\"<default>\\",env=\\"test\\",registry=\\"prometheus\\",} 2.0")) + .body(containsString( + "hibernate_connections_obtained_total{entityManagerFactory=\\"<default>\\",env=\\"test\\",registry=\\"prometheus\\",}")) + .body(containsString( + "hibernate_entities_inserts_total{entityManagerFactory=\\"<default>\\",env=\\"test\\",registry=\\"prometheus\\",} 3.0")) + .body(containsString( + "hibernate_flushes_total{entityManagerFactory=\\"<default>\\",env=\\"test\\",registry=\\"prometheus\\",} 1.0")) + + // Annotated counters + .body(not(containsString("metric_none"))) + .body(containsString( + "metric_all_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",extra=\\"tag\\",method=\\"countAllInvocations\\",registry=\\"prometheus\\",result=\\"success\\",} 1.0")) + .body(containsString( + "metric_all_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",extra=\\"tag\\",method=\\"countAllInvocations\\",registry=\\"prometheus\\",result=\\"failure\\",} 1.0")) + .body(containsString( + "method_counted_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",method=\\"emptyMetricName\\",registry=\\"prometheus\\",result=\\"failure\\",} 1.0")) + .body(containsString( + "method_counted_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",method=\\"emptyMetricName\\",registry=\\"prometheus\\",result=\\"success\\",} 1.0")) + .body(not(containsString("async_none"))) + .body(containsString( + "async_all_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",extra=\\"tag\\",method=\\"countAllAsyncInvocations\\",registry=\\"prometheus\\",result=\\"failure\\",} 1.0")) + .body(containsString( + "async_all_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",extra=\\"tag\\",method=\\"countAllAsyncInvocations\\",registry=\\"prometheus\\",result=\\"success\\",} 1.0")) + .body(containsString( + "method_counted_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",method=\\"emptyAsyncMetricName\\",registry=\\"prometheus\\",result=\\"failure\\",} 1.0")) + .body(containsString( + "method_counted_total{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",method=\\"emptyAsyncMetricName\\",registry=\\"prometheus\\",result=\\"success\\",} 1.0")) + + // Annotated Timers + .body(containsString( + "call_seconds_count{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",extra=\\"tag\\",method=\\"call\\",registry=\\"prometheus\\",} 1.0")) + .body(containsString( + "call_seconds_count{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",extra=\\"tag\\",method=\\"call\\",registry=\\"prometheus\\",}")) + .body(containsString( + "async_call_seconds_count{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"NullPointerException\\",extra=\\"tag\\",method=\\"asyncCall\\",registry=\\"prometheus\\",} 1.0")) + .body(containsString( + "async_call_seconds_count{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",exception=\\"none\\",extra=\\"tag\\",method=\\"asyncCall\\",registry=\\"prometheus\\",} 1.0")) + .body(containsString( + "longCall_seconds_active_count{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",extra=\\"tag\\",method=\\"longCall\\",registry=\\"prometheus\\",}")) + .body(containsString( + "async_longCall_seconds_duration_sum{class=\\"io.quarkus.it.micrometer.prometheus.AnnotatedResource\\",env=\\"test\\",extra=\\"tag\\",method=\\"longAsyncCall\\",registry=\\"prometheus\\",} 0.0")) + + // Configured median, 95th percentile and histogram buckets + .body(containsString( + "prime_number_test_seconds{env=\\"test\\",registry=\\"prometheus\\",quantile=\\"0.5\\",}")) + .body(containsString( + "prime_number_test_seconds{env=\\"test\\",registry=\\"prometheus\\",quantile=\\"0.95\\",}")) + .body(containsString( + "prime_number_test_seconds_bucket{env=\\"test\\",registry=\\"prometheus\\",le=\\"0.001\\",}")) + + // this was defined by a tag to a non-matching registry, and should not be found + .body(not(containsString("class-should-not-match"))) + + // should not find this ignored uri + .body(not(containsString("uri=\\"/fruit/create\\""))); + } + + @Test + @Order(11) + void testPrometheusScrapeEndpointOpenMetrics() { + RestAssured.given().header("Accept", TextFormat.CONTENT_TYPE_OPENMETRICS_100) + .when().get("/q/metrics") + .then().statusCode(200) // Prometheus body has ALL THE THINGS in no particular order
['extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/PrometheusRecorder.java', 'extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/handlers/PrometheusHandler.java', 'integration-tests/micrometer-prometheus/src/test/java/io/quarkus/it/micrometer/prometheus/PrometheusMetricsRegistryTest.java', 'extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/export/JsonRecorder.java']
{'.java': 4}
4
4
0
0
4
24,446,040
4,813,201
623,308
5,708
1,337
252
25
3
1,861
179
545
50
3
0
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,275
quarkusio/quarkus/30574/30423
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30423
https://github.com/quarkusio/quarkus/pull/30574
https://github.com/quarkusio/quarkus/pull/30574
1
close
2.15+ - Services dependent on libraries without classes no longer build
### Describe the bug When trying to upgrade to Quarkus `2.15` or higher (tested with `2.15.0.Final`, `2.15.3.Final`, `2.16.0.CR1`), libraries that don't contain classes that are included as a dependency in a Quarkus project no longer can be built because `The project does not contain a class output directory. .../build/classes must exist.`. In the example provided in the reproducer, the library `lib2` contains `src/main/resources` but no Java classes (i.e. `src/main/java`). The Quarkus service `service4` pulls in `lib2` as a dependency. The build for `service4` fails because `lib2` does not have `build/classes`. ### Expected behavior Successful build ### Actual behavior ``` org.gradle.api.GradleException: The project does not contain a class output directory. quarkus-test\\common\\subprojects\\lib2\\build\\classes must exist. at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.addSubstitutedProject(GradleApplicationModelBuilder.java:552) at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.collectDependencies(GradleApplicationModelBuilder.java:305) at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.lambda$collectDependencies$0(GradleApplicationModelBuilder.java:218) at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.collectDependencies(GradleApplicationModelBuilder.java:217) at io.quarkus.gradle.tooling.GradleApplicationModelBuilder.buildAll(GradleApplicationModelBuilder.java:117) at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:74) at io.quarkus.gradle.tooling.ToolingUtils.create(ToolingUtils.java:70) at io.quarkus.gradle.extension.QuarkusPluginExtension.getApplicationModel(QuarkusPluginExtension.java:135) at io.quarkus.gradle.tasks.QuarkusGenerateCode.prepareQuarkus(QuarkusGenerateCode.java:95) ``` ### How to Reproduce? Reproducer: 1. Clone https://github.com/mikethecalamity/quarkus-test 2. `./gradlew -p apps service4:build` Note that the project `lib2` only contains `src/main/resources` so it should not have `build/classes`. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 17.0.5 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.15.3.Final / 2.16.0.CR1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.5.1 ### Additional information _No response_
3affaf27b831ff3f6d4e1e6e018b6aa9979afc82
e5e35d918ae183590d807c67620f1f99bfa0b75a
https://github.com/quarkusio/quarkus/compare/3affaf27b831ff3f6d4e1e6e018b6aa9979afc82...e5e35d918ae183590d807c67620f1f99bfa0b75a
diff --git a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java index fea4982a425..0344dda228d 100644 --- a/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java +++ b/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java @@ -18,7 +18,6 @@ import java.util.Properties; import java.util.Set; -import org.gradle.api.GradleException; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ResolvedArtifact; @@ -570,15 +569,13 @@ private void addSubstitutedProject(PathList.Builder paths, File projectFile) { } File classesOutput = new File(projectFile, CLASSES_OUTPUT); File[] languageDirectories = classesOutput.listFiles(); - if (languageDirectories == null) { - throw new GradleException( - "The project does not contain a class output directory. " + classesOutput.getPath() + " must exist."); - } - for (File languageDirectory : languageDirectories) { - if (languageDirectory.isDirectory()) { - for (File sourceSet : languageDirectory.listFiles()) { - if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) { - paths.add(sourceSet.toPath()); + if (languageDirectories != null) { + for (File languageDirectory : languageDirectories) { + if (languageDirectory.isDirectory()) { + for (File sourceSet : languageDirectory.listFiles()) { + if (sourceSet.isDirectory() && sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME)) { + paths.add(sourceSet.toPath()); + } } } }
['devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/GradleApplicationModelBuilder.java']
{'.java': 1}
1
1
0
0
1
24,440,020
4,812,068
623,199
5,708
1,061
181
17
1
2,441
209
628
57
1
1
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,276
quarkusio/quarkus/30569/30515
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30515
https://github.com/quarkusio/quarkus/pull/30569
https://github.com/quarkusio/quarkus/pull/30569
1
fix
Native build fails with hibernate-orm-rest-data-panache + elytron-security-properties-file
### Describe the bug Combination of `hibernate-orm-rest-data-panache` and `elytron-security-properties-file`, together with a panache resource with a class annotation from `javax.annotation.security` cause native build to fail. ```java package org.acme; import io.quarkus.hibernate.orm.rest.data.panache.PanacheEntityResource; import javax.annotation.security.DenyAll; @DenyAll public interface MyResource extends PanacheEntityResource<MyEntity, Long> { } ``` This can be reproduced for any Quarkus newer than `2.14.3.Final`. ### Expected behavior Native build succeeds. ### Actual behavior ``` Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1() Parsing context: at org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1(Unknown Source) at org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass$$function$$12.apply(Unknown Source) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1932) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at java.lang.reflect.Executable.sharedToString(Executable.java:122) at java.lang.reflect.Constructor.toString(Constructor.java:358) at java.lang.String.valueOf(String.java:4225) at com.oracle.svm.core.jdk.localization.substitutions.Target_java_util_Locale.initDefault(Target_java_util_Locale.java:52) at java.util.Locale.getDisplayLocale(Locale.java:1039) at java.util.Locale.getDefault(Locale.java:1023) at java.util.Formatter.<init>(Formatter.java:2095) at java.lang.String.format(String.java:4150) at jdk.internal.util.Preconditions.outOfBoundsMessage(Preconditions.java:245) at jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) at java.lang.String.checkIndex(String.java:4570) ... Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3.count(). This error is reported at image build time because class org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass is registered for linking at image build time by command line at parsing org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1(Unknown Source) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2518) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:110) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3393) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3345) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3190) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1138) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1030) at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:84) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:446) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:135) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:685) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:171) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:349) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:93) ``` ### How to Reproduce? ``` git clone git@github.com:jsmrcka/orm-rest-data-panache-security-native-reproducer.git mvn -f ./orm-rest-data-panache-security-native-reproducer clean package -Dnative ``` ### Output of `uname -a` or `ver` Linux ... 6.0.15-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 21 18:33:23 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.12" 2021-07-20 ### GraalVM version (if different from Java) GraalVM 22.3.0 Java 19 CE (Java Version 19.0.1+10-jvmci-22.3-b08) ### Quarkus version or git rev 2.15.0.CR1+, 999-SNAPSHOT ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) 3.8.6 ### Additional information _No response_
d27d5357f33ce8c0c6a8113c0822eddfe6d2677e
fa39b9ab49f1c9bf7ed5feb3b3ed1d025572eda8
https://github.com/quarkusio/quarkus/compare/d27d5357f33ce8c0c6a8113c0822eddfe6d2677e...fa39b9ab49f1c9bf7ed5feb3b3ed1d025572eda8
diff --git a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java index dc6ef6f5d2e..7ce9d26ea47 100644 --- a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java +++ b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java @@ -26,12 +26,16 @@ * @param sort Panache sort instance that should be used in a query. * @return A response with an entities JSON array. */ - Uni<List<Entity>> list(Page page, Sort sort); + default Uni<List<Entity>> list(Page page, Sort sort) { + throw new RuntimeException("Not implemented yet"); + } /** * @return the total number of entities. */ - Uni<Long> count(); + default Uni<Long> count() { + throw new RuntimeException("Not implemented yet"); + } /** * Return an entity as a JSON object. @@ -40,7 +44,9 @@ * @param id Entity identifier. * @return A response with a JSON object representing an entity. */ - Uni<Entity> get(ID id); + default Uni<Entity> get(ID id) { + throw new RuntimeException("Not implemented yet"); + } /** * Create a new entity from the provided JSON object. @@ -50,7 +56,9 @@ * @param entity Entity to be created * @return A response with a JSON object representing an entity and a location header of the new entity. */ - Uni<Entity> add(Entity entity); + default Uni<Entity> add(Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Update an existing entity or create a new one from the provided JSON object. @@ -62,7 +70,9 @@ * @return A response with no-content status in case of the update. * A response with a JSON object representing an entity and a location header in case of the create. */ - Uni<Entity> update(ID id, Entity entity); + default Uni<Entity> update(ID id, Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Delete an entity. @@ -70,5 +80,7 @@ * @param id Entity identifier. * @return A boolean indicated whether the entity was deleted or not. */ - Uni<Boolean> delete(ID id); + default Uni<Boolean> delete(ID id) { + throw new RuntimeException("Not implemented yet"); + } } diff --git a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java index 2d86466166f..fe664c74700 100644 --- a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java +++ b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java @@ -25,12 +25,16 @@ * @param sort Panache sort instance that should be used in a query. * @return A response with an entities JSON array. */ - List<Entity> list(Page page, Sort sort); + default List<Entity> list(Page page, Sort sort) { + throw new RuntimeException("Not implemented yet"); + } /** * @return the total number of entities. */ - long count(); + default long count() { + throw new RuntimeException("Not implemented yet"); + } /** * Return an entity as a JSON object. @@ -39,7 +43,9 @@ * @param id Entity identifier. * @return A response with a JSON object representing an entity. */ - Entity get(ID id); + default Entity get(ID id) { + throw new RuntimeException("Not implemented yet"); + } /** * Create a new entity from the provided JSON object. @@ -49,7 +55,9 @@ * @param entity Entity to be created * @return A response with a JSON object representing an entity and a location header of the new entity. */ - Entity add(Entity entity); + default Entity add(Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Update an existing entity or create a new one from the provided JSON object. @@ -61,7 +69,9 @@ * @return A response with no-content status in case of the update. * A response with a JSON object representing an entity and a location header in case of the create. */ - Entity update(ID id, Entity entity); + default Entity update(ID id, Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Delete an entity. @@ -69,5 +79,7 @@ * @param id Entity identifier. * @return A boolean indicated whether the entity was deleted or not. */ - boolean delete(ID id); + default boolean delete(ID id) { + throw new RuntimeException("Not implemented yet"); + } }
['extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java', 'extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java']
{'.java': 2}
2
2
0
0
2
24,434,172
4,811,043
623,088
5,708
1,734
346
48
2
6,335
289
1,604
109
0
3
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,277
quarkusio/quarkus/30557/30354
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30354
https://github.com/quarkusio/quarkus/pull/30557
https://github.com/quarkusio/quarkus/pull/30557
1
fixes
AWT `io.quarkus.awt.it.ImageGeometryFontsIT` native integration test failing with "GraalVM for Java 20" dev builds
### Describe the bug $title cc @Karm ### Expected behavior Tests should pass. ### Actual behavior Test fails with: ``` [ERROR] Failures: [ERROR] ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 TIFF: Wrong pixel at 80x56. Expected: [46,14,32,255] Actual: [194,59,132,255] ==> expected: <true> but was: <false> [ERROR] ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 GIF: Wrong pixel at 80x56. Expected: [2,0,0,0] Actual: [156,0,0,0] ==> expected: <true> but was: <false> [ERROR] ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 PNG: Wrong pixel at 80x56. Expected: [46,14,32,255] Actual: [194,59,132,255] ==> expected: <true> but was: <false> [ERROR] ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 JPG: Wrong pixel at 80x56. Expected: [73,0,44,0] Actual: [201,53,137,0] ==> expected: <true> but was: <false> [ERROR] ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 BMP: Wrong pixel at 80x56. Expected: [46,14,32,0] Actual: [194,59,132,0] ==> expected: <true> but was: <false> ``` See https://github.com/oracle/graal/actions/runs/3898752856/jobs/6658142635#step:9:487 ### How to Reproduce? 1. Build GraalVM `master` using Java 20 EA 2. Set GRAALVM_HOME to `<graalvm-repo>/sdk/latest_graalvm_home` 3. ./mvnw -Dnative -pl integration-tests/awt -Dnative.surefire.skip -Dformat.skip -Dno-descriptor-tests -Dlog.level=ALL clean verify -Dquarkus.native.container-build=false ### Output of `uname -a` or `ver` Linux 6.0.17-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 4 15:58:35 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) GraalVM for Java 20 - dev build based on 92cfa766d1f059561e6c6a5631d6b082fc9f7765 ### Quarkus version or git rev f1be907e9994569e1e321ebda596bf3e49ac4900 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
5fcac567b376117be631476ea14d488870d94911
26d25fcc363d3779e0eb8fdef0dd9582047506f4
https://github.com/quarkusio/quarkus/compare/5fcac567b376117be631476ea14d488870d94911...26d25fcc363d3779e0eb8fdef0dd9582047506f4
diff --git a/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java b/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java index da13c2ea177..0cb63f461a1 100644 --- a/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java +++ b/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java @@ -143,6 +143,8 @@ JniRuntimeAccessBuildItem setupJava2DClasses() { "sun.font.FontConfigManager", "sun.font.FontManagerNativeLibrary", "sun.font.FontStrike", + // Added for JDK 19+ due to: https://github.com/openjdk/jdk20/commit/9bc023220 calling FontUtilities + "sun.font.FontUtilities", "sun.font.FreetypeFontScaler", "sun.font.GlyphLayout", "sun.font.GlyphLayout$EngineRecord",
['extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java']
{'.java': 1}
1
1
0
0
1
24,405,917
4,805,537
622,297
5,706
160
38
2
1
2,066
210
671
54
1
1
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,278
quarkusio/quarkus/30544/30540
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30540
https://github.com/quarkusio/quarkus/pull/30544
https://github.com/quarkusio/quarkus/pull/30544
1
fixes
Build failed due to limit bean types to types outside of the transitive closure of bean types
### Describe the bug Our Quarkus QE project does not compile when run against `999-SNAPSHOT`. It must be some recent change as it was fine last week. caused by https://github.com/quarkusio/quarkus/pull/30447 ### Expected behavior Build succeeds. ### Actual behavior Build failes with ```bash [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (build) on project http-advanced-reactive: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#registerBeans threw an exception: javax.enterprise.inject.spi.DefinitionException: Cannot limit bean types to types outside of the transitive closure of bean types. Bean: org.jboss.resteasy.plugins.providers.multipart.MapMultipartFormDataReader illegal bean types: [javax.ws.rs.ext.MessageBodyReader] [ERROR] at io.quarkus.arc.processor.Types.restrictBeanTypes(Types.java:644) [ERROR] at io.quarkus.arc.processor.Types.getClassBeanTypeClosure(Types.java:403) [ERROR] at io.quarkus.arc.processor.Beans$ClassBeanFactory.create(Beans.java:1121) [ERROR] at io.quarkus.arc.processor.Beans.createClassBean(Beans.java:49) [ERROR] at io.quarkus.arc.processor.BeanDeployment.findBeans(BeanDeployment.java:1034) [ERROR] at io.quarkus.arc.processor.BeanDeployment.registerBeans(BeanDeployment.java:256) [ERROR] at io.quarkus.arc.processor.BeanProcessor.registerBeans(BeanProcessor.java:134) [ERROR] at io.quarkus.arc.deployment.ArcProcessor.registerBeans(ArcProcessor.java:444) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:568) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:281) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [ERROR] at java.base/java.lang.Thread.run(Thread.java:833) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :http-advanced-reactive ``` ### How to Reproduce? Reproducer: Steps to reproduce teh behavior: 1. `git clone https://github.com/quarkus-qe/quarkus-test-suite.git` 2. `mvn -T C1 -DskipDocs -DskipTests -DskipITs -DskipExtensionValidation -Dskip.gradle.tests -Dcheckstyle.skip clean install` ### Output of `uname -a` or `ver` Linux fedora 6.1.5-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 12 15:52:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "17.0.5" 2022-10-18 ### GraalVM version (if different from Java) 22.3 ### Quarkus version or git rev 999-SNAPSHOT ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) ### Additional information _No response_
cd3bb034834489e2675a4fad58ba670497727f9a
7b70ded73f5729b840074bbafa40948e9df42f74
https://github.com/quarkusio/quarkus/compare/cd3bb034834489e2675a4fad58ba670497727f9a...7b70ded73f5729b840074bbafa40948e9df42f74
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java index ce05ad8207a..f6a97250338 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java @@ -331,6 +331,7 @@ static Type getProviderType(ClassInfo classInfo) { static Set<Type> getProducerMethodTypeClosure(MethodInfo producerMethod, BeanDeployment beanDeployment) { Set<Type> types; + Set<Type> unrestrictedBeanTypes = new HashSet<>(); Type returnType = producerMethod.returnType(); if (returnType.kind() == Kind.TYPE_VARIABLE) { throw new DefinitionException("A type variable is not a legal bean type: " + producerMethod); @@ -347,22 +348,25 @@ static Set<Type> getProducerMethodTypeClosure(MethodInfo producerMethod, BeanDep "Producer method return type not found in index: " + producerMethod.returnType().name()); } if (Kind.CLASS.equals(returnType.kind())) { - types = getTypeClosure(returnTypeClassInfo, producerMethod, Collections.emptyMap(), beanDeployment, null); + types = getTypeClosure(returnTypeClassInfo, producerMethod, Collections.emptyMap(), beanDeployment, null, + unrestrictedBeanTypes); } else if (Kind.PARAMETERIZED_TYPE.equals(returnType.kind())) { types = getTypeClosure(returnTypeClassInfo, producerMethod, buildResolvedMap(returnType.asParameterizedType().arguments(), returnTypeClassInfo.typeParameters(), Collections.emptyMap(), beanDeployment.getBeanArchiveIndex()), - beanDeployment, null); + beanDeployment, null, unrestrictedBeanTypes); } else { throw new IllegalArgumentException("Unsupported return type"); } } - return restrictBeanTypes(types, beanDeployment.getAnnotations(producerMethod), beanDeployment.getBeanArchiveIndex(), + return restrictBeanTypes(types, unrestrictedBeanTypes, beanDeployment.getAnnotations(producerMethod), + beanDeployment.getBeanArchiveIndex(), producerMethod); } static Set<Type> getProducerFieldTypeClosure(FieldInfo producerField, BeanDeployment beanDeployment) { Set<Type> types; + Set<Type> unrestrictedBeanTypes = new HashSet<>(); Type fieldType = producerField.type(); if (fieldType.kind() == Kind.TYPE_VARIABLE) { throw new DefinitionException("A type variable is not a legal bean type: " + producerField); @@ -377,30 +381,34 @@ static Set<Type> getProducerFieldTypeClosure(FieldInfo producerField, BeanDeploy throw new IllegalArgumentException("Producer field type not found in index: " + producerField.type().name()); } if (Kind.CLASS.equals(fieldType.kind())) { - types = getTypeClosure(fieldClassInfo, producerField, Collections.emptyMap(), beanDeployment, null); + types = getTypeClosure(fieldClassInfo, producerField, Collections.emptyMap(), beanDeployment, null, + unrestrictedBeanTypes); } else if (Kind.PARAMETERIZED_TYPE.equals(fieldType.kind())) { types = getTypeClosure(fieldClassInfo, producerField, buildResolvedMap(fieldType.asParameterizedType().arguments(), fieldClassInfo.typeParameters(), Collections.emptyMap(), beanDeployment.getBeanArchiveIndex()), - beanDeployment, null); + beanDeployment, null, unrestrictedBeanTypes); } else { throw new IllegalArgumentException("Unsupported return type"); } } - return restrictBeanTypes(types, beanDeployment.getAnnotations(producerField), beanDeployment.getBeanArchiveIndex(), + return restrictBeanTypes(types, unrestrictedBeanTypes, beanDeployment.getAnnotations(producerField), + beanDeployment.getBeanArchiveIndex(), producerField); } static Set<Type> getClassBeanTypeClosure(ClassInfo classInfo, BeanDeployment beanDeployment) { Set<Type> types; + Set<Type> unrestrictedBeanTypes = new HashSet<>(); List<TypeVariable> typeParameters = classInfo.typeParameters(); if (typeParameters.isEmpty()) { - types = getTypeClosure(classInfo, null, Collections.emptyMap(), beanDeployment, null); + types = getTypeClosure(classInfo, null, Collections.emptyMap(), beanDeployment, null, unrestrictedBeanTypes); } else { types = getTypeClosure(classInfo, null, buildResolvedMap(typeParameters, typeParameters, - Collections.emptyMap(), beanDeployment.getBeanArchiveIndex()), beanDeployment, null); + Collections.emptyMap(), beanDeployment.getBeanArchiveIndex()), beanDeployment, null, unrestrictedBeanTypes); } - return restrictBeanTypes(types, beanDeployment.getAnnotations(classInfo), beanDeployment.getBeanArchiveIndex(), + return restrictBeanTypes(types, unrestrictedBeanTypes, beanDeployment.getAnnotations(classInfo), + beanDeployment.getBeanArchiveIndex(), classInfo); } @@ -485,9 +493,13 @@ static boolean containsWildcard(Type type, AnnotationTarget producerFieldOrMetho return true; } } else if (type.kind().equals(Kind.PARAMETERIZED_TYPE)) { + boolean wildcardFound = false; for (Type t : type.asParameterizedType().arguments()) { // recursive check of all parameterized types - return containsWildcard(t, producerFieldOrMethod, throwIfDetected); + wildcardFound = containsWildcard(t, producerFieldOrMethod, throwIfDetected); + if (wildcardFound) { + return true; + } } } return false; @@ -496,7 +508,8 @@ static boolean containsWildcard(Type type, AnnotationTarget producerFieldOrMetho private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget producerFieldOrMethod, boolean throwOnProducerWildcard, Map<String, Type> resolvedTypeParameters, - BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer) { + BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer, + Set<Type> unrestrictedBeanTypes) { Set<Type> types = new HashSet<>(); List<TypeVariable> typeParameters = classInfo.typeParameters(); @@ -524,6 +537,8 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr } if (!skipThisType) { types.add(ParameterizedType.create(classInfo.name(), typeParams, null)); + } else { + unrestrictedBeanTypes.add(ParameterizedType.create(classInfo.name(), typeParams, null)); } } // Interfaces @@ -539,7 +554,7 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr interfaceClassInfo.typeParameters(), resolvedTypeParameters, beanDeployment.getBeanArchiveIndex()); } types.addAll(getTypeClosure(interfaceClassInfo, producerFieldOrMethod, false, resolved, beanDeployment, - resolvedTypeVariablesConsumer)); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes)); } } // Superclass @@ -553,21 +568,24 @@ private static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget pr resolvedTypeParameters, beanDeployment.getBeanArchiveIndex()); } types.addAll(getTypeClosure(superClassInfo, producerFieldOrMethod, false, resolved, beanDeployment, - resolvedTypeVariablesConsumer)); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes)); } } + unrestrictedBeanTypes.addAll(types); return types; } static Set<Type> getTypeClosure(ClassInfo classInfo, AnnotationTarget producerFieldOrMethod, Map<String, Type> resolvedTypeParameters, - BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer) { + BeanDeployment beanDeployment, BiConsumer<ClassInfo, Map<String, Type>> resolvedTypeVariablesConsumer, + Set<Type> unrestrictedBeanTypes) { return getTypeClosure(classInfo, producerFieldOrMethod, true, resolvedTypeParameters, beanDeployment, - resolvedTypeVariablesConsumer); + resolvedTypeVariablesConsumer, unrestrictedBeanTypes); } static Set<Type> getDelegateTypeClosure(InjectionPointInfo delegateInjectionPoint, BeanDeployment beanDeployment) { Set<Type> types; + Set<Type> unrestrictedBeanTypes = new HashSet<>(); Type delegateType = delegateInjectionPoint.getRequiredType(); if (delegateType.kind() == Kind.TYPE_VARIABLE || delegateType.kind() == Kind.PRIMITIVE @@ -580,12 +598,12 @@ static Set<Type> getDelegateTypeClosure(InjectionPointInfo delegateInjectionPoin } if (Kind.CLASS.equals(delegateType.kind())) { types = getTypeClosure(delegateTypeClass, delegateInjectionPoint.getTarget(), Collections.emptyMap(), - beanDeployment, null); + beanDeployment, null, unrestrictedBeanTypes); } else if (Kind.PARAMETERIZED_TYPE.equals(delegateType.kind())) { types = getTypeClosure(delegateTypeClass, delegateInjectionPoint.getTarget(), buildResolvedMap(delegateType.asParameterizedType().arguments(), delegateTypeClass.typeParameters(), Collections.emptyMap(), beanDeployment.getBeanArchiveIndex()), - beanDeployment, null); + beanDeployment, null, unrestrictedBeanTypes); } else { throw new IllegalArgumentException("Unsupported return type"); } @@ -595,11 +613,12 @@ static Set<Type> getDelegateTypeClosure(InjectionPointInfo delegateInjectionPoin static Map<ClassInfo, Map<String, Type>> resolvedTypeVariables(ClassInfo classInfo, BeanDeployment beanDeployment) { Map<ClassInfo, Map<String, Type>> resolvedTypeVariables = new HashMap<>(); - getTypeClosure(classInfo, null, Collections.emptyMap(), beanDeployment, resolvedTypeVariables::put); + getTypeClosure(classInfo, null, Collections.emptyMap(), beanDeployment, resolvedTypeVariables::put, new HashSet<>()); return resolvedTypeVariables; } - static Set<Type> restrictBeanTypes(Set<Type> types, Collection<AnnotationInstance> annotations, IndexView index, + static Set<Type> restrictBeanTypes(Set<Type> types, Set<Type> unrestrictedBeanTypes, + Collection<AnnotationInstance> annotations, IndexView index, AnnotationTarget target) { AnnotationInstance typed = null; for (AnnotationInstance a : annotations) { @@ -621,12 +640,20 @@ static Set<Type> restrictBeanTypes(Set<Type> types, Collection<AnnotationInstanc } } } + // check if all classes declared in @Typed match some class in the unrestricted bean type set + for (DotName typeName : typedClasses) { + if (!unrestrictedBeanTypes.stream().anyMatch(type -> type.name().equals(typeName))) { + throw new DefinitionException( + "Cannot limit bean types to types outside of the transitive closure of bean types. Bean: " + target + + " illegal bean types: " + typedClasses); + } + } for (Iterator<Type> it = types.iterator(); it.hasNext();) { Type next = it.next(); if (DotNames.OBJECT.equals(next.name())) { continue; } - if (typed != null && !typedClasses.remove(next.name())) { + if (typed != null && !typedClasses.contains(next.name())) { it.remove(); continue; } @@ -639,12 +666,6 @@ static Set<Type> restrictBeanTypes(Set<Type> types, Collection<AnnotationInstanc } } } - // if the set of types we gathered from @Typed annotation isn't now empty, there are some illegal types in it - if (!typedClasses.isEmpty()) { - throw new DefinitionException( - "Cannot limit bean types to types outside of the transitive closure of bean types. Bean: " + target - + " illegal bean types: " + typedClasses); - } return types; } diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java index dc2535c0755..86ddf65858e 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java @@ -10,6 +10,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -42,7 +43,7 @@ public void testGetTypeClosure() throws IOException { Set<Type> bazTypes = Types.getTypeClosure(index.getClassByName(bazName), null, Collections.emptyMap(), dummyDeployment, - resolvedTypeVariables::put); + resolvedTypeVariables::put, new HashSet<>()); assertEquals(3, bazTypes.size()); assertTrue(bazTypes.contains(Type.create(bazName, Kind.CLASS))); assertTrue(bazTypes.contains(ParameterizedType.create(fooName,
['independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Types.java', 'independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java']
{'.java': 2}
2
2
0
0
2
24,404,941
4,805,329
622,274
5,706
5,650
965
73
1
3,899
318
1,041
80
3
1
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,279
quarkusio/quarkus/30530/30515
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30515
https://github.com/quarkusio/quarkus/pull/30530
https://github.com/quarkusio/quarkus/pull/30530
1
fix
Native build fails with hibernate-orm-rest-data-panache + elytron-security-properties-file
### Describe the bug Combination of `hibernate-orm-rest-data-panache` and `elytron-security-properties-file`, together with a panache resource with a class annotation from `javax.annotation.security` cause native build to fail. ```java package org.acme; import io.quarkus.hibernate.orm.rest.data.panache.PanacheEntityResource; import javax.annotation.security.DenyAll; @DenyAll public interface MyResource extends PanacheEntityResource<MyEntity, Long> { } ``` This can be reproduced for any Quarkus newer than `2.14.3.Final`. ### Expected behavior Native build succeeds. ### Actual behavior ``` Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1() Parsing context: at org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1(Unknown Source) at org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass$$function$$12.apply(Unknown Source) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1932) at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at java.lang.reflect.Executable.sharedToString(Executable.java:122) at java.lang.reflect.Constructor.toString(Constructor.java:358) at java.lang.String.valueOf(String.java:4225) at com.oracle.svm.core.jdk.localization.substitutions.Target_java_util_Locale.initDefault(Target_java_util_Locale.java:52) at java.util.Locale.getDisplayLocale(Locale.java:1039) at java.util.Locale.getDefault(Locale.java:1023) at java.util.Formatter.<init>(Formatter.java:2095) at java.lang.String.format(String.java:4150) at jdk.internal.util.Preconditions.outOfBoundsMessage(Preconditions.java:245) at jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) at java.lang.String.checkIndex(String.java:4570) ... Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3.count(). This error is reported at image build time because class org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass is registered for linking at image build time by command line at parsing org.acme.MyResourceJaxRs_ab15c77efe36959f9555ec5aecafdc237bba9ef3_Subclass.count$$superforward1(Unknown Source) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2518) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:110) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3393) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3345) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3190) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1138) at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1030) at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97) at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:84) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:446) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42) at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:135) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:685) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:171) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:349) at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:93) ``` ### How to Reproduce? ``` git clone git@github.com:jsmrcka/orm-rest-data-panache-security-native-reproducer.git mvn -f ./orm-rest-data-panache-security-native-reproducer clean package -Dnative ``` ### Output of `uname -a` or `ver` Linux ... 6.0.15-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 21 18:33:23 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.12" 2021-07-20 ### GraalVM version (if different from Java) GraalVM 22.3.0 Java 19 CE (Java Version 19.0.1+10-jvmci-22.3-b08) ### Quarkus version or git rev 2.15.0.CR1+, 999-SNAPSHOT ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) 3.8.6 ### Additional information _No response_
653954d73c3c44a952526f25c5d32e4cae020e9a
72b1a5e8fd271af0a65066659d5c2b060d61178a
https://github.com/quarkusio/quarkus/compare/653954d73c3c44a952526f25c5d32e4cae020e9a...72b1a5e8fd271af0a65066659d5c2b060d61178a
diff --git a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/methods/CountMethodImplementor.java b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/methods/CountMethodImplementor.java index efc45733a16..c3594cdc4c7 100644 --- a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/methods/CountMethodImplementor.java +++ b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/methods/CountMethodImplementor.java @@ -4,6 +4,7 @@ import static io.quarkus.rest.data.panache.deployment.utils.SignatureMethodCreator.ofType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import io.quarkus.deployment.Capabilities; import io.quarkus.gizmo.ClassCreator; @@ -41,9 +42,9 @@ public CountMethodImplementor(Capabilities capabilities) { * {@code * &#64;GET * &#64;Path("/count") - * public long count() { + * public Response count(UriInfo uriInfo) { * try { - * return resource.count(); + * return Response.ok(resource.count()); * } catch (Throwable t) { * throw new RestDataPanacheException(t); * } @@ -74,10 +75,13 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res ResourceProperties resourceProperties, FieldDescriptor resourceField) { // Method parameters: sort strings, page index, page size, uri info MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(RESOURCE_METHOD_NAME, classCreator, - isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, Long.class)); + isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, Long.class), + UriInfo.class); + methodCreator.setParameterNames(new String[] { "uriInfo" }); // Add method annotations addGetAnnotation(methodCreator); + addContextAnnotation(methodCreator.getParameterAnnotations(0)); addProducesAnnotation(methodCreator, APPLICATION_JSON); addPathAnnotation(methodCreator, appendToPath(resourceProperties.getPath(RESOURCE_METHOD_NAME), RESOURCE_METHOD_NAME)); addMethodAnnotations(methodCreator, resourceProperties.getMethodAnnotations(RESOURCE_METHOD_NAME));
['extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/methods/CountMethodImplementor.java']
{'.java': 1}
1
1
0
0
1
24,401,368
4,804,704
622,197
5,706
580
116
10
1
6,335
289
1,604
109
0
3
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,282
quarkusio/quarkus/30449/30417
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30417
https://github.com/quarkusio/quarkus/pull/30449
https://github.com/quarkusio/quarkus/pull/30449
1
fixes
Eventbus, No message codec for type when using headers
### Describe the bug When a event class is only consumed by `@ConsumeEvent` methods with signature ```java @ConsumeEvent(value = "address") public void listen(MultiMap headers, Body body) { ... } ``` no message codec is regisered for this class. Resulting in ```shell java.lang.IllegalArgumentException: No message codec for type: class org.acme.Hello at io.vertx.core.eventbus.impl.CodecManager.lookupCodec(CodecManager.java:119) at io.vertx.core.eventbus.impl.EventBusImpl.createMessage(EventBusImpl.java:254) at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:164) at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:159) at org.acme.GreetingResource.hello(GreetingResource.java:23) at org.acme.GreetingResource$quarkusrestinvoker$hello_e747664148511e1e5212d3e0f4b40d45c56ab8a1.invoke(Unknown Source) at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29) at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114) at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145) at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) ``` Adding another method without headers will register a codec. ### Expected behavior Message codecs are created on startup regardless of whether the event consumers include headers. ### Actual behavior No message codecs are created, resulting in ```shell java.lang.IllegalArgumentException: No message codec for type: class org.acme.Hello at io.vertx.core.eventbus.impl.CodecManager.lookupCodec(CodecManager.java:119) at io.vertx.core.eventbus.impl.EventBusImpl.createMessage(EventBusImpl.java:254) at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:164) at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:159) at org.acme.GreetingResource.hello(GreetingResource.java:23) at org.acme.GreetingResource$quarkusrestinvoker$hello_e747664148511e1e5212d3e0f4b40d45c56ab8a1.invoke(Unknown Source) at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29) at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114) at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145) at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) ``` ### How to Reproduce? https://github.com/computerlove/quarkus-evenbus-headers-reproducer Start with `mvn quarkus:dev` and GET http://localhost:8080/hello Exception will be printed in terminal. Commenting in the extra listener, `listenNoHeaders`, in `Listener.java` will result in the expected behaviour. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` java 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.15.3 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
b163409e24025eb963a4844373093a6528570e51
d5e05ee127a1148b3c5f47d1fca227b9a4e02602
https://github.com/quarkusio/quarkus/compare/b163409e24025eb963a4844373093a6528570e51...d5e05ee127a1148b3c5f47d1fca227b9a4e02602
diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java index 27ae071ec82..6cc48b1848f 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java @@ -168,7 +168,12 @@ private static Type extractPayloadTypeFromParameter(MethodInfo method) { if (parameters.isEmpty()) { return null; } - Type param = method.parameterType(0); + /* + * VertxProcessor.collectEventConsumers makes sure that only methods with either just the message object, + * or headers as first argument then message object are allowed. + */ + int messageIndex = parameters.size() == 1 ? 0 : 1; + Type param = method.parameterType(messageIndex); if (param.kind() == Type.Kind.CLASS) { return param; } else if (param.kind() == Type.Kind.PARAMETERIZED_TYPE) { diff --git a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/CodecRegistrationTest.java b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/CodecRegistrationTest.java index 58bfeb0b163..046e2468258 100644 --- a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/CodecRegistrationTest.java +++ b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/CodecRegistrationTest.java @@ -8,6 +8,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import javax.inject.Inject; @@ -18,6 +19,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.test.QuarkusUnitTest; +import io.vertx.core.MultiMap; import io.vertx.mutiny.core.Vertx; import io.vertx.mutiny.core.eventbus.Message; @@ -83,6 +85,8 @@ public void testWithPrimitiveTypesAndCompletionStage() { @Test public void testCodecRegistrationBasedOnParameterType() { + assertThat(bean.getSink().size()).isEqualTo(0); + String address = "address-5"; vertx.eventBus().send(address, new CustomType1("foo")); vertx.eventBus().send(address, new CustomType1("bar")); @@ -104,6 +108,20 @@ public void testCodecRegistrationBasedOnParameterType() { set = bean.getSink().stream().map(x -> (CustomType1) x).map(CustomType1::getName) .collect(Collectors.toSet()); assertThat(set).contains("foo-x", "bar-x", "baz-x"); + bean.getSink().clear(); + } + + @Test + public void testCodecRegistrationBasedOnHeadersAndParameterType() { + assertThat(bean.getSink().size()).isEqualTo(0); + + vertx.eventBus().send("address-9", new CustomType5("foo-x")); + + await().timeout(5, TimeUnit.SECONDS).until(() -> bean.getSink().size() == 1); + Set<String> set = bean.getSink().stream().map(x -> (CustomType5) x).map(CustomType5::getName) + .collect(Collectors.toSet()); + assertThat(set).contains("foo-x"); + bean.getSink().clear(); } @Test @@ -199,6 +217,11 @@ CompletionStage<CustomType4> codecRegistrationBasedReturnTypeAndCS(String n) { return CompletableFuture.completedFuture(new CustomType4(n)); } + @ConsumeEvent("address-9") + void codecRegistrationBasedOnHeadersParam(MultiMap headers, CustomType5 ct) { + sink.add(ct); + } + public List<Object> getSink() { return sink; } @@ -259,4 +282,16 @@ public String getName() { return name; } } + + static class CustomType5 { + private final String name; + + CustomType5(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } diff --git a/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusConsumer.java b/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusConsumer.java index 419edb41ee9..1cfb1af7920 100644 --- a/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusConsumer.java +++ b/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusConsumer.java @@ -3,6 +3,7 @@ import javax.enterprise.context.ApplicationScoped; import io.quarkus.vertx.ConsumeEvent; +import io.vertx.core.MultiMap; @ApplicationScoped public class EventBusConsumer { @@ -17,4 +18,10 @@ public String name(String name) { return "Hello " + name; } + @ConsumeEvent("person-headers") + public String personWithHeader(MultiMap headers, Person person) { + String s = "Hello " + person.getFirstName() + " " + person.getLastName() + ", " + headers; + return s; + } + } diff --git a/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusSender.java b/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusSender.java index d623a40c3bf..46b21d3df93 100644 --- a/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusSender.java +++ b/integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusSender.java @@ -3,8 +3,10 @@ import javax.inject.Inject; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.Produces; import io.smallrye.mutiny.Uni; +import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.core.json.JsonObject; import io.vertx.mutiny.core.eventbus.EventBus; import io.vertx.mutiny.core.eventbus.Message; @@ -22,6 +24,17 @@ public Uni<String> helloToPerson(JsonObject json) { .onItem().transform(Message::body); } + @POST + @Path("/person2") + @Produces("text/plain") + public Uni<String> helloToPersonWithHeaders(JsonObject json) { + return bus.<String> request( + "person-headers", + new Person(json.getString("firstName"), json.getString("lastName")), + new DeliveryOptions().addHeader("header", "headerValue")) + .onItem().transform(Message::body); + } + @POST @Path("/pet") public Uni<String> helloToPet(JsonObject json) { diff --git a/integration-tests/vertx/src/test/java/io/quarkus/it/vertx/EventBusTest.java b/integration-tests/vertx/src/test/java/io/quarkus/it/vertx/EventBusTest.java index 31ada479f39..be8f78e784d 100644 --- a/integration-tests/vertx/src/test/java/io/quarkus/it/vertx/EventBusTest.java +++ b/integration-tests/vertx/src/test/java/io/quarkus/it/vertx/EventBusTest.java @@ -20,6 +20,19 @@ public void testEventBusWithString() { .then().statusCode(200).body(equalTo("Hello Bob Morane")); } + @Test + public void testEventBusWithObjectAndHeader() { + String body = new JsonObject() + .put("firstName", "Bob") + .put("lastName", "Morane") + .toString(); + given().contentType(ContentType.JSON).body(body) + .post("/vertx-test/event-bus/person2") + .then().statusCode(200) + // For some reason Multimap.toString() has \\n at the end. + .body(equalTo("Hello Bob Morane, header=headerValue\\n")); + } + @Test public void testEventBusWithPet() { String body = new JsonObject().put("name", "Neo").put("kind", "rabbit").toString();
['integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusSender.java', 'integration-tests/vertx/src/main/java/io/quarkus/it/vertx/EventBusConsumer.java', 'integration-tests/vertx/src/test/java/io/quarkus/it/vertx/EventBusTest.java', 'extensions/vertx/deployment/src/test/java/io/quarkus/vertx/CodecRegistrationTest.java', 'extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java']
{'.java': 5}
5
5
0
0
5
24,374,562
4,799,848
621,604
5,698
378
77
7
1
4,276
244
1,050
89
2
3
1970-01-01T00:27:54
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,283
quarkusio/quarkus/30426/30424
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30424
https://github.com/quarkusio/quarkus/pull/30426
https://github.com/quarkusio/quarkus/pull/30426
1
fixes
Building of container images with buildx causes build failures
### Describe the bug As of 2.15.0.Final, building and pushing container images with buildx is causing build failures. The problem seems to be that Quarkus tries to push the container images from the host, although they've been built and pushed in buildx already. Because the images are not available in the host's local registry, the push attempt fails. Here's an example build log: ``` [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] Starting (local) container image build for jar using docker. [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] Executing the following command to build docker image: 'docker buildx build -f /REDACTED/bar/src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 -t host.docker.internal:5005/foo/bar:1.0.0-SNAPSHOT -t host.docker.internal:5005/foo/bar:latest --push /REDACTED/bar' [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #1 [internal] load build definition from Dockerfile.jvm [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #1 transferring dockerfile: 5.39kB done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #1 DONE 0.0s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #2 [internal] load .dockerignore [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #2 transferring context: 115B done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #2 DONE 0.0s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #3 [linux/amd64 internal] load metadata for registry.access.redhat.com/ubi8/openjdk-17-runtime:latest [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #3 ... [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #4 [linux/arm64 internal] load metadata for registry.access.redhat.com/ubi8/openjdk-17-runtime:latest [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #4 DONE 1.3s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #3 [linux/amd64 internal] load metadata for registry.access.redhat.com/ubi8/openjdk-17-runtime:latest [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #3 DONE 1.5s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #5 [linux/amd64 1/2] FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #5 resolve registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #5 DONE 0.0s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #6 [linux/arm64 1/2] FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #6 resolve registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a 0.0s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #6 DONE 0.0s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #7 [internal] load build context [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #7 transferring context: 116.88MB 2.5s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #7 DONE 2.5s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #6 [linux/arm64 1/2] FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #6 CACHED [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #5 [linux/amd64 1/2] FROM registry.access.redhat.com/ubi8/openjdk-17-runtime@sha256:9358f474bc99d4c65e1043990a0f8834aaa9974f27fe6c2ed88d6fa11a27a35a [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #5 CACHED [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #8 [linux/amd64 2/2] COPY --chown=185 target/*-runner.jar /deployments/quarkus-run.jar [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #8 DONE 0.5s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #9 [linux/arm64 2/2] COPY --chown=185 target/*-runner.jar /deployments/quarkus-run.jar [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #9 DONE 0.5s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting to image [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting layers [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting layers 2.4s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting manifest sha256:a8b3772b2612de447814116b0202a28c18f35e65a588c6be9e680eea56e5bafd done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting config sha256:64b8bc2007f1255ebe4d3358c372555da80fd3133d956ca91dce1396e77de2aa done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting attestation manifest sha256:6779238e09865c565980594ce834d228881125b837f4b9f5ba817752b77bc2cb done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting manifest sha256:548b8c98021bc178c0427a8ad3c03647813e64c87b7e39cccaf8c24fbfe3d581 done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting config sha256:489c7dbd39adefb3fe7b9c53040b94c22fdb60f05101491d8d33229d62f20332 [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting config sha256:489c7dbd39adefb3fe7b9c53040b94c22fdb60f05101491d8d33229d62f20332 done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting attestation manifest sha256:46a2550c0416c61875eb66cbc659b1559a73763275795fe276d74638b8937563 done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 exporting manifest list sha256:232246f8f7809e9d7bd57fbc03b53c60d92cb4bc85261b1838d06368f9571de6 done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 pushing layers [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 pushing layers 2.0s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 pushing manifest for host.docker.internal:5005/foo/bar:1.0.0-SNAPSHOT@sha256:232246f8f7809e9d7bd57fbc03b53c60d92cb4bc85261b1838d06368f9571de6 0.0s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 pushing layers 0.0s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 pushing manifest for host.docker.internal:5005/foo/bar:latest@sha256:232246f8f7809e9d7bd57fbc03b53c60d92cb4bc85261b1838d06368f9571de6 0.0s done [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] #10 DONE 4.5s [INFO] [io.quarkus.container.image.docker.deployment.DockerProcessor] Built container image host.docker.internal:5005/foo/bar:1.0.0-SNAPSHOT (linux/amd64,linux/arm64 platform(s)) [INFO] [io.quarkus.deployment.util.ExecUtil] The push refers to repository [host.docker.internal:5005/foo/bar] [INFO] [io.quarkus.deployment.util.ExecUtil] An image does not exist locally with the tag: host.docker.internal:5005/foo/bar ... Error: [ERROR] [error]: Build step io.quarkus.container.image.docker.deployment.DockerProcessor#dockerBuildFromJar threw an exception: java.lang.RuntimeException: Execution of 'docker push host.docker.internal:5005/foo/bar:latest' failed. See docker output for more details ``` Note how both building and pushing the images with buildx succeeded. Yet the build is failing due to the redundant push attempt. I think the culprit is that there's a missing `!useBuildx` condition here, when Quarkus checks if it should push images: https://github.com/quarkusio/quarkus/blob/66f501aefb1e05ca9768f4d25f15628e3f0a4165/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java#L224-L230 ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? 1. Create a new Quarkus project with `container-image-docker` extension: ```shell quarkus create app -x container-image-docker foo:bar:1.0.0-SNAPSHOT ``` 2. Start a local Docker registry: ```shell docker run --rm -p 5005:5000 --name registry registry:2 ``` 3. Create a new buildx builder that allows for HTTP usage against the local registry: ```shell echo '[registry."host.docker.internal:5005"]\\n http = true' > buildkitd.toml docker buildx create --use desktop-linux --config buildkitd.toml ``` 4. Run the Quarkus build: ```shell cd bar mvn clean install \\ -Dquarkus.container-image.additional-tags=latest \\ -Dquarkus.container-image.build=true \\ -Dquarkus.container-image.group=foo \\ -Dquarkus.container-image.registry=host.docker.internal:5005 \\ -DskipTests=true \\ -Dquarkus.container-image.push=true \\ -Dquarkus.docker.buildx.platform=linux/amd64,linux/arm64 ``` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.15.0.Final - 2.15.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
4f36e105afdc9d9d6430d846940b1b575b173a6f
6452f5fdb8f27e1e7fd14d524499d4c96dcb4b94
https://github.com/quarkusio/quarkus/compare/4f36e105afdc9d9d6430d846940b1b575b173a6f...6452f5fdb8f27e1e7fd14d524499d4c96dcb4b94
diff --git a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java b/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java index a9bc9b2e303..f6a5d79ab18 100644 --- a/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java +++ b/extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java @@ -221,7 +221,7 @@ private String createContainerImage(ContainerImageConfig containerImageConfig, D } } - if (pushContainerImage) { + if (!useBuildx && pushContainerImage) { // If not using buildx, push the images loginToRegistryIfNeeded(containerImageConfig, containerImageInfo, dockerConfig);
['extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java']
{'.java': 1}
1
1
0
0
1
24,364,354
4,797,663
621,356
5,696
83
20
2
1
10,633
678
3,163
144
1
5
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,284
quarkusio/quarkus/30418/30275
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30275
https://github.com/quarkusio/quarkus/pull/30418
https://github.com/quarkusio/quarkus/pull/30418
1
fixes
Inline Log category property doesn't work
### Describe the bug Quarkus 2.15.0.Final I am trying to set `quarkus.log.category` property through an inline system property at start time (Quarkus Dev Mode) `mvn quarkus:dev -Dquarkus.log.category."io.quarkus".level=WARN` or ``` mvn quarkus:dev -Dquarkus.log.category.\\"io.quarkus\\".level=WARN ``` But looks like the property is ignored. Works If I add the property to the application.property This issue has an impact on the developer user experience ### Expected behavior log level for `io.quarkus` package should be "warning". ### Actual behavior log level for `io.quarkus` is not changed ### How to Reproduce? ``` quarkus create app org.acme:getting-started \\ --extension='resteasy-reactive' ``` ``` cd getting-started ``` ``` mvn quarkus:dev -Dquarkus.log.category."io.quarkus".level=WARN ``` Result: ``` 2023-01-10 09:45:36,125 WARN [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.log.category.io.quarkus.level" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo ``` ### Output of `uname -a` or `ver` Linux fedora 6.0.16-300.fc37.x86_64 ### Output of `java -version` openjdk 17.0.5 2022-10-18 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_ FYI: @llowinge
b3e01e07655d4d777980b6a6ca6345e8b30fd8cc
b9dfa4ae023adce6b5d87c022cbe34214ae1aa00
https://github.com/quarkusio/quarkus/compare/b3e01e07655d4d777980b6a6ca6345e8b30fd8cc...b9dfa4ae023adce6b5d87c022cbe34214ae1aa00
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index 3e10e02d712..c57a75a2c50 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -93,7 +93,6 @@ import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContextConfig; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; -import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions; import io.quarkus.bootstrap.util.BootstrapUtils; import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.bootstrap.workspace.SourceDir; @@ -1184,7 +1183,6 @@ private QuarkusDevModeLauncher newLauncher(Boolean debugPortOk) throws Exception if (argsString != null) { builder.applicationArgs(argsString); } - propagateUserProperties(builder); return builder.build(); } @@ -1207,26 +1205,6 @@ private void setJvmArgs(Builder builder) throws Exception { } - private void propagateUserProperties(MavenDevModeLauncher.Builder builder) { - Properties userProps = BootstrapMavenOptions.newInstance().getSystemProperties(); - if (userProps == null) { - return; - } - final StringBuilder buf = new StringBuilder(); - buf.append("-D"); - for (Object o : userProps.keySet()) { - String name = o.toString(); - final String value = userProps.getProperty(name); - buf.setLength(2); - buf.append(name); - if (value != null && !value.isEmpty()) { - buf.append('='); - buf.append(value); - } - builder.jvmArgs(buf.toString()); - } - } - private void applyCompilerFlag(Optional<Xpp3Dom> compilerPluginConfiguration, String flagName, Consumer<String> builderCall) { compilerPluginConfiguration
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
24,316,726
4,788,479
620,220
5,687
857
156
22
1
1,566
194
439
70
0
5
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,285
quarkusio/quarkus/30399/30384
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/30384
https://github.com/quarkusio/quarkus/pull/30399
https://github.com/quarkusio/quarkus/pull/30399
1
fixes
Elasticsearch Dev Services restarts container on every auto-compile
### Describe the bug In DevMode, when having ElasticSearch dev services enabled and you modify code, causing dev mode to recompile, it restarts the ElasticSearch container on build. This is not supposed to happen if configuration does not change. The issue is the comparison of configurations `ElasticSearchDevServicesBuildTimeConfig` has no implementations of `.equals()` nor `hashCode()` so the comparison ALWAYS fails causing a container restart. ### Expected behavior No restart if configuration did not change. ### Actual behavior Container restarts every time regardless of wht changed. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
a316dd5fd70d0ba0b5ee3069725de99e888c06c4
aa11333c5056866180b1a4542369fe966b874c26
https://github.com/quarkusio/quarkus/compare/a316dd5fd70d0ba0b5ee3069725de99e888c06c4...aa11333c5056866180b1a4542369fe966b874c26
diff --git a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java index 4c7e97f8219..fee7078a2b8 100644 --- a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java +++ b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.elasticsearch.restclient.common.deployment; +import java.util.Objects; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigItem; @@ -65,4 +66,24 @@ public class ElasticsearchDevServicesBuildTimeConfig { */ @ConfigItem(defaultValue = "elasticsearch") public String serviceName; + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ElasticsearchDevServicesBuildTimeConfig that = (ElasticsearchDevServicesBuildTimeConfig) o; + return Objects.equals(shared, that.shared) + && Objects.equals(enabled, that.enabled) + && Objects.equals(port, that.port) + && Objects.equals(imageName, that.imageName) + && Objects.equals(javaOpts, that.javaOpts) + && Objects.equals(serviceName, that.serviceName); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, port, imageName, javaOpts, shared, serviceName); + } }
['extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java']
{'.java': 1}
1
1
0
0
1
24,359,778
4,796,952
621,268
5,696
812
157
21
1
979
141
210
45
0
0
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,393
quarkusio/quarkus/26779/26764
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26764
https://github.com/quarkusio/quarkus/pull/26779
https://github.com/quarkusio/quarkus/pull/26779
1
fixes
OpenTelemetry: NPE in HttpInstrumenterVertxTracer.RouteGetter when request got cancelled
### Describe the bug Relates to [#26356](https://github.com/quarkusio/quarkus/pull/26356/files#diff-8dd25e6bcffd41aa6d82e224799fbf61b9708d6d8a3ead2c7ed32ad261d62cccR152): Using a vert.x HTTP server along with `quarkus-opentelemetry`, we are seeing such exceptions in the logs: ``` java.lang.NullPointerException: Cannot invoke "io.vertx.core.spi.observability.HttpResponse.statusCode()" because "response" is null at io.quarkus.opentelemetry.runtime.tracing.vertx.HttpInstrumenterVertxTracer$RouteGetter.get(HttpInstrumenterVertxTracer.java:153) at io.quarkus.opentelemetry.runtime.tracing.vertx.HttpInstrumenterVertxTracer$RouteGetter.get(HttpInstrumenterVertxTracer.java:136) at io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteHolder.updateHttpRoute(HttpRouteHolder.java:125) at io.quarkus.opentelemetry.runtime.tracing.vertx.HttpInstrumenterVertxTracer.sendResponse(HttpInstrumenterVertxTracer.java:94) at io.quarkus.opentelemetry.runtime.tracing.vertx.HttpInstrumenterVertxTracer.sendResponse(HttpInstrumenterVertxTracer.java:41) at io.quarkus.opentelemetry.runtime.tracing.vertx.OpenTelemetryVertxTracer.sendResponse(OpenTelemetryVertxTracer.java:47) at io.quarkus.opentelemetry.runtime.tracing.vertx.OpenTelemetryVertxTracer.sendResponse(OpenTelemetryVertxTracer.java:16) at io.vertx.core.http.impl.Http1xServerRequest.reportRequestReset(Http1xServerRequest.java:645) at io.vertx.core.http.impl.Http1xServerRequest.handleException(Http1xServerRequest.java:623) at io.vertx.core.http.impl.Http1xServerConnection.lambda$handleClosed$6(Http1xServerConnection.java:455) at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:71) at io.vertx.core.impl.DuplicatedContext.execute(DuplicatedContext.java:163) at io.vertx.core.impl.AbstractContext.execute(AbstractContext.java:58) at io.vertx.core.http.impl.Http1xServerConnection.handleClosed(Http1xServerConnection.java:454) at io.vertx.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:143) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262) [...] ``` They occur when a client cancels a request before the server has sent a response. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.10.2 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
bcb0a1c62e2f611c85e7b04e9e7ce1ce1933902b
032297652436aa23e05307974b5fbbf51a700ae3
https://github.com/quarkusio/quarkus/compare/bcb0a1c62e2f611c85e7b04e9e7ce1ce1933902b...032297652436aa23e05307974b5fbbf51a700ae3
diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java index 0e21f0d2bdb..cbc01516f96 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java @@ -4,6 +4,7 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_CLIENT_IP; import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.INSTRUMENTATION_NAME; +import java.util.Collections; import java.util.List; import java.util.function.BiConsumer; @@ -151,7 +152,7 @@ public String get(final io.opentelemetry.context.Context context, final HttpRequ return route; } - if (HttpResponseStatus.NOT_FOUND.code() == response.statusCode()) { + if (response != null && HttpResponseStatus.NOT_FOUND.code() == response.statusCode()) { return "/*"; } @@ -231,12 +232,12 @@ public Long requestContentLengthUncompressed(final HttpRequest request, final Ht @Override public Integer statusCode(final HttpRequest request, final HttpResponse response) { - return response.statusCode(); + return response != null ? response.statusCode() : null; } @Override public Long responseContentLength(final HttpRequest request, final HttpResponse response) { - return getContentLength(response.headers()); + return response != null ? getContentLength(response.headers()) : null; } @Override @@ -246,7 +247,7 @@ public Long responseContentLengthUncompressed(final HttpRequest request, final H @Override public List<String> responseHeader(final HttpRequest request, final HttpResponse response, final String name) { - return response.headers().getAll(name); + return response != null ? response.headers().getAll(name) : Collections.emptyList(); } private static Long getContentLength(final MultiMap headers) {
['extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java']
{'.java': 1}
1
1
0
0
1
22,103,097
4,326,634
563,591
5,258
617
99
9
1
2,703
147
658
62
1
1
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,392
quarkusio/quarkus/26783/26782
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26782
https://github.com/quarkusio/quarkus/pull/26783
https://github.com/quarkusio/quarkus/pull/26783
1
fixes
Endpoint access not logged into access log when root-path and non-application-root-path are under different root
### Describe the bug Originally reported in https://github.com/smallrye/smallrye-health/issues/412. When non app root is rooted under different root than app HTTP root a new main router is created and thus we add access log handler only to the HTTP root and not the new main root. ### Expected behavior Non app access are logged into the access log. ### Actual behavior Not logged as showed in https://github.com/smallrye/smallrye-health/issues/412. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
65bb8b9c2756340d1ab80ebf11a6040ab4bfd286
767eedab15fa679940a3c9641e01635fd9820686
https://github.com/quarkusio/quarkus/compare/65bb8b9c2756340d1ab80ebf11a6040ab4bfd286...767eedab15fa679940a3c9641e01635fd9820686
diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java index 5f535780bfd..c8155cb1f62 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java @@ -291,7 +291,9 @@ ServiceStartBuildItem finalizeRouter( recorder.finalizeRouter(beanContainer.getValue(), defaultRoute.map(DefaultRouteBuildItem::getRoute).orElse(null), listOfFilters, vertx.getVertx(), lrc, mainRouter, httpRouteRouter.getHttpRouter(), - httpRouteRouter.getMutinyRouter(), + httpRouteRouter.getMutinyRouter(), httpRouteRouter.getFrameworkRouter(), + nonApplicationRootPathBuildItem.isDedicatedRouterRequired(), + nonApplicationRootPathBuildItem.isAttachedToMainRouter(), httpRootPathBuildItem.getRootPath(), launchMode.getLaunchMode(), !requireBodyHandlerBuildItems.isEmpty(), bodyHandler, gracefulShutdownFilter, diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 00da9c567b7..983dbc6e315 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -334,6 +334,8 @@ public void finalizeRouter(BeanContainer container, Consumer<Route> defaultRoute List<Filter> filterList, Supplier<Vertx> vertx, LiveReloadConfig liveReloadConfig, Optional<RuntimeValue<Router>> mainRouterRuntimeValue, RuntimeValue<Router> httpRouterRuntimeValue, RuntimeValue<io.vertx.mutiny.ext.web.Router> mutinyRouter, + RuntimeValue<Router> frameworkRouter, + boolean nonApplicationDedicatedRouter, boolean nonApplicationAttachedToMainRouter, String rootPath, LaunchMode launchMode, boolean requireBodyHandler, Handler<RoutingContext> bodyHandler, GracefulShutdownFilter gracefulShutdownFilter, ShutdownConfig shutdownConfig, @@ -552,7 +554,11 @@ public void handle(HttpServerRequest event) { } AccessLogHandler handler = new AccessLogHandler(receiver, accessLog.pattern, getClass().getClassLoader(), accessLog.excludePattern); + if (nonApplicationDedicatedRouter && !nonApplicationAttachedToMainRouter) { + frameworkRouter.getValue().route().order(Integer.MIN_VALUE).handler(handler); + } httpRouteRouter.route().order(Integer.MIN_VALUE).handler(handler); + quarkusWrapperNeeded = true; }
['extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/VertxHttpProcessor.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java']
{'.java': 2}
2
2
0
0
2
22,180,696
4,341,732
565,632
5,276
641
114
10
2
830
123
193
41
2
0
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,391
quarkusio/quarkus/26810/26773
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26773
https://github.com/quarkusio/quarkus/pull/26810
https://github.com/quarkusio/quarkus/pull/26810
1
fixes
Runtime exception on building application jar
### Describe the bug When I try to build application jar the following exception occures: `ERROR] [error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingRuntimeInit threw an exception: java.lang.RuntimeException: You cannot invoke getValue() directly on an object returned from the bytecode recorder, you can only pass it back into the recorder as a parameter [ERROR] at io.quarkus.deployment.recording.BytecodeRecorderImpl$3.invoke(BytecodeRecorderImpl.java:444) [ERROR] at io.quarkus.deployment.recording.BytecodeRecorderImpl$$ReturnValueProxy22.getValue(Unknown Source) [ERROR] at io.quarkus.runtime.logging.LoggingSetupRecorder.configureFileHandler(LoggingSetupRecorder.java:500) [ERROR] at io.quarkus.runtime.logging.LoggingSetupRecorder.createNamedHandlers(LoggingSetupRecorder.java:333) [ERROR] at io.quarkus.runtime.logging.LoggingSetupRecorder.initializeBuildTimeLogging(LoggingSetupRecorder.java:261) [ERROR] at io.quarkus.deployment.logging.LoggingResourceProcessor.setupLoggingRuntimeInit(LoggingResourceProcessor.java:225) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:944) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [ERROR] at java.base/java.lang.Thread.run(Thread.java:829) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException` **Possible root cause** Direct use of possibleFileFormatters in io.quarkus.runtime.logging.LoggingSetupRecorder::initializeBuildTimeLogging. Does logging to file make sense at build time? ### Expected behavior Quarkus jar is build. ### Actual behavior Error occurs: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingRuntimeInit threw an exception: java.lang.RuntimeException: You cannot invoke getValue() directly on an object returned from the bytecode recorder, you can only pass it back into the recorder as a parameter ### How to Reproduce? a) Checkout https://github.com/quarkusio/quarkus-quickstarts/tree/main/getting-started b) add the following to application.properties quarkus.log.handler.file."aaa".enable=true quarkus.log.handler.file."aaar".path=./logs/aaa.log quarkus.log.handler.file."aaa".level=INFO c) add depdencency to io.quarkus:quarkus-logging-json in pom.xml d) run mvnw package ### Output of `uname -a` or `ver` Microsoft Windows [Version 10.0.19044.1766] ### Output of `java -version` openjdk 11.0.15 2022-04-19 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.10.x ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) ### Additional information _No response_
b4527f8d2bc8167c2026c60935a8ba02bf6a67d0
d125cd8018dfb07b94bd4807db79468322a78b1f
https://github.com/quarkusio/quarkus/compare/b4527f8d2bc8167c2026c60935a8ba02bf6a67d0...d125cd8018dfb07b94bd4807db79468322a78b1f
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java index 0045e8e8cba..7501e18b087 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java @@ -237,7 +237,7 @@ LoggingSetupBuildItem setupLoggingRuntimeInit(RecorderContext context, LoggingSe ConsoleRuntimeConfig crc = new ConsoleRuntimeConfig(); ConfigInstantiator.handleObject(crc); LoggingSetupRecorder.initializeBuildTimeLogging(logConfig, buildLog, categoryMinLevelDefaults.content, - crc, possibleFileFormatters, launchModeBuildItem.getLaunchMode()); + crc, launchModeBuildItem.getLaunchMode()); ((QuarkusClassLoader) Thread.currentThread().getContextClassLoader()).addCloseTask(new Runnable() { @Override public void run() { diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index aac631b5388..4b0ec8741df 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -231,9 +231,13 @@ public void accept(String categoryName, CategoryConfig config) { InitialConfigurator.DELAYED_HANDLER.setHandlers(handlers.toArray(EmbeddedConfigurator.NO_HANDLERS)); } + /** + * WARNING: this method is part of the recorder but is actually called statically at build time. + * You may not push RuntimeValue's to it. + */ public static void initializeBuildTimeLogging(LogConfig config, LogBuildTimeConfig buildConfig, Map<String, InheritableLevel> categoryDefaultMinLevels, - ConsoleRuntimeConfig consoleConfig, List<RuntimeValue<Optional<Formatter>>> possibleFileFormatters, + ConsoleRuntimeConfig consoleConfig, LaunchMode launchMode) { final Map<String, CategoryConfig> categories = config.categories; @@ -263,7 +267,7 @@ public static void initializeBuildTimeLogging(LogConfig config, LogBuildTimeConf Map<String, Handler> namedHandlers = createNamedHandlers(config, consoleConfig, Collections.emptyList(), Collections.emptyList(), - possibleFileFormatters, errorManager, logCleanupFilter, launchMode); + Collections.emptyList(), errorManager, logCleanupFilter, launchMode); for (Map.Entry<String, CategoryConfig> entry : categories.entrySet()) { final String categoryName = entry.getKey();
['core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java', 'core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java']
{'.java': 2}
2
2
0
0
2
22,094,925
4,325,072
563,515
5,258
652
122
10
2
3,931
299
946
77
2
0
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,389
quarkusio/quarkus/26886/26885
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26885
https://github.com/quarkusio/quarkus/pull/26886
https://github.com/quarkusio/quarkus/pull/26886
1
fix
Redis healthcheck message sometimes is not useful.
### Describe the bug There is some runtime exceptions that has no message when they are fired. Actually the healthcheck performs a message with ` return builder.down().withData("reason", "client [" + client.getKey() + "]: " + e.getMessage()).build();` ### Expected behavior Reason should include a message that must explain what's happening on any exception. ### Actual behavior If getMessage() returns null the message is something like `"reason": "client [<default>]: null"` ### How to Reproduce? 1. Setup a 1 second timeout. 2. Connect to a redis that is lagging or with high workload. 3. Wait to a healthcheck happend. 4. Read the healthcheck message. In this reproducer the `atMost` method of Mutiny will throw a `TimeoutException` that has no message ( null ). ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
3f51f74670f9522a37be81696ca662c6d329d213
a15b8ddde2a23e5f5f992168df89446f38114c34
https://github.com/quarkusio/quarkus/compare/3f51f74670f9522a37be81696ca662c6d329d213...a15b8ddde2a23e5f5f992168df89446f38114c34
diff --git a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/health/RedisHealthCheck.java b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/health/RedisHealthCheck.java index e179a0cf1d5..5a64eb1d2ff 100644 --- a/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/health/RedisHealthCheck.java +++ b/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/health/RedisHealthCheck.java @@ -22,6 +22,7 @@ import io.quarkus.redis.datasource.ReactiveRedisDataSource; import io.quarkus.redis.datasource.RedisDataSource; import io.quarkus.redis.runtime.client.config.RedisConfig; +import io.smallrye.mutiny.TimeoutException; import io.vertx.mutiny.redis.client.Command; import io.vertx.mutiny.redis.client.Redis; import io.vertx.mutiny.redis.client.Request; @@ -88,7 +89,12 @@ public HealthCheckResponse call() { Duration timeout = getTimeout(client.getKey()); Response response = redisClient.send(Request.cmd(Command.PING)).await().atMost(timeout); builder.up().withData(redisClientName, response.toString()); + } catch (TimeoutException e) { + return builder.down().withData("reason", "client [" + client.getKey() + "]: timeout").build(); } catch (Exception e) { + if (e.getMessage() == null) { + return builder.down().withData("reason", "client [" + client.getKey() + "]: " + e).build(); + } return builder.down().withData("reason", "client [" + client.getKey() + "]: " + e.getMessage()).build(); } }
['extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/health/RedisHealthCheck.java']
{'.java': 1}
1
1
0
0
1
22,102,723
4,326,552
563,585
5,258
379
82
6
1
1,131
171
270
50
0
0
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,388
quarkusio/quarkus/26891/26831
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/26831
https://github.com/quarkusio/quarkus/pull/26891
https://github.com/quarkusio/quarkus/pull/26891
1
fixes
Windows paths not escaped in DevUI
### Describe the bug On Windows when the DevUI renders the template [main.html](https://github.com/quarkusio/quarkus/blob/91ba39965d13652e853446e227b256a1b8cea477/extensions/vertx-http/deployment/src/main/resources/dev-templates/main.html) the path are not properly escaped leading to the page not being able to be used as JavaScript is broken. The code [here](https://github.com/quarkusio/quarkus/blob/91ba39965d13652e853446e227b256a1b8cea477/extensions/vertx-http/deployment/src/main/resources/dev-templates/main.html#L146-L150) takes the paths as is and put them into the HTML, leading to the following error `provider:594 Uncaught SyntaxError: Invalid Unicode escape sequence (at provider:594:70)`. ### Expected behavior The paths should be properly escaped using `\\\\` for path separators on Windows. ### Actual behavior It lead to the JavaScript error: `provider:594 Uncaught SyntaxError: Invalid Unicode escape sequence (at provider:594:70)` ### How to Reproduce? Create/move a project into a path where the directory would start with an invalid Unicode character i.e. `c:\\userproject`. I have created and uploaded a sample project to Github as a sample: https://github.com/bwolkerstorfer/sample-quarkus-path-issue Steps: 1. run the project on Windows using `gradle quarkusDev` 2. navigate to i.e. http://localhost:8080/q/dev/io.quarkus.quarkus-oidc/provider 3. check the JS console ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.10.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) ------------------------------------------------------------ Gradle 7.5 ------------------------------------------------------------ Build time: 2022-07-14 12:48:15 UTC Revision: c7db7b958189ad2b0c1472b6fe663e6d654a5103 Kotlin: 1.6.21 Groovy: 3.0.10 Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021 JVM: 17.0.3 (Eclipse Adoptium 17.0.3+7) OS: Windows 11 10.0 amd64 ### Additional information _No response_
3f51f74670f9522a37be81696ca662c6d329d213
e563988c9e8f5de84c6fcdb29092759d7a08ff50
https://github.com/quarkusio/quarkus/compare/3f51f74670f9522a37be81696ca662c6d329d213...e563988c9e8f5de84c6fcdb29092759d7a08ff50
diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsoleProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsoleProcessor.java index e2933e22aa6..d5d62e3a682 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsoleProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsoleProcessor.java @@ -940,7 +940,7 @@ public Object apply(EvalContext ctx) { for (Path sourcePaths : sourcesDir) { List<String> packages = sourcePackagesForRoot(sourcePaths); if (!packages.isEmpty()) { - sourcePackagesByDir.put(sourcePaths.toAbsolutePath().toString(), packages); + sourcePackagesByDir.put(sourcePaths.toAbsolutePath().toString().replace("\\\\", "/"), packages); } } return sourcePackagesByDir;
['extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsoleProcessor.java']
{'.java': 1}
1
1
0
0
1
22,102,723
4,326,552
563,585
5,258
220
35
2
1
2,153
234
576
50
4
0
1970-01-01T00:27:38
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,287
quarkusio/quarkus/30303/29209
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29209
https://github.com/quarkusio/quarkus/pull/30303
https://github.com/quarkusio/quarkus/pull/30303
1
fix
Kubernetes resources generation log not on par with what is generated
### Describe the bug When you generate a container image and Kubernetes resources but not push the image to a remote Docker registry, the following logs is shown ``` [WARNING] [io.quarkus.kubernetes.deployment.KubernetesDeployer] A Kubernetes deployment was requested, but the container image to be built will not be pushed to any registry because "quarkus.container-image.registry" has not been set. The Kubernetes deployment will only work properly if the cluster is using the local Docker daemon. For that reason 'ImagePullPolicy' is being force-set to 'IfNotPresent'. ``` However, the generated resouce have `imagePullPolicy: Always`. ### Expected behavior Either the log is updated either the generated resource is updated to match each other. ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` Ubuntu 22.04 ### Output of `java -version` 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.14.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
4b03cbe1878dc775d656161abe20f382a7067daa
e008499c27dbeefcf5615367f392dbca75b6160b
https://github.com/quarkusio/quarkus/compare/4b03cbe1878dc775d656161abe20f382a7067daa...e008499c27dbeefcf5615367f392dbca75b6160b
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java index 3dcab91d48a..5a8dcbc4aa1 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java @@ -41,7 +41,6 @@ import io.quarkus.container.image.deployment.ContainerImageConfig; import io.quarkus.container.spi.ContainerImageInfoBuildItem; import io.quarkus.deployment.Capabilities; -import io.quarkus.deployment.Capability; import io.quarkus.deployment.IsNormalNotRemoteDev; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -152,7 +151,6 @@ private DeploymentTargetEntry determineDeploymentTarget( ContainerImageConfig containerImageConfig) { final DeploymentTargetEntry selectedTarget; - boolean checkForMissingRegistry = true; boolean checkForNamespaceGroupAlignment = false; List<String> userSpecifiedDeploymentTargets = KubernetesConfigUtil.getExplictilyDeploymentTargets(); if (userSpecifiedDeploymentTargets.isEmpty()) { @@ -178,25 +176,10 @@ private DeploymentTargetEntry determineDeploymentTarget( } if (OPENSHIFT.equals(selectedTarget.getName())) { - checkForMissingRegistry = Capability.CONTAINER_IMAGE_S2I.equals(activeContainerImageCapability) - || Capability.CONTAINER_IMAGE_OPENSHIFT.equals(activeContainerImageCapability); - // We should ensure that we have image group and namespace alignment we are not using deployment triggers via DeploymentConfig. if (!targets.getEntriesSortedByPriority().get(0).getKind().equals("DeploymentConfig")) { checkForNamespaceGroupAlignment = true; } - - } else if (MINIKUBE.equals(selectedTarget.getName()) || KIND.equals(selectedTarget.getName())) { - checkForMissingRegistry = false; - } else if (containerImageConfig.isPushExplicitlyDisabled()) { - checkForMissingRegistry = false; - } - - if (checkForMissingRegistry && !containerImageInfo.getRegistry().isPresent()) { - log.warn( - "A Kubernetes deployment was requested, but the container image to be built will not be pushed to any registry" - + " because \\"quarkus.container-image.registry\\" has not been set. The Kubernetes deployment will only work properly" - + " if the cluster is using the local Docker daemon. For that reason 'ImagePullPolicy' is being force-set to 'IfNotPresent'."); } //This might also be applicable in other scenarios too (e.g. Knative on Openshift), so we might need to make it slightly more generic.
['extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java']
{'.java': 1}
1
1
0
0
1
24,286,873
4,782,609
619,556
5,678
1,135
210
17
1
1,154
167
263
45
0
1
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,289
quarkusio/quarkus/30285/23059
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/23059
https://github.com/quarkusio/quarkus/pull/30285
https://github.com/quarkusio/quarkus/pull/30285
1
fix
REST Reactive Client: PartFilename annotation doesn't work if member is anything else than java.io.File
### Describe the bug I have tested the new @PartFilename annotation in the REST Reactive client (Quarkus 2.7.0.CR1). See issue #22658 However, the annotation seems to work only if the respective annotated member is of type java.io.File. I tested with java.nio.Buffer and java.lang.String. If one of these two types is used, the file name is not transferred. Works as expected: ```java public class OurForm { @FormParam("files") @PartFilename("document.txt") @PartType(MediaType.TEXT_PLAIN) private File documentFile; } ``` Doesn't work: ```java public class OurForm { @FormParam("files") @PartFilename("document.txt") @PartType(MediaType.TEXT_PLAIN) private String documentFile; } public class OurForm { @FormParam("files") @PartFilename("document.txt") @PartType(MediaType.TEXT_PLAIN) private Buffer documentFile; } ``` ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) 2.7.0.CR1 ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
126aa68c303e62d476d6238abe51805479c4d1b4
cf5240ce60c88db84e11ffc7623352081a1ba340
https://github.com/quarkusio/quarkus/compare/126aa68c303e62d476d6238abe51805479c4d1b4...cf5240ce60c88db84e11ffc7623352081a1ba340
diff --git a/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java b/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java index 8f79b818fad..db778f22b64 100644 --- a/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java +++ b/extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java @@ -1627,7 +1627,7 @@ private void handleMultipartField(String formParamName, String partType, String // we support string, and send it as an attribute unconverted if (type.equals(String.class.getName())) { - addString(ifValueNotNull, multipartForm, formParamName, partFilename, fieldValue); + addString(ifValueNotNull, multipartForm, formParamName, partType, partFilename, fieldValue); } else if (type.equals(File.class.getName())) { // file is sent as file :) ResultHandle filePath = ifValueNotNull.invokeVirtualMethod( @@ -1660,7 +1660,7 @@ private void handleMultipartField(String formParamName, String partType, String parameterAnnotations, methodIndex); BytecodeCreator parameterIsStringBranch = checkStringParam(ifValueNotNull, convertedFormParam, restClientInterfaceClassName, errorLocation); - addString(parameterIsStringBranch, multipartForm, formParamName, partFilename, convertedFormParam); + addString(parameterIsStringBranch, multipartForm, formParamName, null, partFilename, convertedFormParam); } } @@ -1743,13 +1743,27 @@ private ResultHandle partFilenameHandle(BytecodeCreator methodCreator, String pa } private void addString(BytecodeCreator methodCreator, AssignableResultHandle multipartForm, String formParamName, - String partFilename, ResultHandle fieldValue) { - methodCreator.assign(multipartForm, - methodCreator.invokeVirtualMethod( - MethodDescriptor.ofMethod(QuarkusMultipartForm.class, "attribute", QuarkusMultipartForm.class, - String.class, String.class, String.class), - multipartForm, methodCreator.load(formParamName), fieldValue, - partFilenameHandle(methodCreator, partFilename))); + String partType, String partFilename, ResultHandle fieldValue) { + if (MediaType.APPLICATION_OCTET_STREAM.equalsIgnoreCase(partType)) { + methodCreator.assign(multipartForm, + // MultipartForm#stringFileUpload(String name, String filename, String content, String mediaType); + methodCreator.invokeVirtualMethod( + MethodDescriptor.ofMethod(QuarkusMultipartForm.class, "stringFileUpload", + QuarkusMultipartForm.class, String.class, String.class, String.class, + String.class), + multipartForm, + methodCreator.load(formParamName), + partFilename != null ? methodCreator.load(partFilename) : methodCreator.loadNull(), + fieldValue, + methodCreator.load(partType))); + } else { + methodCreator.assign(multipartForm, + methodCreator.invokeVirtualMethod( + MethodDescriptor.ofMethod(QuarkusMultipartForm.class, "attribute", QuarkusMultipartForm.class, + String.class, String.class, String.class), + multipartForm, methodCreator.load(formParamName), fieldValue, + partFilenameHandle(methodCreator, partFilename))); + } } private void addMultiAsFile(BytecodeCreator methodCreator, AssignableResultHandle multipartForm, String formParamName, diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java index 22c7a845d41..9723f6f3841 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java @@ -58,9 +58,18 @@ void shouldUseFileNameFromAnnotation() throws IOException { File file = File.createTempFile("MultipartTest", ".txt"); file.deleteOnExit(); - ClientForm2 form = new ClientForm2(); + ClientFormUsingFile form = new ClientFormUsingFile(); form.file = file; - assertThat(client.postMultipartWithPartFilename(form)).isEqualTo(ClientForm2.FILE_NAME); + assertThat(client.postMultipartWithPartFilename(form)).isEqualTo(ClientFormUsingFile.FILE_NAME); + } + + @Test + void shouldUseFileNameFromAnnotationUsingString() { + Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class); + + ClientFormUsingString form = new ClientFormUsingString(); + form.file = "file content"; + assertThat(client.postMultipartWithPartFilenameUsingString(form)).isEqualTo("clientFile:file content"); } @Test @@ -111,6 +120,13 @@ public String upload(@MultipartForm FormData form) { return form.myFile.fileName(); } + @POST + @Path("/using-string") + @Consumes(MediaType.MULTIPART_FORM_DATA) + public String uploadWithFileContentUsingString(@MultipartForm FormData form) throws IOException { + return form.myFile.fileName() + ":" + Files.readString(form.myFile.uploadedFile()); + } + @POST @Path("/file-content") @Consumes(MediaType.MULTIPART_FORM_DATA) @@ -166,7 +182,12 @@ public interface Client { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) - String postMultipartWithPartFilename(@MultipartForm ClientForm2 clientForm); + String postMultipartWithPartFilename(@MultipartForm ClientFormUsingFile clientForm); + + @POST + @Path("/using-string") + @Consumes(MediaType.MULTIPART_FORM_DATA) + String postMultipartWithPartFilenameUsingString(@MultipartForm ClientFormUsingString clientForm); @POST @Path("/file-content") @@ -190,7 +211,7 @@ public static class ClientForm { public File file; } - public static class ClientForm2 { + public static class ClientFormUsingFile { public static final String FILE_NAME = "clientFile"; @FormParam("myFile") @@ -198,4 +219,13 @@ public static class ClientForm2 { @PartFilename(FILE_NAME) public File file; } + + public static class ClientFormUsingString { + public static final String FILE_NAME = "clientFile"; + + @FormParam("myFile") + @PartType(MediaType.APPLICATION_OCTET_STREAM) + @PartFilename(FILE_NAME) + public String file; + } } diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartForm.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartForm.java index 55c8db8783a..026c96dbd68 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartForm.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartForm.java @@ -67,6 +67,11 @@ public QuarkusMultipartForm textFileUpload(String name, String filename, Buffer return this; } + @SuppressWarnings("unused") + public QuarkusMultipartForm stringFileUpload(String name, String filename, String content, String mediaType) { + return textFileUpload(name, filename, Buffer.buffer(content), mediaType); + } + @SuppressWarnings("unused") public QuarkusMultipartForm binaryFileUpload(String name, String filename, String pathname, String mediaType) { parts.add(new QuarkusMultipartFormDataPart(name, filename, pathname, mediaType, false));
['extensions/resteasy-reactive/jaxrs-client-reactive/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java', 'independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartForm.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/multipart/MultipartFilenameTest.java']
{'.java': 3}
3
3
0
0
3
24,271,939
4,779,488
619,224
5,676
2,665
444
37
2
1,321
165
324
68
0
2
1970-01-01T00:27:53
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,333
quarkusio/quarkus/28835/25991
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/25991
https://github.com/quarkusio/quarkus/pull/28835
https://github.com/quarkusio/quarkus/pull/28835
1
resolves
CLI allows to create project with comma in the name
### Describe the bug CLI allows to create project with comma in the name. Comma is not allowed character for `artifactId` in maven projects ``` quarkus create app app,with,comma cd app,with,comma quarkus build ... [ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] 'artifactId' with value 'app,with,comma' does not match a valid id pattern. @ line 6, column 15 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project org.acme:app,with,comma:1.0.0-SNAPSHOT (/Users/rsvoboda/tmp/app,with,comma/pom.xml) has 1 error [ERROR] 'artifactId' with value 'app,with,comma' does not match a valid id pattern. @ line 6, column 15 ``` ### Expected behavior CLI complains about problematic character ### Actual behavior CLI allows to create project with comma in the name. Comma is not allowed character for `artifactId` in maven projects ### How to Reproduce? ``` quarkus create app app,with,comma cd app,with,comma quarkus build ``` ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` Java 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.9.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
a8b1ee4584f7a5db432f28908668eb024139ae3a
b40e64d47a0c15fbe3088772b413c19668b9ed81
https://github.com/quarkusio/quarkus/compare/a8b1ee4584f7a5db432f28908668eb024139ae3a...b40e64d47a0c15fbe3088772b413c19668b9ed81
diff --git a/devtools/cli/src/main/java/io/quarkus/cli/create/TargetGAVGroup.java b/devtools/cli/src/main/java/io/quarkus/cli/create/TargetGAVGroup.java index 5c45c4a6425..04d083d811f 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/create/TargetGAVGroup.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/create/TargetGAVGroup.java @@ -1,9 +1,15 @@ package io.quarkus.cli.create; +import java.util.regex.Pattern; + import io.quarkus.devtools.commands.CreateProjectHelper; import picocli.CommandLine; +import picocli.CommandLine.TypeConversionException; public class TargetGAVGroup { + static final String BAD_IDENTIFIER = "The specified %s identifier (%s) contains invalid characters. Valid characters are alphanumeric (A-Za-z), underscore, dash and dot."; + static final Pattern OK_ID = Pattern.compile("[0-9A-Za-z_.-]+"); + static final String DEFAULT_GAV = CreateProjectHelper.DEFAULT_GROUP_ID + ":" + CreateProjectHelper.DEFAULT_ARTIFACT_ID + ":" + CreateProjectHelper.DEFAULT_VERSION; @@ -52,6 +58,13 @@ void projectGav() { } } } + if (artifactId != CreateProjectHelper.DEFAULT_ARTIFACT_ID && !OK_ID.matcher(artifactId).matches()) { + throw new TypeConversionException(String.format(BAD_IDENTIFIER, "artifactId", artifactId)); + } + if (groupId != CreateProjectHelper.DEFAULT_GROUP_ID && !OK_ID.matcher(groupId).matches()) { + throw new TypeConversionException(String.format(BAD_IDENTIFIER, "groupId", groupId)); + } + initialized = true; } } diff --git a/devtools/cli/src/test/java/io/quarkus/cli/create/TargetGAVGroupTest.java b/devtools/cli/src/test/java/io/quarkus/cli/create/TargetGAVGroupTest.java index a8714b43e23..1602c0d7ac0 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/create/TargetGAVGroupTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/create/TargetGAVGroupTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import io.quarkus.devtools.commands.CreateProjectHelper; +import picocli.CommandLine.TypeConversionException; public class TargetGAVGroupTest { @@ -92,4 +93,16 @@ void testOldParameters() { Assertions.assertEquals("a", gav.getArtifactId()); Assertions.assertEquals("v", gav.getVersion()); } + + @Test + void testBadArtifactId() { + gav.gav = "g:a/x:v"; + Assertions.assertThrows(TypeConversionException.class, () -> gav.getArtifactId()); + } + + @Test + void testBadGroupId() { + gav.gav = "g,x:a:v"; + Assertions.assertThrows(TypeConversionException.class, () -> gav.getGroupId()); + } } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java index 44a5e3f8216..21932062a48 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Set; import java.util.function.Predicate; +import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.maven.execution.MavenSession; @@ -55,6 +56,8 @@ */ @Mojo(name = "create", requiresProject = false) public class CreateProjectMojo extends AbstractMojo { + static final String BAD_IDENTIFIER = "The specified %s identifier (%s) contains invalid characters. Valid characters are alphanumeric (A-Za-z), underscore, dash and dot."; + static final Pattern OK_ID = Pattern.compile("[0-9A-Za-z_.-]+"); private static final String DEFAULT_GROUP_ID = "org.acme"; private static final String DEFAULT_ARTIFACT_ID = "code-with-quarkus"; @@ -262,6 +265,13 @@ public void execute() throws MojoExecutionException { } askTheUserForMissingValues(); + if (projectArtifactId != DEFAULT_ARTIFACT_ID && !OK_ID.matcher(projectArtifactId).matches()) { + throw new MojoExecutionException(String.format(BAD_IDENTIFIER, "artifactId", projectArtifactId)); + } + if (projectGroupId != DEFAULT_GROUP_ID && !OK_ID.matcher(projectGroupId).matches()) { + throw new MojoExecutionException(String.format(BAD_IDENTIFIER, "groupId", projectGroupId)); + } + projectRoot = new File(outputDirectory, projectArtifactId); if (projectRoot.exists()) { throw new MojoExecutionException("Unable to create the project, " + diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java index ef5d03e70a7..16b859cf388 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java @@ -396,6 +396,34 @@ public void testProjectGenerationFromScratchWithCustomDependencies() throws Exce && d.getVersion().equalsIgnoreCase("2.5"))).isTrue(); } + @Test + public void testBadArtifactId() throws Exception { + testDir = initEmptyProject("projects/project-generation-with-bad-artifact-id"); + assertThat(testDir).isDirectory(); + invoker = initInvoker(testDir); + + Properties properties = new Properties(); + properties.put("projectArtifactId", "acme,fail"); + properties.put("extensions", "resteasy,commons-io:commons-io:2.5"); + InvocationResult result = setup(properties); + + assertThat(result.getExitCode()).isNotZero(); + } + + @Test + public void testBadGroupId() throws Exception { + testDir = initEmptyProject("projects/project-generation-with-bad-group-id"); + assertThat(testDir).isDirectory(); + invoker = initInvoker(testDir); + + Properties properties = new Properties(); + properties.put("projectGroupId", "acme,fail"); + properties.put("extensions", "resteasy,commons-io:commons-io:2.5"); + InvocationResult result = setup(properties); + + assertThat(result.getExitCode()).isNotZero(); + } + @Test public void testProjectGenerationFromScratchWithAppConfigParameter() throws MavenInvocationException, IOException { testDir = initEmptyProject("projects/project-generation-with-config-param");
['devtools/cli/src/test/java/io/quarkus/cli/create/TargetGAVGroupTest.java', 'devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java', 'integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java', 'devtools/cli/src/main/java/io/quarkus/cli/create/TargetGAVGroup.java']
{'.java': 4}
4
4
0
0
4
23,288,312
4,576,048
594,755
5,488
1,517
306
23
2
1,342
195
376
59
0
2
1970-01-01T00:27:46
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,331
quarkusio/quarkus/28945/28936
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/28936
https://github.com/quarkusio/quarkus/pull/28945
https://github.com/quarkusio/quarkus/pull/28945
1
fix
Wrong warnings when pushing images using JIB, Docker or BuildPack
### Describe the bug When using the property `quarkus.container-image.image=quay.io/user/app:1.0`, the extensions `quarkus-container-image-buildpack`, `quarkus-container-image-docker` and `quarkus-container-image-jib` does not read this value but only to the property `quarkus.container-image.registry` and hence, it prints this warning message: ``` [INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] No container image registry was set, so 'docker.io' will be used ``` The good thing is that later in the process, the right registry from `quarkus.container-image.image` is used and the process ends fine. However, the log message is wrong and we need to address it to take into consideration both properties. ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev _No response_ ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
529e29e948fcfdfca52236dea642a3d839846521
5bea18ffdbd1129642b2596e69192c129c8cb0b8
https://github.com/quarkusio/quarkus/compare/529e29e948fcfdfca52236dea642a3d839846521...5bea18ffdbd1129642b2596e69192c129c8cb0b8
diff --git a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java index c3b2a0dbf61..e3592f9f1fb 100644 --- a/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java +++ b/extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java @@ -159,7 +159,7 @@ private String runBuildpackBuild(BuildpackConfig buildpackConfig, log.debug("Using source root of " + dirs.get(ProjectDirs.SOURCE)); log.debug("Using project root of " + dirs.get(ProjectDirs.ROOT)); - String targetImageName = containerImage.getImage().toString(); + String targetImageName = containerImage.getImage(); log.debug("Using Destination image of " + targetImageName); Map<String, String> envMap = new HashMap<>(buildpackConfig.builderEnv); @@ -204,11 +204,13 @@ private String runBuildpackBuild(BuildpackConfig buildpackConfig, log.info("Buildpack build complete"); if (containerImageConfig.isPushExplicitlyEnabled() || pushRequest.isPresent()) { - if (!containerImageConfig.registry.isPresent()) { - log.info("No container image registry was set, so 'docker.io' will be used"); - } + var registry = containerImage.getRegistry() + .orElseGet(() -> { + log.info("No container image registry was set, so 'docker.io' will be used"); + return "docker.io"; + }); AuthConfig authConfig = new AuthConfig(); - authConfig.withRegistryAddress(containerImageConfig.registry.orElse("docker.io")); + authConfig.withRegistryAddress(registry); containerImageConfig.username.ifPresent(u -> authConfig.withUsername(u)); containerImageConfig.password.ifPresent(p -> authConfig.withPassword(p)); diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java index 989a4026e63..194144ed1ac 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java @@ -264,14 +264,14 @@ private JibContainer containerize(ContainerImageConfig containerImageConfig, } private Containerizer createContainerizer(ContainerImageConfig containerImageConfig, - JibConfig jibConfig, ContainerImageInfoBuildItem containerImage, + JibConfig jibConfig, ContainerImageInfoBuildItem containerImageInfo, boolean pushRequested) { Containerizer containerizer; - ImageReference imageReference = ImageReference.of(containerImage.getRegistry().orElse(null), - containerImage.getRepository(), containerImage.getTag()); + ImageReference imageReference = ImageReference.of(containerImageInfo.getRegistry().orElse(null), + containerImageInfo.getRepository(), containerImageInfo.getTag()); if (pushRequested || containerImageConfig.isPushExplicitlyEnabled()) { - if (!containerImageConfig.registry.isPresent()) { + if (imageReference.getRegistry() == null) { log.info("No container image registry was set, so 'docker.io' will be used"); } RegistryImage registryImage = toRegistryImage(imageReference, containerImageConfig.username,
['extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java', 'extensions/container-image/container-image-buildpack/deployment/src/main/java/io/quarkus/container/image/buildpack/deployment/BuildpackProcessor.java']
{'.java': 2}
2
2
0
0
2
23,351,225
4,588,369
596,161
5,495
1,371
235
20
2
1,178
154
280
45
0
1
1970-01-01T00:27:47
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,330
quarkusio/quarkus/29036/29017
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29017
https://github.com/quarkusio/quarkus/pull/29036
https://github.com/quarkusio/quarkus/pull/29036
1
fix
Request Context Race condition in quarkus 2.13
### Describe the bug when firing an async CDI Event, the request context from the emitter briefly exists for the observer and is then terminated. This prevents to create a new Request context for the Async observer since the emitter context still exist. This was working in Quarkus 2.12 ### Expected behavior _No response_ ### Actual behavior _No response_ ### How to Reproduce? reproducer: https://github.com/rmanibus/quarkus_29017 execute the ReproducerTest ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
da7477638a01a6b87fe2a4b3d7df1ea4bea14a41
4293f3797365134f84280834167399d37e4c6e5a
https://github.com/quarkusio/quarkus/compare/da7477638a01a6b87fe2a4b3d7df1ea4bea14a41...4293f3797365134f84280834167399d37e4c6e5a
diff --git a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxCoreRecorder.java b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxCoreRecorder.java index 05d88e50dbd..5ac0b5769c9 100644 --- a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxCoreRecorder.java +++ b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxCoreRecorder.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; @@ -42,7 +43,9 @@ import io.quarkus.vertx.core.runtime.config.ClusterConfiguration; import io.quarkus.vertx.core.runtime.config.EventBusConfiguration; import io.quarkus.vertx.core.runtime.config.VertxConfiguration; +import io.quarkus.vertx.core.runtime.context.VertxContextSafetyToggle; import io.quarkus.vertx.mdc.provider.LateBoundMDCProvider; +import io.quarkus.vertx.runtime.VertxCurrentContextFactory; import io.vertx.core.AsyncResult; import io.vertx.core.Context; import io.vertx.core.Handler; @@ -558,7 +561,16 @@ public void runWith(Runnable task, Object context) { ContextInternal currentContext = (ContextInternal) Vertx.currentContext(); if (context != null && context != currentContext) { // Only do context handling if it's non-null - final ContextInternal vertxContext = (ContextInternal) context; + ContextInternal vertxContext = (ContextInternal) context; + // The CDI request context must not be propagated + ConcurrentMap<Object, Object> local = vertxContext.localContextData(); + if (local.containsKey(VertxCurrentContextFactory.LOCAL_KEY)) { + // Duplicate the context, copy the data, remove the request context + vertxContext = vertxContext.duplicate(); + vertxContext.localContextData().putAll(local); + vertxContext.localContextData().remove(VertxCurrentContextFactory.LOCAL_KEY); + VertxContextSafetyToggle.setContextSafe(vertxContext, true); + } vertxContext.beginDispatch(); try { task.run(); diff --git a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxCurrentContextFactory.java b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxCurrentContextFactory.java index a2806ebc628..88db266deac 100644 --- a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxCurrentContextFactory.java +++ b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxCurrentContextFactory.java @@ -14,6 +14,8 @@ public class VertxCurrentContextFactory implements CurrentContextFactory { + public static final String LOCAL_KEY = "io.quarkus.vertx.cdi-current-context"; + @Override public <T extends InjectableContext.ContextState> CurrentContext<T> create(Class<? extends Annotation> scope) { return new VertxCurrentContext<>(); @@ -27,7 +29,7 @@ public <T extends InjectableContext.ContextState> CurrentContext<T> create(Class public T get() { Context context = Vertx.currentContext(); if (context != null && VertxContext.isDuplicatedContext(context)) { - return context.getLocal(this); + return context.getLocal(LOCAL_KEY); } return fallback.get(); } @@ -37,7 +39,7 @@ public void set(T state) { Context context = Vertx.currentContext(); if (context != null && VertxContext.isDuplicatedContext(context)) { VertxContextSafetyToggle.setContextSafe(context, true); - context.putLocal(this, state); + context.putLocal(LOCAL_KEY, state); } else { fallback.set(state); } @@ -48,7 +50,7 @@ public void remove() { Context context = Vertx.currentContext(); if (context != null && VertxContext.isDuplicatedContext(context)) { // NOOP - the DC should not be shared. - // context.removeLocal(this); + // context.removeLocal(LOCAL_KEY); } else { fallback.remove(); }
['extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxCurrentContextFactory.java', 'extensions/vertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/VertxCoreRecorder.java']
{'.java': 2}
2
2
0
0
2
23,394,637
4,596,061
597,077
5,498
1,431
250
22
2
854
118
198
49
1
0
1970-01-01T00:27:47
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,329
quarkusio/quarkus/29094/28783
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/28783
https://github.com/quarkusio/quarkus/pull/29094
https://github.com/quarkusio/quarkus/pull/29094
1
fixes
Hibernate validation fails on a constructor parameter validation
### Describe the bug I am getting a Hibernate exception like the one below when trying to add validation to the bean constructor method like this: ``` @ApplicationScoped public class GrpcMetadataResolver { @Inject public GrpcMetadataResolver(GrpcMetadataConfig config, @SourceApi @Pattern(regexp = "rest|graphql") String sourceApi) { ... } } ``` Removing the `@Pattern(regexp = "rest|graphql") ` makes the injection to work fine. The stack trace from the cause: ``` Caused by: java.lang.IllegalArgumentException: HV000181: Wrong number of parameters. Method or constructor class io.stargate.sgv2.api.common.grpc.GrpcMetadataResolver#GrpcMetadataResolver(GrpcMetadataConfig, String) expects 2 parameters, but got 0. at org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:842) at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:283) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstructorParameters(ValidatorImpl.java:243) at io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor.validateConstructorInvocation(AbstractMethodValidationInterceptor.java:97) at io.quarkus.hibernate.validator.runtime.interceptor.MethodValidationInterceptor.validateConstructorInvocation(MethodValidationInterceptor.java:23) at io.quarkus.hibernate.validator.runtime.interceptor.MethodValidationInterceptor_Bean.intercept(Unknown Source) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42) at io.quarkus.arc.impl.LifecycleCallbackInvocationContext.invokeNext(LifecycleCallbackInvocationContext.java:53) at io.quarkus.arc.impl.LifecycleCallbackInvocationContext.proceed(LifecycleCallbackInvocationContext.java:28) ... 202 more ``` Not sure if there are some config props to handle this behavior? I am sure why would the hibernate go for the no-args constructor here? ### Expected behavior Injection and validation works. ### Actual behavior _No response_ ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` _No response_ ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /home/ise/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 17.0.4, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-52-generic", arch: "amd64", family: "unix" ### Additional information _No response_
a6e4724a5bbfde1be3b6b04c931a99a219579f94
5c8b5a2ce845f43718057ac26485c68d978efcc7
https://github.com/quarkusio/quarkus/compare/a6e4724a5bbfde1be3b6b04c931a99a219579f94...5c8b5a2ce845f43718057ac26485c68d978efcc7
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java index 002135d2146..698525b7650 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java @@ -1428,8 +1428,14 @@ void implementCreateForClassBean(ClassOutput classOutput, ClassCreator beanCreat annotationLiterals.create(create, bindingClass, binding)); } + // ResultHandle of Object[] holding all constructor args + ResultHandle ctorArgsArray = create.newArray(Object.class, create.load(providerHandles.size())); + for (int i = 0; i < providerHandles.size(); i++) { + create.writeArrayValue(ctorArgsArray, i, providerHandles.get(i)); + } ResultHandle invocationContextHandle = create.invokeStaticMethod( MethodDescriptors.INVOCATION_CONTEXTS_AROUND_CONSTRUCT, constructorHandle, + ctorArgsArray, aroundConstructsHandle, func.getInstance(), create.invokeStaticMethod(MethodDescriptors.SETS_OF, bindingsArray)); TryBlock tryCatch = create.tryBlock(); diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java index 5f58546124e..f1762c7db4a 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java @@ -170,7 +170,7 @@ public final class MethodDescriptors { public static final MethodDescriptor INVOCATION_CONTEXTS_AROUND_CONSTRUCT = MethodDescriptor.ofMethod( InvocationContexts.class, "aroundConstruct", - InvocationContext.class, Constructor.class, List.class, Supplier.class, Set.class); + InvocationContext.class, Constructor.class, Object[].class, List.class, Supplier.class, Set.class); public static final MethodDescriptor INVOCATION_CONTEXTS_POST_CONSTRUCT = MethodDescriptor.ofMethod( InvocationContexts.class, diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AroundConstructInvocationContext.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AroundConstructInvocationContext.java index 14056e5afa7..24e4328e540 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AroundConstructInvocationContext.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AroundConstructInvocationContext.java @@ -13,9 +13,9 @@ class AroundConstructInvocationContext extends LifecycleCallbackInvocationContex private final Supplier<Object> aroundConstructForward; - AroundConstructInvocationContext(Constructor<?> constructor, Set<Annotation> interceptorBindings, + AroundConstructInvocationContext(Constructor<?> constructor, Object[] parameters, Set<Annotation> interceptorBindings, List<InterceptorInvocation> chain, Supplier<Object> aroundConstructForward) { - super(null, constructor, interceptorBindings, chain); + super(null, constructor, parameters, interceptorBindings, chain); this.aroundConstructForward = aroundConstructForward; } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InvocationContexts.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InvocationContexts.java index 39db0202169..ef3c6394314 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InvocationContexts.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InvocationContexts.java @@ -42,7 +42,7 @@ public static Object performAroundInvoke(Object target, Method method, */ public static InvocationContext postConstruct(Object target, List<InterceptorInvocation> chain, Set<Annotation> interceptorBindings) { - return new LifecycleCallbackInvocationContext(target, null, interceptorBindings, chain); + return new LifecycleCallbackInvocationContext(target, null, null, interceptorBindings, chain); } /** @@ -54,7 +54,7 @@ public static InvocationContext postConstruct(Object target, List<InterceptorInv */ public static InvocationContext preDestroy(Object target, List<InterceptorInvocation> chain, Set<Annotation> interceptorBindings) { - return new LifecycleCallbackInvocationContext(target, null, interceptorBindings, chain); + return new LifecycleCallbackInvocationContext(target, null, null, interceptorBindings, chain); } /** @@ -65,10 +65,12 @@ public static InvocationContext preDestroy(Object target, List<InterceptorInvoca * @return a new {@link javax.interceptor.AroundConstruct} invocation context */ public static InvocationContext aroundConstruct(Constructor<?> constructor, + Object[] parameters, List<InterceptorInvocation> chain, Supplier<Object> aroundConstructForward, Set<Annotation> interceptorBindings) { - return new AroundConstructInvocationContext(constructor, interceptorBindings, chain, aroundConstructForward); + return new AroundConstructInvocationContext(constructor, parameters, interceptorBindings, chain, + aroundConstructForward); } } diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LifecycleCallbackInvocationContext.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LifecycleCallbackInvocationContext.java index c4cc1bfaac3..6aa8ee4e6e4 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LifecycleCallbackInvocationContext.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LifecycleCallbackInvocationContext.java @@ -15,9 +15,9 @@ class LifecycleCallbackInvocationContext extends AbstractInvocationContext { private int position = 0; - LifecycleCallbackInvocationContext(Object target, Constructor<?> constructor, Set<Annotation> interceptorBindings, - List<InterceptorInvocation> chain) { - super(target, null, constructor, null, null, interceptorBindings, chain); + LifecycleCallbackInvocationContext(Object target, Constructor<?> constructor, Object[] parameters, + Set<Annotation> interceptorBindings, List<InterceptorInvocation> chain) { + super(target, null, constructor, parameters, null, interceptorBindings, chain); } @Override diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/aroundconstruct/AroundConstructTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/aroundconstruct/AroundConstructTest.java index 37a083de51c..b6d8a3706d6 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/aroundconstruct/AroundConstructTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/aroundconstruct/AroundConstructTest.java @@ -1,9 +1,12 @@ package io.quarkus.arc.test.interceptors.aroundconstruct; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.concurrent.atomic.AtomicBoolean; +import javax.inject.Inject; import javax.inject.Singleton; import javax.interceptor.AroundConstruct; import javax.interceptor.Interceptor; @@ -20,7 +23,7 @@ public class AroundConstructTest { @RegisterExtension public ArcTestContainer container = new ArcTestContainer(MyTransactional.class, SimpleBean.class, - SimpleInterceptor.class); + SimpleInterceptor.class, MyDependency.class); public static AtomicBoolean INTERCEPTOR_CALLED = new AtomicBoolean(false); @@ -35,6 +38,25 @@ public void testInterception() { @MyTransactional static class SimpleBean { + @Inject + SimpleBean(MyDependency foo) { + + } + + } + + @Singleton + static class MyDependency { + + long created; + + MyDependency() { + created = System.currentTimeMillis(); + } + + public long getCreated() { + return created; + } } @MyTransactional @@ -44,6 +66,10 @@ public static class SimpleInterceptor { @AroundConstruct void mySuperCoolAroundConstruct(InvocationContext ctx) throws Exception { INTERCEPTOR_CALLED.set(true); + assertTrue(ctx.getParameters().length == 1); + Object param = ctx.getParameters()[0]; + assertTrue(param instanceof MyDependency); + assertEquals(Arc.container().instance(MyDependency.class).get().getCreated(), ((MyDependency) param).getCreated()); ctx.proceed(); }
['independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/MethodDescriptors.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LifecycleCallbackInvocationContext.java', 'independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/aroundconstruct/AroundConstructTest.java', 'independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AroundConstructInvocationContext.java', 'independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InvocationContexts.java']
{'.java': 6}
6
6
0
0
6
23,408,626
4,598,741
597,409
5,502
2,186
379
26
5
2,824
230
671
70
0
2
1970-01-01T00:27:47
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,328
quarkusio/quarkus/29119/28818
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/28818
https://github.com/quarkusio/quarkus/pull/29119
https://github.com/quarkusio/quarkus/pull/29119
1
fix
Incoming HTTP request not being fully read or closed when a constraint validator rejects the request
### Describe the bug Machine: Apple M1 Pro JVM: openjdk 11.0.2 Quarkus: 2.7.4.Final, 2.13.3.Final There seems to be a race condition between reading a request from a TCP socket and constraint validators. When a request gets rejected by a constraint validator (such as `@Consume`) before Quarkus had a chance to fully ACK the incoming request, Quarkus answers back with the appropriate status code and stops reading the request from the TCP socket but doesn't close the connection. This behavior, keeping the connection open but not reading data from the socket, leaves clients in a hanging state after they fully filled the TCP transmission window, waiting for it to be ACK'ed. The client hang may not be observed if the requests are smaller in size, given that in those cases it's likely that the request has been completely received and ACK'ed by Quarkus before the constraint validator had the chance to fire. In these cases, no hanging is observed. ### Expected behavior Quarkus should either read the incoming request fully or close the connection, so as to signal to the client that the request transmission should be over. ### Actual behavior Described in the previous section. Follow the steps below to reproduce. ### How to Reproduce? 1. Create a sample Quarkus application using `quarkus create && cd code-with-quarkus` 2. Add the following endpoint: ```java @Path("/hello") public class GreetingResource { @POST @Consumes({"image/jpeg", "image/png"}) @Produces(MediaType.TEXT_PLAIN) public String hello(byte[] imageFile) { throw new NotAuthorizedException(""); } } ``` 3. Make a request with a large payload (3MB is enough on my machine, Apple M1 Pro) which breaks the `@Consumes` filter by sending a different `Content-Type` header. For your convenience, here's a python snippet that'll do it: ```python import requests import os url = "http://localhost:8080/hello" payload=b"\\x00"+os.urandom(1024 * 1024 * 3)+b"\\x00" headers = { 'Content-Type': 'image/gif' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` At this point, the Python code should hang because the request stream is neither being fully read nor closed by Quarkus. ### Output of `uname -a` or `ver` (macOS M1 Pro) Darwin <REDACTED>.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64 ### Output of `java -version` openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev Reproduced in 2.7.4.Final and 2.13.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 Maven home: /Users/<REDACTED>/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home Default locale: en_PT, platform encoding: UTF-8 OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac" ### Additional information _No response_
81551c59e7bef3c75b392a86323ff605a6729228
23f9abc6e13994edb8b3ab99cf5cf66abb3c604a
https://github.com/quarkusio/quarkus/compare/81551c59e7bef3c75b392a86323ff605a6729228...23f9abc6e13994edb8b3ab99cf5cf66abb3c604a
diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/BasicRestClientTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/BasicRestClientTest.java index 3148c53acf5..ab885f48c38 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/BasicRestClientTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/BasicRestClientTest.java @@ -1,7 +1,10 @@ package io.quarkus.rest.client.reactive; +import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; +import java.time.Duration; import java.util.Map; import java.util.Set; @@ -72,4 +75,23 @@ void shouldMapQueryParamsWithSpecialCharacters() { assertThat(map.get("p5")).isEqualTo("5"); assertThat(map.get("p6")).isEqualTo("6"); } + + /** + * Test to reproduce https://github.com/quarkusio/quarkus/issues/28818. + */ + @Test + void shouldCloseConnectionsWhenFailures() { + // It's using 30 seconds because it's the default timeout to release connections. This timeout should not be taken into + // account when there are failures, and we should be able to call 3 times to the service without waiting. + await().atMost(Duration.ofSeconds(30)) + .until(() -> { + for (int call = 0; call < 3; call++) { + given() + .when().get("/hello/callClientForImageInfo") + .then() + .statusCode(500); + } + return true; + }); + } } diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloClient2.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloClient2.java index 660c55a0260..2c2c31eab34 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloClient2.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloClient2.java @@ -4,6 +4,7 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; @@ -23,4 +24,10 @@ public interface HelloClient2 { @GET @Path("delay") Uni<String> delay(); + + @POST + @Path("/imageInfo") + @Consumes("image/gif") + @Produces(MediaType.TEXT_PLAIN) + String imageInfo(byte[] imageFile); } diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloResource.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloResource.java index f298c0b3030..65b0dc25760 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloResource.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloResource.java @@ -78,4 +78,23 @@ public Uni<String> delay() { return Uni.createFrom().item("Hello") .onItem().delayIt().by(Duration.ofMillis(500)); } + + @Path("callClientForImageInfo") + @GET + public String callClientForImageInfo() { + int size = 1024 * 1024 * 5; + + byte[] buffer = new byte[size]; + + //Should provoke 415 Unsupported Media Type + return client2.imageInfo(buffer); + } + + @POST + @Consumes({ "image/jpeg", "image/png" }) + @Path("/imageInfo") + @Produces(MediaType.TEXT_PLAIN) + public String imageInfo(byte[] imageFile) { + throw new IllegalStateException("This method should never be invoked"); + } } diff --git a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java index 8d1d7d62c3c..2bf3f434ecb 100644 --- a/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java +++ b/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java @@ -20,6 +20,7 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import javax.ws.rs.core.Variant; import org.jboss.logging.Logger; @@ -243,6 +244,11 @@ public void handle(HttpClientResponse clientResponse) { } } + if (Response.Status.Family.familyOf(status) != Response.Status.Family.SUCCESSFUL) { + httpClientRequest.connection().close(); + requestContext.resume(); + } + if (isResponseMultipart(requestContext)) { QuarkusMultipartResponseDecoder multipartDecoder = new QuarkusMultipartResponseDecoder( clientResponse); @@ -366,17 +372,16 @@ public void handle(Buffer buffer) { requestContext.resume(t); } } - }) - .onFailure(new Handler<>() { - @Override - public void handle(Throwable failure) { - if (failure instanceof IOException) { - requestContext.resume(new ProcessingException(failure)); - } else { - requestContext.resume(failure); - } - } - }); + }).onFailure(new Handler<>() { + @Override + public void handle(Throwable failure) { + if (failure instanceof IOException) { + requestContext.resume(new ProcessingException(failure)); + } else { + requestContext.resume(failure); + } + } + }); } private boolean isResponseMultipart(RestClientRequestContext requestContext) {
['extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloResource.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/HelloClient2.java', 'independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/handlers/ClientSendRequestHandler.java', 'extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/BasicRestClientTest.java']
{'.java': 4}
4
4
0
0
4
23,408,191
4,598,586
597,404
5,502
1,119
155
27
1
3,297
445
884
82
1
2
1970-01-01T00:27:47
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,327
quarkusio/quarkus/29121/29089
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29089
https://github.com/quarkusio/quarkus/pull/29121
https://github.com/quarkusio/quarkus/pull/29121
1
fix
Panache project() is not working if used with distinct + case-sensitive HQL query
### Describe the bug For an entity that has getter defined with camelCase attribute name ie: `myId` executing query: ```java Data.find("SELECT DISTINCT d.myId FROM Data d", Sort.by("myId")) .project(Long.class) .list(); ``` will result in: ``` Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: myid of: de.turing85.panache.projection.entity.Data [select distinct new java.lang.Long(d.myid) FROM de.turing85.panache.projection.entity.Data d ORDER BY myId] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114) at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createQuery(TransactionScopedSession.java:349) at org.hibernate.engine.spi.SessionLazyDelegator.createQuery(SessionLazyDelegator.java:547) ``` The issue is probably here: https://github.com/quarkusio/quarkus/blob/8e4ee686b538e8cb7cbb402ef084ef0925fb83cf/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java#L104 ### Expected behavior Distinct query should work with HQL compliant query. ### Actual behavior It does not work, an exception is raised. ``` Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: myid of: de.turing85.panache.projection.entity.Data [select distinct new java.lang.Long(d.myid) FROM de.turing85.panache.projection.entity.Data d ORDER BY myId] at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757) at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114) at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.createQuery(TransactionScopedSession.java:349) at org.hibernate.engine.spi.SessionLazyDelegator.createQuery(SessionLazyDelegator.java:547) ``` ### How to Reproduce? https://github.com/turing85/quarkus-panache-projection/tree/reanme-id-to-myId Check this line: https://github.com/turing85/quarkus-panache-projection/blob/reanme-id-to-myId/src/main/java/de/turing85/panache/projection/DataResource.java#L36 ### Output of `uname -a` or `ver` Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 ### Output of `java -version` openjdk version "19" 2022-09-20 OpenJDK Runtime Environment Homebrew (build 19) OpenJDK 64-Bit Server VM Homebrew (build 19, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /Users/jasminsuljic/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 19, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/19/libexec/openjdk.jdk/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "12.6", arch: "x86_64", family: "mac" ### Additional information _No response_
f29b28887af4b50e7484dd1faf252b15f1a9f61a
9becd8a405673589c9bfbe00976ef0558fced3bc
https://github.com/quarkusio/quarkus/compare/f29b28887af4b50e7484dd1faf252b15f1a9f61a...9becd8a405673589c9bfbe00976ef0558fced3bc
diff --git a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java b/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java index 894357ec8a0..70bfb1a8033 100644 --- a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java +++ b/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java @@ -95,15 +95,14 @@ public <T> CommonPanacheQueryImpl<T> project(Class<T> type) { int endSelect = lowerCasedTrimmedQuery.indexOf(" from "); String trimmedQuery = query.trim(); // 7 is the length of "select " - String selectClause = trimmedQuery.substring(7, endSelect); + String selectClause = trimmedQuery.substring(7, endSelect).trim(); String from = trimmedQuery.substring(endSelect); StringBuilder newQuery = new StringBuilder("select "); // Handle select-distinct. HQL example: select distinct new org.acme.ProjectionClass... - String lowerCasedTrimmedSelect = selectClause.trim().toLowerCase(); - boolean distinctQuery = lowerCasedTrimmedSelect.startsWith("distinct "); + boolean distinctQuery = selectClause.toLowerCase().startsWith("distinct "); if (distinctQuery) { // 9 is the length of "distinct " - selectClause = lowerCasedTrimmedSelect.substring(9).trim(); + selectClause = selectClause.substring(9).trim(); newQuery.append("distinct "); } diff --git a/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/CommonPanacheQueryImpl.java b/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/CommonPanacheQueryImpl.java index 3623f2ee25c..96896088c52 100644 --- a/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/CommonPanacheQueryImpl.java +++ b/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/CommonPanacheQueryImpl.java @@ -82,15 +82,14 @@ public <T> CommonPanacheQueryImpl<T> project(Class<T> type) { int endSelect = lowerCasedTrimmedQuery.indexOf(" from "); String trimmedQuery = query.trim(); // 7 is the length of "select " - String selectClause = trimmedQuery.substring(7, endSelect); + String selectClause = trimmedQuery.substring(7, endSelect).trim(); String from = trimmedQuery.substring(endSelect); StringBuilder newQuery = new StringBuilder("select "); // Handle select-distinct. HQL example: select distinct new org.acme.ProjectionClass... - String lowerCasedTrimmedSelect = selectClause.trim().toLowerCase(); - boolean distinctQuery = lowerCasedTrimmedSelect.startsWith("distinct "); + boolean distinctQuery = selectClause.toLowerCase().startsWith("distinct "); if (distinctQuery) { // 9 is the length of "distinct " - selectClause = lowerCasedTrimmedSelect.substring(9).trim(); + selectClause = selectClause.substring(9).trim(); newQuery.append("distinct "); } diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java index 2641e034de2..363fd589281 100644 --- a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java +++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java @@ -1253,6 +1253,18 @@ public String testProjection() { long countDistinct = projectionDistinctQuery.count(); Assertions.assertEquals(1L, countDistinct); + // We are checking that not everything gets lowercased + PanacheQuery<CatProjectionBean> letterCaseQuery = Cat + // The spaces at the beginning are intentional + .find(" SELECT disTINct 'GARFIELD', 'JoN ArBuCkLe' from Cat c where name = :NamE group by name ", + Parameters.with("NamE", bubulle.name)) + .project(CatProjectionBean.class); + + CatProjectionBean catView = letterCaseQuery.firstResult(); + // Must keep the letter case + Assertions.assertEquals("GARFIELD", catView.getName()); + Assertions.assertEquals("JoN ArBuCkLe", catView.getOwnerName()); + Cat.deleteAll(); CatOwner.deleteAll(); diff --git a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/TestEndpoint.java b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/TestEndpoint.java index fb50b9a4287..7046f84404e 100644 --- a/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/TestEndpoint.java +++ b/integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/TestEndpoint.java @@ -1675,6 +1675,16 @@ public Uni<String> testProjection2() { Assertions.assertTrue( exception.getMessage().startsWith("Unable to perform a projection on a 'select new' query")); }) + .chain(() -> Cat + .find(" SELECT disTINct 'GARFIELD', 'JoN ArBuCkLe' from Cat c where name = :NamE group by name ", + Parameters.with("NamE", catName)) + .project(CatProjectionBean.class) + .<CatProjectionBean> firstResult()) + .invoke(catView -> { + // Must keep the letter case + Assertions.assertEquals("GARFIELD", catView.name); + Assertions.assertEquals("JoN ArBuCkLe", catView.ownerName); + }) .replaceWith("OK"); }
['extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/CommonPanacheQueryImpl.java', 'extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java', 'integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java', 'integration-tests/hibernate-reactive-panache/src/main/java/io/quarkus/it/panache/reactive/TestEndpoint.java']
{'.java': 4}
4
4
0
0
4
23,474,147
4,612,156
598,915
5,524
1,102
202
14
2
3,950
250
961
70
3
3
1970-01-01T00:27:47
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,326
quarkusio/quarkus/29159/29157
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29157
https://github.com/quarkusio/quarkus/pull/29159
https://github.com/quarkusio/quarkus/pull/29159
1
fix
Make @TransactionScoped thread safe (virtual and platform threads)
### Describe the bug When a `@TransactionScoped` bean is accessed inside a transaction for a first time from 2 virtual threads started by the thread that started the transaction (e.g. StructuredTaskScope forks), a race condition can lead to two instances of the bean being created. The transaction context is properly propagated to the virtual threads by smallrye-context-propagation callable wrapping. ### Expected behavior A reentrantlock is expected to be locked before line https://github.com/quarkusio/quarkus/blob/main/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java#L110 and released after getting the bean. ### Actual behavior No locking is done in `TransactionalContext`, thus a race condition can create two beans ### How to Reproduce? 1. Define a `TransactionScoped` bean 2. Create another bean with a method with `@Transactional` annotation 3. Start 2 virtual threads from that method, e.g. using StrucuredTaskScope.fork(), with proper context propagation (smallrye) 4. From the 2 virtual threads, access a method on the `TransactionScoped` bean 5. Call the `@Transactional` method Repeat a lot of times and watch for multiple bean creation per method call. ```java @Inject TransactionScopedBean myBean; @Transactional public void foo() { try(var scope = new StrucuredTaskScope.ShutdownOnFailure()) { scope.fork(wrapWithContext(()->myBean.something())); // race condition may occur here scope.fork(wrapWithContext(()->myBean.something())); // race condition may occur here scope.join(); } } ``` ### Output of `uname -a` or `ver` all platforms ### Output of `java -version` 19 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.3.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) all build tools ### Additional information _No response_
3baf6cc39bc7715ffd67f63cc0c5fa11b6e676d3
700950cea39da0b787944731f38e0ff8053fb2ff
https://github.com/quarkusio/quarkus/compare/3baf6cc39bc7715ffd67f63cc0c5fa11b6e676d3...700950cea39da0b787944731f38e0ff8053fb2ff
diff --git a/extensions/narayana-jta/deployment/src/test/java/io/quarkus/narayana/quarkus/QuarkusTransactionTest.java b/extensions/narayana-jta/deployment/src/test/java/io/quarkus/narayana/quarkus/QuarkusTransactionTest.java index 83b77c91ea8..b25237f4b2b 100644 --- a/extensions/narayana-jta/deployment/src/test/java/io/quarkus/narayana/quarkus/QuarkusTransactionTest.java +++ b/extensions/narayana-jta/deployment/src/test/java/io/quarkus/narayana/quarkus/QuarkusTransactionTest.java @@ -3,17 +3,24 @@ import static io.quarkus.narayana.jta.QuarkusTransaction.beginOptions; import static io.quarkus.narayana.jta.QuarkusTransaction.runOptions; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import javax.enterprise.context.ContextNotActiveException; import javax.enterprise.context.control.ActivateRequestContext; +import javax.enterprise.inject.Produces; import javax.inject.Inject; +import javax.inject.Singleton; import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.Synchronization; import javax.transaction.SystemException; import javax.transaction.TransactionManager; +import javax.transaction.TransactionScoped; +import org.eclipse.microprofile.context.ThreadContext; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Assertions; @@ -28,9 +35,17 @@ public class QuarkusTransactionTest { + private static AtomicInteger counter = new AtomicInteger(); + @Inject TransactionManager transactionManager; + @Inject + ThreadContext threadContext; + + @Inject + TransactionScopedTestBean testBean; + @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); @@ -224,6 +239,31 @@ public void testCallJoinExisting() throws SystemException { }); } + @Test + public void testConcurrentTransactionScopedBeanCreation() { + // 1. A Transaction is activated in a parent thread. + QuarkusTransaction.run(() -> { + ExecutorService executor = Executors.newCachedThreadPool(); + try { + // 2. The parent thread starts 2 child threads, and propagates the transaction. + // 3. The child threads access a @TransactionScoped bean concurrently, + // which has resource intensive producer simulated by sleep. + var f1 = executor.submit(threadContext.contextualRunnable(() -> testBean.doWork())); + var f2 = executor.submit(threadContext.contextualRunnable(() -> testBean.doWork())); + + f1.get(); + f2.get(); + } catch (Throwable e) { + throw new AssertionError("Should not have thrown", e); + } finally { + executor.shutdownNow(); + } + }); + + // 4. The race condition is handled correctly, the bean is only created once. + Assertions.assertEquals(1, counter.get()); + } + TestSync register() { TestSync t = new TestSync(); try { @@ -249,4 +289,25 @@ public void afterCompletion(int status) { } } + static class TransactionScopedTestBean { + public void doWork() { + + } + } + + @Singleton + static class TransactionScopedTestBeanCreator { + + @Produces + @TransactionScoped + TransactionScopedTestBean transactionScopedTestBean() { + try { + Thread.sleep(100); + } catch (Exception e) { + + } + counter.incrementAndGet(); + return new TransactionScopedTestBean(); + } + } } diff --git a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java index 9553ead1858..f8fe96f29ff 100644 --- a/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java +++ b/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java @@ -4,6 +4,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -34,6 +36,8 @@ public class TransactionContext implements InjectableContext { // marker object to be put as a key for SynchronizationRegistry to gather all beans created in the scope private static final Object TRANSACTION_CONTEXT_MARKER = new Object(); + private final Lock transactionLock = new ReentrantLock(); + private final LazyValue<TransactionSynchronizationRegistry> transactionSynchronizationRegistry = new LazyValue<>( new Supplier<TransactionSynchronizationRegistry>() { @Override @@ -107,26 +111,45 @@ public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContex throw new IllegalArgumentException("Contextual parameter must not be null"); } + TransactionSynchronizationRegistry registryInstance = transactionSynchronizationRegistry.get(); TransactionContextState contextState; - contextState = (TransactionContextState) transactionSynchronizationRegistry.get() - .getResource(TRANSACTION_CONTEXT_MARKER); - if (contextState == null) { - contextState = new TransactionContextState(getCurrentTransaction()); - transactionSynchronizationRegistry.get().putResource(TRANSACTION_CONTEXT_MARKER, contextState); + // Prevent concurrent contextState creation from multiple threads sharing the same transaction, + // since TransactionSynchronizationRegistry has no atomic compute if absent mechanism. + transactionLock.lock(); + + try { + contextState = (TransactionContextState) registryInstance.getResource(TRANSACTION_CONTEXT_MARKER); + + if (contextState == null) { + contextState = new TransactionContextState(getCurrentTransaction()); + registryInstance.putResource(TRANSACTION_CONTEXT_MARKER, contextState); + } + + } finally { + transactionLock.unlock(); } ContextInstanceHandle<T> instanceHandle = contextState.get(contextual); if (instanceHandle != null) { return instanceHandle.get(); } else if (creationalContext != null) { - T createdInstance = contextual.create(creationalContext); - instanceHandle = new ContextInstanceHandleImpl<>((InjectableBean<T>) contextual, createdInstance, - creationalContext); - - contextState.put(contextual, instanceHandle); + Lock beanLock = contextState.getLock(); + beanLock.lock(); + try { + instanceHandle = contextState.get(contextual); + if (instanceHandle != null) { + return instanceHandle.get(); + } - return createdInstance; + T createdInstance = contextual.create(creationalContext); + instanceHandle = new ContextInstanceHandleImpl<>((InjectableBean<T>) contextual, createdInstance, + creationalContext); + contextState.put(contextual, instanceHandle); + return createdInstance; + } finally { + beanLock.unlock(); + } } else { return null; } @@ -175,6 +198,8 @@ private Transaction getCurrentTransaction() { */ private static class TransactionContextState implements ContextState, Synchronization { + private final Lock lock = new ReentrantLock(); + private final ConcurrentMap<Contextual<?>, ContextInstanceHandle<?>> mapBeanToInstanceHandle = new ConcurrentHashMap<>(); TransactionContextState(Transaction transaction) { @@ -246,5 +271,14 @@ public void beforeCompletion() { public void afterCompletion(int status) { this.destroy(); } + + /** + * Gets the lock associated with this ContextState for synchronization purposes + * + * @return the lock for this ContextState + */ + public Lock getLock() { + return lock; + } } }
['extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java', 'extensions/narayana-jta/deployment/src/test/java/io/quarkus/narayana/quarkus/QuarkusTransactionTest.java']
{'.java': 2}
2
2
0
0
2
23,731,321
4,666,286
605,716
5,573
2,622
428
56
1
1,976
245
452
58
1
1
1970-01-01T00:27:48
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,325
quarkusio/quarkus/29201/29188
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29188
https://github.com/quarkusio/quarkus/pull/29201
https://github.com/quarkusio/quarkus/pull/29201
1
fixes
IsDockerWorking not using TestContainersStrategy after 2.13.4.Final
### Describe the bug There is a regression in the class `IsDockerWorking`, it was detected running on GitLab CI using the docker socket configuration: https://www.testcontainers.org/supported_docker_environment/continuous_integration/gitlab_ci/ The first strategy should be using the `TestContainersStrategy` and is able to detect the socket correctly. I tested it with and without a `~/.testcontainers.properties`, but it's the same behavior. The only related change is https://github.com/quarkusio/quarkus/pull/28702 cc: @geoand ### Expected behavior Running Quarkus 2.13.3.Final: ``` 2022-11-10 18:36:35,116 DEBUG [io.qua.dep.IsDockerWorking] (build-40) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$TestContainersStrategy 2022-11-10 18:36:35,161 INFO [org.tes.doc.DockerClientProviderStrategy] (build-40) Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first 2022-11-10 18:36:36,001 INFO [org.tes.doc.DockerClientProviderStrategy] (build-40) Found Docker environment with local Unix socket (unix:///var/run/docker.sock) ``` Only the TestContainersStrategy runs and works correctly. ### Actual behavior Running Quarkus 2.13.3.Final and 2.14.0.Final: On the docker.sock mounted CI pipeline failing: ``` 2022-11-10 17:19:04,262 DEBUG [io.qua.dep.IsDockerWorking] (build-8) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$TestContainersStrategy 2022-11-10 17:19:04,285 DEBUG [io.qua.dep.IsDockerWorking] (build-8) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$DockerHostStrategy 2022-11-10 17:19:04,286 DEBUG [io.qua.dep.IsDockerWorking] (build-8) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$DockerBinaryStrategy 2022-11-10 17:19:04,321 WARN [io.qua.dep.IsDockerWorking] (build-8) No docker binary found or general error: java.lang.RuntimeException: Input/Output error while executing command. ``` On my local laptop fallback to using the docker binary detection: ``` 2022-11-10 18:21:17,864 DEBUG [io.qua.dep.IsDockerWorking] (build-36) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$TestContainersStrategy 2022-11-10 18:21:17,886 DEBUG [io.qua.dep.IsDockerWorking] (build-36) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$DockerHostStrategy 2022-11-10 18:21:17,887 DEBUG [io.qua.dep.IsDockerWorking] (build-36) Checking Docker Environment using strategy io.quarkus.deployment.IsDockerWorking$DockerBinaryStrategy 2022-11-10 18:21:17,969 DEBUG [io.qua.dep.IsDockerWorking] (build-36) Docker daemon found. Version: '20.10.21' 2022-11-10 18:21:17,987 INFO [org.tes.uti.ImageNameSubstitutor] (build-36) Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor') 2022-11-10 18:21:18,007 INFO [org.tes.doc.DockerClientProviderStrategy] (build-36) Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first 2022-11-10 18:21:18,816 INFO [org.tes.doc.DockerClientProviderStrategy] (build-36) Found Docker environment with local Unix socket (unix:///var/run/docker.sock) ``` It runs the strategies TestContainersStrategy, DockerHostStrategy, DockerBinaryStrategy... here it works since it find the docker binary, yet TestContainers is using the UnixSocketClientProviderStrategy. ### How to Reproduce? _No response_ ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` openjdk 17.0.5 2022-10-18 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.13.4.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.6 ### Additional information _No response_
16adf2c5f6c0082959fffdefbf192ebd35498751
eac0e5eb11dd218d57e89c85e144b565012724ab
https://github.com/quarkusio/quarkus/compare/16adf2c5f6c0082959fffdefbf192ebd35498751...eac0e5eb11dd218d57e89c85e144b565012724ab
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java index 333d3563645..de3618be44a 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java @@ -84,7 +84,7 @@ public Result get() { Class<?> configurationClass = Thread.currentThread().getContextClassLoader() .loadClass("org.testcontainers.utility.TestcontainersConfiguration"); - Object configurationInstance = configurationClass.getMethod("instance").invoke(null); + Object configurationInstance = configurationClass.getMethod("getInstance").invoke(null); String oldReusePropertyValue = (String) configurationClass .getMethod("getUserProperty", String.class, String.class) .invoke(configurationInstance, "testcontainers.reuse.enable", "false"); // use the default provided in TestcontainersConfiguration#environmentSupportsReuse
['core/deployment/src/main/java/io/quarkus/deployment/IsDockerWorking.java']
{'.java': 1}
1
1
0
0
1
23,490,655
4,615,364
599,328
5,529
208
28
2
1
3,966
362
1,083
75
2
3
1970-01-01T00:27:48
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,323
quarkusio/quarkus/29216/29215
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29215
https://github.com/quarkusio/quarkus/pull/29216
https://github.com/quarkusio/quarkus/pull/29216
1
fixes
Kafka complaining about common unknown properties, regression in 2.14
### Describe the bug Kafka complaining about common unknown properties, it's a regression, we had fix https://github.com/quarkusio/quarkus/pull/22504 since 2.6 Seems the message slightly changed in the latest Kafka client version. ``` 2022-11-11 15:28:27,279 WARN [org.apa.kaf.cli.con.ConsumerConfig] (Quarkus Main Thread) These configurations '[wildfly.sasl.relax-compliance]' were supplied but are not used yet. 2022-11-11 15:28:27,334 WARN [org.apa.kaf.cli.pro.ProducerConfig] (Quarkus Main Thread) These configurations '[wildfly.sasl.relax-compliance]' were supplied but are not used yet. ``` ### Expected behavior Warning is deffered ### Actual behavior Warning about `wildfly.sasl.relax-compliance` ### How to Reproduce? Run app with kafka client ### Output of `uname -a` or `ver` macOS ### Output of `java -version` Java 17 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.14.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
a4a9c3996009271b15b64c0d12102d979fce7801
2304d4d16a12dbefc3cd532bf2c8f89f4f15cb1f
https://github.com/quarkusio/quarkus/compare/a4a9c3996009271b15b64c0d12102d979fce7801...2304d4d16a12dbefc3cd532bf2c8f89f4f15cb1f
diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java index c29791d4215..ecabb78aeb7 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java @@ -179,7 +179,7 @@ void silenceUnwantedConfigLogs(BuildProducer<LogCleanupFilterBuildItem> logClean List<String> ignoredMessages = new ArrayList<>(); for (String ignoredConfigProperty : ignoredConfigProperties) { ignoredMessages - .add("The configuration '" + ignoredConfigProperty + "' was supplied but isn't a known config."); + .add("These configurations '[" + ignoredConfigProperty + "]' were supplied but are not used yet."); } logCleanupFilters.produce(new LogCleanupFilterBuildItem("org.apache.kafka.clients.consumer.ConsumerConfig",
['extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java']
{'.java': 1}
1
1
0
0
1
23,479,417
4,613,179
599,126
5,528
239
45
2
1
1,089
136
297
46
1
1
1970-01-01T00:27:48
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,322
quarkusio/quarkus/29276/29206
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29206
https://github.com/quarkusio/quarkus/pull/29276
https://github.com/quarkusio/quarkus/pull/29276
1
fixes
spring-di - WARN Failed to index org.osgi.annotation.bundle.Requirements
### Describe the bug spring-di - WARN Failed to index org.osgi.annotation.bundle.Requirements This wasn't happening in previous Quarkus releases ``` mvn quarkus:dev ... 2022-11-11 15:04:25,550 WARN [io.qua.arc.pro.BeanArchives] (build-9) Failed to index org.osgi.annotation.bundle.Requirements: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@2b4bac49 ... ``` ### Expected behavior No warning ### Actual behavior `2022-11-11 14:57:43,349 WARN [io.qua.arc.pro.BeanArchives] (build-13) Failed to index org.osgi.annotation.bundle.Requirements: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@50a7bc6e` ### How to Reproduce? - generate app which is using `spring-di` - run `mvn quarkus:dev` - check the log ### Output of `uname -a` or `ver` macOS ### Output of `java -version` Java 11 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.14.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information _No response_
0ba80a877aa3b11ce83109e2f03bbc777142e06b
7eb85caa37b5b3e1ec83e1825fe8587435ca39e1
https://github.com/quarkusio/quarkus/compare/0ba80a877aa3b11ce83109e2f03bbc777142e06b...7eb85caa37b5b3e1ec83e1825fe8587435ca39e1
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java index d0d4cbee7f0..c3be954fafd 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java @@ -12,6 +12,7 @@ import java.nio.file.Path; import java.util.Collections; import java.util.Enumeration; +import java.util.HashSet; import java.util.Set; import java.util.function.Function; import java.util.jar.JarEntry; @@ -131,6 +132,11 @@ private static Index indexJar(JarFile file, Set<String> removed) throws IOExcept public static void indexClass(String className, Indexer indexer, IndexView quarkusIndex, Set<DotName> additionalIndex, ClassLoader classLoader) { + indexClass(className, indexer, quarkusIndex, additionalIndex, new HashSet<>(), classLoader); + } + + public static void indexClass(String className, Indexer indexer, IndexView quarkusIndex, + Set<DotName> additionalIndex, Set<DotName> knownMissingClasses, ClassLoader classLoader) { DotName classDotName = DotName.createSimple(className); if (additionalIndex.contains(classDotName)) { return; @@ -162,10 +168,11 @@ public static void indexClass(String className, Indexer indexer, IndexView quark try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) { if (annotationStream == null) { log.debugf("Could not index annotation: %s (missing class or dependency)", annotationName); + knownMissingClasses.add(annotationName); } else { log.debugf("Index annotation: %s", annotationName); - indexer.index(annotationStream); - additionalIndex.add(annotationName); + indexClass(annotationName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses, + classLoader); } } catch (IOException e) { throw new IllegalStateException("Failed to index: " + className, e); @@ -173,12 +180,17 @@ public static void indexClass(String className, Indexer indexer, IndexView quark } } if (superclassName != null && !superclassName.equals(OBJECT)) { - indexClass(superclassName.toString(), indexer, quarkusIndex, additionalIndex, classLoader); + indexClass(superclassName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses, classLoader); } } public static void indexClass(String className, Indexer indexer, - IndexView quarkusIndex, Set<DotName> additionalIndex, + IndexView quarkusIndex, Set<DotName> additionalIndex, ClassLoader classLoader, byte[] beanData) { + indexClass(className, indexer, quarkusIndex, additionalIndex, new HashSet<>(), classLoader, beanData); + } + + public static void indexClass(String className, Indexer indexer, + IndexView quarkusIndex, Set<DotName> additionalIndex, Set<DotName> knownMissingClasses, ClassLoader classLoader, byte[] beanData) { DotName classDotName = DotName.createSimple(className); if (additionalIndex.contains(classDotName)) { @@ -206,9 +218,15 @@ public static void indexClass(String className, Indexer indexer, for (DotName annotationName : annotationNames) { if (!additionalIndex.contains(annotationName) && quarkusIndex.getClassByName(annotationName) == null) { try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) { - log.debugf("Index annotation: %s", annotationName); - indexer.index(annotationStream); - additionalIndex.add(annotationName); + if (annotationStream == null) { + log.debugf("Could not index annotation: %s (missing class or dependency)", annotationName); + knownMissingClasses.add(annotationName); + } else { + log.debugf("Index annotation: %s", annotationName); + indexClass(annotationName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses, + classLoader); + additionalIndex.add(annotationName); + } } catch (IOException e) { throw new IllegalStateException("Failed to index: " + className, e); } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java index 922b36d759f..cc4cc69774c 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java @@ -3,8 +3,11 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.Set; +import org.jboss.jandex.ClassInfo; import org.jboss.jandex.CompositeIndex; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; @@ -37,11 +40,12 @@ CombinedIndexBuildItem build(ApplicationArchivesBuildItem archives, Indexer indexer = new Indexer(); Set<DotName> additionalIndex = new HashSet<>(); + Set<DotName> knownMissingClasses = new HashSet<>(); for (AdditionalIndexedClassesBuildItem additionalIndexedClasses : additionalIndexedClassesItems) { for (String classToIndex : additionalIndexedClasses.getClassesToIndex()) { IndexingUtil.indexClass(classToIndex, indexer, archivesIndex, additionalIndex, - Thread.currentThread().getContextClassLoader()); + knownMissingClasses, Thread.currentThread().getContextClassLoader()); } } @@ -51,6 +55,11 @@ CombinedIndexBuildItem build(ApplicationArchivesBuildItem archives, liveReloadBuildItem.setContextObject(PersistentClassIndex.class, index); } + Map<DotName, Optional<ClassInfo>> additionalClasses = index.getAdditionalClasses(); + for (DotName knownMissingClass : knownMissingClasses) { + additionalClasses.put(knownMissingClass, Optional.empty()); + } + CompositeIndex compositeIndex = CompositeIndex.create(archivesIndex, indexer.complete()); RuntimeUpdatesProcessor.setLastStartIndex(compositeIndex); return new CombinedIndexBuildItem(compositeIndex, diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java index 3a050a14239..29283e4df95 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -11,6 +12,7 @@ import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget.Kind; +import org.jboss.jandex.ClassInfo; import org.jboss.jandex.CompositeIndex; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; @@ -57,15 +59,15 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil // Build the index for additional beans and generated bean classes Set<DotName> additionalIndex = new HashSet<>(); + Set<DotName> knownMissingClasses = new HashSet<>(); for (String beanClass : additionalBeanClasses) { IndexingUtil.indexClass(beanClass, additionalBeanIndexer, applicationIndex, additionalIndex, - Thread.currentThread().getContextClassLoader()); + knownMissingClasses, Thread.currentThread().getContextClassLoader()); } Set<DotName> generatedClassNames = new HashSet<>(); for (GeneratedBeanBuildItem generatedBeanClass : generatedBeans) { IndexingUtil.indexClass(generatedBeanClass.getName(), additionalBeanIndexer, applicationIndex, additionalIndex, - Thread.currentThread().getContextClassLoader(), - generatedBeanClass.getData()); + knownMissingClasses, Thread.currentThread().getContextClassLoader(), generatedBeanClass.getData()); generatedClassNames.add(DotName.createSimple(generatedBeanClass.getName().replace('/', '.'))); generatedClass.produce(new GeneratedClassBuildItem(true, generatedBeanClass.getName(), generatedBeanClass.getData(), generatedBeanClass.getSource())); @@ -77,9 +79,14 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil liveReloadBuildItem.setContextObject(PersistentClassIndex.class, index); } + Map<DotName, Optional<ClassInfo>> additionalClasses = index.getAdditionalClasses(); + for (DotName knownMissingClass : knownMissingClasses) { + additionalClasses.put(knownMissingClass, Optional.empty()); + } + // Finally, index ArC/CDI API built-in classes return new BeanArchiveIndexBuildItem( - BeanArchives.buildBeanArchiveIndex(Thread.currentThread().getContextClassLoader(), index.getAdditionalClasses(), + BeanArchives.buildBeanArchiveIndex(Thread.currentThread().getContextClassLoader(), additionalClasses, applicationIndex, additionalBeanIndexer.complete()), generatedClassNames); diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java index b2a7320b751..bd14d9e679f 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java @@ -55,12 +55,11 @@ public final class BeanArchives { * @return the final bean archive index */ public static IndexView buildBeanArchiveIndex(ClassLoader deploymentClassLoader, - Map<DotName, Optional<ClassInfo>> persistentClassIndex, - IndexView... applicationIndexes) { + Map<DotName, Optional<ClassInfo>> additionalClasses, IndexView... applicationIndexes) { List<IndexView> indexes = new ArrayList<>(); Collections.addAll(indexes, applicationIndexes); indexes.add(buildAdditionalIndex()); - return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, persistentClassIndex); + return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, additionalClasses); } private static IndexView buildAdditionalIndex() {
['independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java', 'extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java', 'core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java', 'core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java']
{'.java': 4}
4
4
0
0
4
23,686,610
4,657,843
604,717
5,556
4,188
717
63
4
1,118
138
309
50
0
1
1970-01-01T00:27:48
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,321
quarkusio/quarkus/29314/29312
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29312
https://github.com/quarkusio/quarkus/pull/29314
https://github.com/quarkusio/quarkus/pull/29314
1
fixes
NPE thrown when trying to connect to existing Keycloak devservice
### Describe the bug We have a setup where we got multiple Quarkus apps working together. As such, when starting it locally in development mode, we rely on devservices provided by Quarkus and share the Keycloak instance. We do not really configure anything on the devservice except fixing the port and this was working fine before Quarkus 2.14.0.Final. After the update, we keep getting the following error: > Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.util.List.isEmpty()" because "realmReps" is null at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:247) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909) at io.quarkus.builder.BuildContext.run(BuildContext.java:281) at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) at java.base/java.lang.Thread.run(Thread.java:833) at org.jboss.threads.JBossThread.run(JBossThread.java:501) Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.isEmpty()" because "realmReps" is null at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.prepareConfiguration(KeycloakDevServicesProcessor.java:262) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.lambda$startContainer$5(KeycloakDevServicesProcessor.java:389) at java.base/java.util.Optional.map(Optional.java:260) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startContainer(KeycloakDevServicesProcessor.java:387) at io.quarkus.oidc.deployment.devservices.keycloak.KeycloakDevServicesProcessor.startKeycloakContainer(KeycloakDevServicesProcessor.java:195) ... 11 more Looking at the code history we determined that the bug was introduced by the following PR: https://github.com/quarkusio/quarkus/pull/28327/files#diff-67404a43520250b1ebd5a0c945e070e60d70d4a3ba06b15e3fac747f820320cc in KeycloakDevServicesProcessor.java, line 259. Previously, there was a check if `realmRep` is `null` (which is always the case when dev service is shared - [check the call](https://github.com/quarkusio/quarkus/blob/c9e00898b30be0ed710087522da58b294bed6834/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java#L389)). This is blocking us to update to new version and for now have reverted to the old one. ### Expected behavior Multiple Quarkus apps should be able to share the same Keycloak instance in dev mode. ### Actual behavior NPE occurs when existing Keycloak instance is detected. ### How to Reproduce? Start two separate Quarkus Apps in dev mode that both make use of Keycloak devservice. ### Output of `uname -a` or `ver` Linux-ubuntu 5.15.0-52-generic ### Output of `java -version` openjdk version "17.0.5" 2022-10-18 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.14.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Gradle 7.5.1 ### Additional information _No response_
921193cf5338b675327c58dcd40f2b22a7a30aa1
45044b38219bae5bcbbd58e3c42db5082b0cf78d
https://github.com/quarkusio/quarkus/compare/921193cf5338b675327c58dcd40f2b22a7a30aa1...45044b38219bae5bcbbd58e3c42db5082b0cf78d
diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index a37d73eb4be..c7c1674c8f2 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -259,7 +259,8 @@ private Map<String, String> prepareConfiguration( BuildProducer<KeycloakDevServicesConfigBuildItem> keycloakBuildItemBuildProducer, String internalURL, String hostURL, List<RealmRepresentation> realmReps, boolean keycloakX, List<String> errors) { - final String realmName = !realmReps.isEmpty() ? realmReps.iterator().next().getRealm() : getDefaultRealmName(); + final String realmName = realmReps != null && !realmReps.isEmpty() ? realmReps.iterator().next().getRealm() + : getDefaultRealmName(); final String authServerInternalUrl = realmsURL(internalURL, realmName); String clientAuthServerBaseUrl = hostURL != null ? hostURL : internalURL;
['extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java']
{'.java': 1}
1
1
0
0
1
23,693,611
4,659,127
604,880
5,557
279
63
3
1
3,724
289
921
65
2
0
1970-01-01T00:27:48
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,319
quarkusio/quarkus/29446/29434
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29434
https://github.com/quarkusio/quarkus/pull/29446
https://github.com/quarkusio/quarkus/pull/29446
1
fixes
Application startup fails using Lombok's @NonNull on a method annotated with @ConsumeEvent
### Describe the bug When annotating a method parameter with @NonNull for a Vertx Consumer Method (means its annotated with @ConsumeEvent) then the application startup fails, throwing an exception. Mentioned on: https://github.com/quarkusio/quarkus/discussions/29322 ### Expected behavior No exception is thrown when using @NonNull. ### Actual behavior Exception is thrown when using @NonNull, application can not be started. ### How to Reproduce? 1. Clone the repo: https://github.com/benjaminrau/quarkus-nonnull-reproducer 2. Start the application ### Output of `uname -a` or `ver` Linux br-builders-nb 5.14.0-1052-oem #59-Ubuntu SMP Fri Sep 9 09:37:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing) ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev >= 2.14.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.6.3 ### Additional information Noticable is that @NonNull is included in the ClassName for EventBusCodec registration too: `2022-11-23 10:29:52,634 INFO [io.qua.ver.dep.EventBusCodecProcessor] (build-5) Local Message Codec registered for type org.acme.@NonNull HelloEvent `
de814ab663f18e44e01ae2f7b78e5419284ef6f4
bba49af6f3baad595291f77c0616aefe4925fd78
https://github.com/quarkusio/quarkus/compare/de814ab663f18e44e01ae2f7b78e5419284ef6f4...bba49af6f3baad595291f77c0616aefe4925fd78
diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java index 1b6c049760a..3d2aba17ccc 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java @@ -42,7 +42,7 @@ public void registerCodecs( final IndexView index = beanArchiveIndexBuildItem.getIndex(); Collection<AnnotationInstance> consumeEventAnnotationInstances = index.getAnnotations(CONSUME_EVENT); - Map<Type, DotName> codecByTypes = new HashMap<>(); + Map<DotName, DotName> codecByTypes = new HashMap<>(); for (AnnotationInstance consumeEventAnnotationInstance : consumeEventAnnotationInstances) { AnnotationTarget typeTarget = consumeEventAnnotationInstance.target(); if (typeTarget.kind() != AnnotationTarget.Kind.METHOD) { @@ -59,7 +59,7 @@ public void registerCodecs( if (codecTargetFromParameter == null) { throw new IllegalStateException("Invalid `codec` argument in @ConsumeEvent - no parameter"); } - codecByTypes.put(codecTargetFromParameter, codec.asClass().asClassType().name()); + codecByTypes.put(codecTargetFromParameter.name(), codec.asClass().asClassType().name()); } else if (codecTargetFromParameter != null) { // Codec is not set, check if we have a built-in codec if (!hasBuiltInCodec(codecTargetFromParameter)) { @@ -70,24 +70,24 @@ public void registerCodecs( "The generic message codec can only be used for local delivery," + ", implement your own event bus codec for " + codecTargetFromParameter.name() .toString()); - } else if (!codecByTypes.containsKey(codecTargetFromParameter)) { + } else if (!codecByTypes.containsKey(codecTargetFromParameter.name())) { LOGGER.infof("Local Message Codec registered for type %s", codecTargetFromParameter.toString()); - codecByTypes.put(codecTargetFromParameter, LOCAL_EVENT_BUS_CODEC); + codecByTypes.put(codecTargetFromParameter.name(), LOCAL_EVENT_BUS_CODEC); } } } if (codecTargetFromReturnType != null && !hasBuiltInCodec(codecTargetFromReturnType) - && !codecByTypes.containsKey(codecTargetFromReturnType)) { + && !codecByTypes.containsKey(codecTargetFromReturnType.name())) { LOGGER.infof("Local Message Codec registered for type %s", codecTargetFromReturnType.toString()); - codecByTypes.put(codecTargetFromReturnType, LOCAL_EVENT_BUS_CODEC); + codecByTypes.put(codecTargetFromReturnType.name(), LOCAL_EVENT_BUS_CODEC); } } // Produce the build items - for (Map.Entry<Type, DotName> entry : codecByTypes.entrySet()) { + for (Map.Entry<DotName, DotName> entry : codecByTypes.entrySet()) { messageCodecs.produce(new MessageCodecBuildItem(entry.getKey().toString(), entry.getValue().toString())); } diff --git a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java index 3bb61dd42ea..26cbd3a1ea8 100644 --- a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java +++ b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java @@ -2,6 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; @@ -73,6 +77,11 @@ String getMessage() { } } + @Retention(RetentionPolicy.CLASS) + @Target(ElementType.TYPE_USE) + @interface NonNull { + } + static class MyBean { @ConsumeEvent("person") public CompletionStage<Greeting> hello(Person p) { @@ -83,6 +92,12 @@ public CompletionStage<Greeting> hello(Person p) { public CompletionStage<Greeting> hello(Pet p) { return CompletableFuture.completedFuture(new Greeting("Hello " + p.getName())); } + + // presence of this method is enough to verify that type annotation + // on the message type doesn't cause failure + @ConsumeEvent("message-type-with-type-annotation") + void messageTypeWithTypeAnnotation(@NonNull Person person) { + } } static class MyNonLocalBean {
['extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusCodecProcessor.java', 'extensions/vertx/deployment/src/test/java/io/quarkus/vertx/EventBusCodecTest.java']
{'.java': 2}
2
2
0
0
2
23,732,829
4,666,564
605,742
5,573
1,194
229
14
1
1,398
175
388
44
2
0
1970-01-01T00:27:49
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0
2,318
quarkusio/quarkus/29452/29425
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/29425
https://github.com/quarkusio/quarkus/pull/29452
https://github.com/quarkusio/quarkus/pull/29452
1
fixes
Indexed `provided` annotation breaks `build` goal (or app startup) in 2.14
### Describe the bug While trying to upgrade from 2.13.3 to 2.14.0/1 I was greeted with a strange `java.lang.ClassNotFoundException: lombok.NonNull` very early in the boot process of the app. This is in a multi-module project that is working just fine with Quarkus 2.13.3 (and the "old" Jandex 1.2.3). In a non-app module, a class is using `lombok.NonNull` on a field alongside `lombok.RequiredArgsConstructor`. `jandex-maven-plugin` is executed in the module to provide an index. The lombok jar is a `provided` dependency (as recommended generally). See the reproducer further down. ### Expected behavior Should work as in 2.13 ### Actual behavior Fails at app startup (with ECJ) or already when building the app via `build` goal (with standard compiler). ### How to Reproduce? [q_jandex_nonnull.zip](https://github.com/quarkusio/quarkus/files/10071585/q_jandex_nonnull.zip) `mvn clean verify`: ``` [INFO] --- quarkus-maven-plugin:2.14.1.Final:build (default) @ code-with-quarkus-app --- [WARNING] [io.quarkus.arc.processor.BeanArchives] Failed to index lombok.NonNull: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: PROD@65f470f8 [INFO] [io.quarkus.arc.processor.IndexClassLookupUtils] Class for name: lombok.NonNull was not found in Jandex index. Please ensure the class is part of the index. [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for code-with-quarkus 1.0.0-SNAPSHOT: [INFO] [INFO] code-with-quarkus .................................. SUCCESS [ 0.027 s] [INFO] code-with-quarkus-lib .............................. SUCCESS [ 0.924 s] [INFO] code-with-quarkus-app .............................. FAILURE [ 1.511 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.968 s [INFO] Finished at: 2022-11-22T23:13:14+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.14.1.Final:build (default) on project code-with-quarkus-app: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#generateResources threw an exception: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Annotation class not available: @NonNull [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:918) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:281) [ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [ERROR] at java.base/java.lang.Thread.run(Thread.java:833) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) [ERROR] Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Annotation class not available: @NonNull [ERROR] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) [ERROR] at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) [ERROR] at io.quarkus.arc.processor.BeanProcessor.generateResources(BeanProcessor.java:319) [ERROR] at io.quarkus.arc.deployment.ArcProcessor.generateResources(ArcProcessor.java:570) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:568) [ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909) [ERROR] ... 6 more [ERROR] Caused by: java.lang.NullPointerException: Annotation class not available: @NonNull [ERROR] at java.base/java.util.Objects.requireNonNull(Objects.java:233) [ERROR] at io.quarkus.arc.processor.AnnotationLiteralProcessor.create(AnnotationLiteralProcessor.java:87) [ERROR] at io.quarkus.arc.processor.BeanGenerator.collectInjectionPointAnnotations(BeanGenerator.java:1937) [ERROR] at io.quarkus.arc.processor.BeanGenerator.wrapCurrentInjectionPoint(BeanGenerator.java:1837) [ERROR] at io.quarkus.arc.processor.BeanGenerator.initConstructor(BeanGenerator.java:704) [ERROR] at io.quarkus.arc.processor.BeanGenerator.createConstructor(BeanGenerator.java:614) [ERROR] at io.quarkus.arc.processor.BeanGenerator.generateClassBean(BeanGenerator.java:355) [ERROR] at io.quarkus.arc.processor.BeanGenerator.generate(BeanGenerator.java:122) [ERROR] at io.quarkus.arc.processor.BeanProcessor$4.call(BeanProcessor.java:258) [ERROR] at io.quarkus.arc.processor.BeanProcessor$4.call(BeanProcessor.java:254) [ERROR] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [ERROR] ... 5 more ``` `mvn clean verify -Pquarkus-2.13.4` is fine though (switches from Quarkus 2.14.1 to 2.13.4 and jandex-plugin to the old coordinates and version) Please note that this reproducer is not using ECJ (unlike my actual project), hence the error at build time, not boot time. If required I can provide a ECJ setup like in https://github.com/smallrye/jandex/issues/268. I actually started with an ECJ setup, stripped it down and was then surprised by the different behavior. ### Output of `uname -a` or `ver` _No response_ ### Output of `java -version` 17.0.5 ### GraalVM version (if different from Java) _No response_ ### Quarkus version or git rev 2.14.1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) _No response_ ### Additional information I _think_ it's an issue in Jandex (cc @Ladicek), but I'm not entirely sure. Might also be related to Arc (cc @mkouba @manovotn )? If I had to guess (wildly), I'd suppose that Jandex 3 is more strict about missing annotations. Please note that there have been discussions about why `lombok.NonNull` has `CLASS` retention in the first place: https://github.com/projectlombok/lombok/issues/895 I do think the maintainer has a point though: https://github.com/projectlombok/lombok/issues/895#issuecomment-145653045
af7bf36e2d3ecdce32dd53636684e17a515c0cb6
46268e3a8e2383b12258645d0435019b1761fb7c
https://github.com/quarkusio/quarkus/compare/af7bf36e2d3ecdce32dd53636684e17a515c0cb6...46268e3a8e2383b12258645d0435019b1761fb7c
diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java index 3446f86ad3e..88e8e83a893 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java @@ -73,6 +73,13 @@ public ResultHandle process(BytecodeCreator bytecode, ClassOutput classOutput, C * the annotation members have the same values as the given annotation instance. * An implementation of the annotation type will be generated automatically. * <p> + * It is expected that given annotation instance is runtime-retained; an exception is thrown + * if not. Further, it is expected that the annotation type is available (that is, + * {@code annotationClass != null}); an exception is thrown if not. Callers that expect + * they always deal with runtime-retained annotations whose classes are available do not + * have to check (and will get decent errors for free), but callers that can possibly deal + * with class-retained annotations or missing annotation classes must check explicitly. + * <p> * We call the generated implementation of the annotation type an <em>annotation literal class</em> * and the instance produced by the generated bytecode an <em>annotation literal instance</em>, * even though the generated code doesn't use CDI's {@code AnnotationLiteral} anymore. @@ -84,6 +91,10 @@ public ResultHandle process(BytecodeCreator bytecode, ClassOutput classOutput, C * @return an annotation literal instance result handle */ public ResultHandle create(BytecodeCreator bytecode, ClassInfo annotationClass, AnnotationInstance annotationInstance) { + if (!annotationInstance.runtimeVisible()) { + throw new IllegalArgumentException("Annotation does not have @Retention(RUNTIME): " + annotationInstance); + } + Objects.requireNonNull(annotationClass, "Annotation class not available: " + annotationInstance); AnnotationLiteralClassInfo literal = cache.getValue(new CacheKey(annotationClass)); diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java index 698525b7650..b418627a6c0 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java @@ -1932,9 +1932,14 @@ public static ResultHandle collectInjectionPointAnnotations(ClassOutput classOut annotationHandle = constructor .readStaticField(FieldDescriptor.of(InjectLiteral.class, "INSTANCE", InjectLiteral.class)); } else { - // Create annotation literal if needed - ClassInfo literalClass = getClassByName(beanDeployment.getBeanArchiveIndex(), annotation.name()); - annotationHandle = annotationLiterals.create(constructor, literalClass, annotation); + if (!annotation.runtimeVisible()) { + continue; + } + ClassInfo annotationClass = getClassByName(beanDeployment.getBeanArchiveIndex(), annotation.name()); + if (annotationClass == null) { + continue; + } + annotationHandle = annotationLiterals.create(constructor, annotationClass, annotation); } constructor.invokeInterfaceMethod(MethodDescriptors.SET_ADD, annotationsHandle, annotationHandle); diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BuiltinBean.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BuiltinBean.java index 68aaa2a2a97..2b64aadfa9d 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BuiltinBean.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BuiltinBean.java @@ -311,10 +311,16 @@ private static void generateBeanManagerBytecode(GeneratorContext ctx) { private static void generateResourceBytecode(GeneratorContext ctx) { ResultHandle annotations = ctx.constructor.newInstance(MethodDescriptor.ofConstructor(HashSet.class)); // For a resource field the required qualifiers contain all annotations declared on the field + // (hence we need to check if they are runtime-retained and their classes are available) if (!ctx.injectionPoint.getRequiredQualifiers().isEmpty()) { for (AnnotationInstance annotation : ctx.injectionPoint.getRequiredQualifiers()) { - // Create annotation literal first + if (!annotation.runtimeVisible()) { + continue; + } ClassInfo annotationClass = getClassByName(ctx.beanDeployment.getBeanArchiveIndex(), annotation.name()); + if (annotationClass == null) { + continue; + } ctx.constructor.invokeInterfaceMethod(MethodDescriptors.SET_ADD, annotations, ctx.annotationLiterals.create(ctx.constructor, annotationClass, annotation)); } diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AnnotationLiteralProcessorTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AnnotationLiteralProcessorTest.java index 48aa079f416..35ed23d0d5d 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AnnotationLiteralProcessorTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AnnotationLiteralProcessorTest.java @@ -1,6 +1,7 @@ package io.quarkus.arc.processor; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; @@ -31,6 +32,10 @@ public enum SimpleEnum { BAZ, } + @Retention(RetentionPolicy.CLASS) + public @interface ClassRetainedAnnotation { + } + @Retention(RetentionPolicy.RUNTIME) public @interface SimpleAnnotation { String value(); @@ -327,6 +332,35 @@ public void test() throws ReflectiveOperationException { annotation.toString()); } + @Test + public void missingAnnotationClass() { + AnnotationLiteralProcessor literals = new AnnotationLiteralProcessor(index, ignored -> true); + + TestClassLoader cl = new TestClassLoader(getClass().getClassLoader()); + try (ClassCreator creator = ClassCreator.builder().classOutput(cl).className(generatedClass).build()) { + MethodCreator method = creator.getMethodCreator("hello", void.class); + + assertThrows(NullPointerException.class, () -> { + literals.create(method, null, simpleAnnotationJandex("foobar")); + }); + } + } + + @Test + public void classRetainedAnnotation() { + AnnotationLiteralProcessor literals = new AnnotationLiteralProcessor(index, ignored -> true); + + TestClassLoader cl = new TestClassLoader(getClass().getClassLoader()); + try (ClassCreator creator = ClassCreator.builder().classOutput(cl).className(generatedClass).build()) { + MethodCreator method = creator.getMethodCreator("hello", void.class); + + assertThrows(IllegalArgumentException.class, () -> { + literals.create(method, Index.singleClass(ClassRetainedAnnotation.class), + AnnotationInstance.builder(ClassRetainedAnnotation.class).build()); + }); + } + } + private static void verify(ComplexAnnotation ann) { assertEquals(true, ann.bool()); assertEquals((byte) 1, ann.b()); diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/injection/resource/ResourceInjectionTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/injection/resource/ResourceInjectionTest.java index 1658d1474e0..2bdb111422d 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/injection/resource/ResourceInjectionTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/injection/resource/ResourceInjectionTest.java @@ -36,12 +36,15 @@ import javax.persistence.criteria.CriteriaUpdate; import javax.persistence.metamodel.Metamodel; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.DotName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.arc.Arc; import io.quarkus.arc.InstanceHandle; import io.quarkus.arc.ResourceReferenceProvider; +import io.quarkus.arc.processor.InjectionPointsTransformer; import io.quarkus.arc.test.ArcTestContainer; public class ResourceInjectionTest { @@ -50,7 +53,26 @@ public class ResourceInjectionTest { public ArcTestContainer container = ArcTestContainer.builder() .beanClasses(EEResourceField.class, JpaClient.class) .resourceReferenceProviders(EntityManagerProvider.class, DummyProvider.class) - .resourceAnnotations(PersistenceContext.class, Dummy.class).build(); + .resourceAnnotations(PersistenceContext.class, Dummy.class) + .injectionPointsTransformers(new InjectionPointsTransformer() { + @Override + public boolean appliesTo(org.jboss.jandex.Type requiredType) { + return requiredType.name().toString().equals(String.class.getName()); + } + + @Override + public void transform(TransformationContext transformationContext) { + if (transformationContext.getAllAnnotations() + .stream() + .anyMatch(it -> it.name().toString().equals(Dummy.class.getName()))) { + // pretend that the injection point has an annotation whose class is missing + transformationContext.transform() + .add(AnnotationInstance.builder(DotName.createSimple("missing.NonNull")).build()) + .done(); + } + } + }) + .build(); @Test public void testInjection() {
['independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java', 'independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/injection/resource/ResourceInjectionTest.java', 'independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BuiltinBean.java', 'independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java', 'independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/AnnotationLiteralProcessorTest.java']
{'.java': 5}
5
5
0
0
5
23,734,868
4,666,948
605,780
5,573
1,805
305
30
3
6,596
554
1,647
110
4
1
1970-01-01T00:27:49
12,047
Java
{'Java': 45174846, 'HTML': 1260641, 'Kotlin': 726044, 'JavaScript': 519044, 'Shell': 51146, 'Groovy': 25140, 'ANTLR': 23342, 'Batchfile': 13971, 'Mustache': 13199, 'Scala': 9778, 'FreeMarker': 8106, 'CSS': 5346, 'Dockerfile': 660, 'PLpgSQL': 109}
Apache License 2.0