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]
stars
int64
10
44.3k
language
stringclasses
8 values
languages
stringclasses
296 values
license
stringclasses
2 values
2,877
quarkusio/quarkus/13908/13848
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13848
https://github.com/quarkusio/quarkus/pull/13908
https://github.com/quarkusio/quarkus/pull/13908
1
fixes
Native container build with debug symbols fails during copying of jar sources
**Describe the bug** When trying to build a native image with debug symbols in the quarkus quickstart project the build fails. I originally spotted this in my custom project and was able to replicate the same problem in the hibernate-orm-quickstart. Maybe I'm doing something wrong, or maybe this is actually a bug? **Expected behavior** The build should succeed. **Actual behavior** The following error message is logged as the build fails: [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.10.3.Final:native-image (default) on project hibernate-orm-quickstart: Failed to generate native image: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Unable to copy from C:\\path\\to\\mvn\\repo\\jakarta\\annotation\\jakarta.annotation-api\\1.3.5\\jakarta.annotation-api-1.3.5-sources.jar to C:\\path\\to\\quarkus-quickstarts\\hibernate-orm-quickstart\\target\\hibernate-orm-quickstart-1.0-SNAPSHOT-native-image-source-jar\\lib\\jakarta.annotation.jakarta.annotation-api-1.3.5-sources.jar [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:423) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:93) [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$2.execute(ExtensionLoader.java:972) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) [ERROR] at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479) [ERROR] Caused by: java.nio.file.NoSuchFileException: C:\\path\\to\\mvn\\repo\\jakarta\\annotation\\jakarta.annotation-api\\1.3.5\\jakarta.annotation-api-1.3.5-sources.jar -> C:\\path\\to\\quarkus-quickstarts\\hibernate-orm-quickstart\\target\\hibernate-orm-quickstart-1.0-SNAPSHOT-native-image-source-jar\\lib\\jakarta.annotation.jakarta.annotation-api-1.3.5-sources.jar [ERROR] at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) [ERROR] at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) [ERROR] at java.base/sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:202) [ERROR] at java.base/sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:283) [ERROR] at java.base/java.nio.file.Files.copy(Files.java:1294) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:421) [ERROR] ... 13 more [ERROR] -> [Help 1] **To Reproduce** Run this as recommended on https://quarkus.io/guides/building-native-image#debugging-native-executable to download the sources jars (this doesn't seem to make any difference): `mvn dependency:sources` Run: `mvn clean install -DskipTests -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.debug.enabled=true` In project: https://github.com/quarkusio/quarkus-quickstarts/tree/master/hibernate-orm-quickstart **Environment:** - Output of `uname -a` or `ver`: ver Microsoft Windows [Version 10.0.19041.388] - Output of `java -version`: java -version openjdk version "11.0.7" 2020-04-14 LTS OpenJDK Runtime Environment Corretto-11.0.7.10.1 (build 11.0.7+10-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.7.10.1 (build 11.0.7+10-LTS, mixed mode) - Quarkus version or git rev: https://github.com/quarkusio/quarkus-quickstarts/commit/6fc48e99980ff8a3e2fe0c40e75da2f468108398 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): mvn -version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\\ProgramData\\chocolatey\\lib\\maven\\apache-maven-3.6.3\\bin\\.. Java version: 11.0.7, vendor: Amazon.com Inc., runtime: C:\\Program Files\\Amazon Corretto\\jdk11.0.7_10 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
4b1d5f6bc70d530751aa43db9bc56118aa879b2d
330ad574da22f63d72230e13826ea5758184fe63
https://github.com/quarkusio/quarkus/compare/4b1d5f6bc70d530751aa43db9bc56118aa879b2d...330ad574da22f63d72230e13826ea5758184fe63
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index 6671453994f..ae164594a3d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -447,6 +447,10 @@ private void copyJarSourcesToLib(OutputTargetBuildItem outputTargetBuildItem, Path targetDirectory = outputTargetBuildItem.getOutputDirectory() .resolve(outputTargetBuildItem.getBaseName() + "-native-image-source-jar"); Path libDir = targetDirectory.resolve(JarResultBuildStep.LIB); + File libDirFile = libDir.toFile(); + if (!libDirFile.exists()) { + libDirFile.mkdirs(); + } final List<AppDependency> appDeps = curateOutcomeBuildItem.getEffectiveModel().getUserDependencies(); for (AppDependency appDep : appDeps) {
['core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java']
{'.java': 1}
1
1
0
0
1
13,845,143
2,701,130
360,501
3,816
125
28
4
1
4,967
311
1,386
62
3
0
2020-12-15T21:23:35
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,878
quarkusio/quarkus/13907/13901
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13901
https://github.com/quarkusio/quarkus/pull/13907
https://github.com/quarkusio/quarkus/pull/13907
1
fixes
Redirect for /metrics sub paths is not working
Redirect for /metrics sub paths is not working http://127.0.0.1:8080/metrics after merging https://github.com/quarkusio/quarkus/pull/13601 gets redirected to http://127.0.0.1:8080/q/metrics But that redirect is not working for `/metrics` sub paths, 404 Not Found is returned `/metrics` sub path: ``` curl -v http://127.0.0.1:8080/metrics/application * Trying 127.0.0.1... * TCP_NODELAY set * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0) > GET /metrics/application HTTP/1.1 > Host: 127.0.0.1:8080 > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 404 Not Found < Content-Length: 0 < Content-Type: application/json < * Connection #0 to host 127.0.0.1 left intact * Closing connection 0 ``` `/metrics` path: ``` curl -v http://127.0.0.1:8080/metrics * Trying 127.0.0.1... * TCP_NODELAY set * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0) > GET /metrics HTTP/1.1 > Host: 127.0.0.1:8080 > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 301 Moved Permanently < location: http://127.0.0.1:8080/q/metrics < content-length: 0 < * Connection #0 to host 127.0.0.1 left intact * Closing connection 0 ```
4b1d5f6bc70d530751aa43db9bc56118aa879b2d
65bdc188a5434ed461b146144688e8b645a8401e
https://github.com/quarkusio/quarkus/compare/4b1d5f6bc70d530751aa43db9bc56118aa879b2d...65bdc188a5434ed461b146144688e8b645a8401e
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 7f1a38cc0d7..920981089dc 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 @@ -130,22 +130,25 @@ VertxWebRouterBuildItem initializeRouter(VertxHttpRecorder recorder, RuntimeValue<Router> router = recorder.initializeRouter(vertx.getVertx()); RuntimeValue<Router> frameworkRouter = recorder.initializeRouter(vertx.getVertx()); boolean frameworkRouterFound = false; + recorder.setNonApplicationRedirectHandler(nonApplicationRootPath.getFrameworkRootPath()); for (RouteBuildItem route : routes) { if (nonApplicationRootPath.isSeparateRoot() && route.isFrameworkRoute()) { frameworkRouterFound = true; recorder.addRoute(frameworkRouter, route.getRouteFunction(), route.getHandler(), route.getType()); + + // Handle redirects from old paths to new non application endpoint root + if (httpBuildTimeConfig.redirectToNonApplicationRootPath) { + recorder.addRoute(router, route.getRouteFunction(), + recorder.getNonApplicationRedirectHandler(), + route.getType()); + } } else { recorder.addRoute(router, route.getRouteFunction(), route.getHandler(), route.getType()); } } - if (frameworkRouterFound && nonApplicationRootPath.isSeparateRoot()) { - // Handle redirects from old paths to new non application endpoint root - if (httpBuildTimeConfig.redirectToNonApplicationRootPath) { - recorder.addNonApplicationPathRedirect(router, frameworkRouter, nonApplicationRootPath.getFrameworkRootPath()); - } - + if (frameworkRouterFound) { frameworkRouterBuildProducer.produce(new VertxNonApplicationRouterBuildItem(frameworkRouter)); } 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 81c4eebbac6..351a031ee4b 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 @@ -120,6 +120,8 @@ public class VertxHttpRecorder { private static volatile Handler<HttpServerRequest> rootHandler; + private static volatile Handler<RoutingContext> nonApplicationRedirectHandler; + private static volatile int actualHttpPort = -1; private static volatile int actualHttpsPort = -1; @@ -798,11 +800,8 @@ public void addRoute(RuntimeValue<Router> router, Function<Router, Route> route, } } - public void addNonApplicationPathRedirect(RuntimeValue<Router> mainRouter, RuntimeValue<Router> nonApplicationRouter, - String nonApplicationPath) { - List<Route> allRoutes = nonApplicationRouter.getValue().getRoutes(); - - Handler<RoutingContext> handler = new Handler<RoutingContext>() { + public void setNonApplicationRedirectHandler(String nonApplicationPath) { + nonApplicationRedirectHandler = new Handler<RoutingContext>() { @Override public void handle(RoutingContext context) { String absoluteURI = context.request().absoluteURI(); @@ -816,10 +815,10 @@ public void handle(RoutingContext context) { .end(); } }; + } - for (Route route : allRoutes) { - addRoute(mainRouter, router -> router.route(route.getPath()), handler, HandlerType.NORMAL); - } + public Handler<RoutingContext> getNonApplicationRedirectHandler() { + return nonApplicationRedirectHandler; } public GracefulShutdownFilter createGracefulShutdownHandler() { diff --git a/integration-tests/smallrye-metrics/src/test/java/io/quarkus/it/metrics/MetricsTestCase.java b/integration-tests/smallrye-metrics/src/test/java/io/quarkus/it/metrics/MetricsTestCase.java index 0ffc3daec8c..3f4e20f9829 100644 --- a/integration-tests/smallrye-metrics/src/test/java/io/quarkus/it/metrics/MetricsTestCase.java +++ b/integration-tests/smallrye-metrics/src/test/java/io/quarkus/it/metrics/MetricsTestCase.java @@ -101,6 +101,13 @@ public void testScopes() { RestAssured.when().get("/q/metrics/application").then().statusCode(200); } + @Test + public void testScopesRedirect() { + RestAssured.when().get("/metrics/base").then().statusCode(200); + RestAssured.when().get("/metrics/vendor").then().statusCode(200); + RestAssured.when().get("/metrics/application").then().statusCode(200); + } + @Test public void testMetricWithAbsoluteName() { invokeCounterWithAbsoluteName();
['integration-tests/smallrye-metrics/src/test/java/io/quarkus/it/metrics/MetricsTestCase.java', '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': 3}
3
3
0
0
3
13,845,143
2,701,130
360,501
3,816
1,741
305
30
2
1,158
150
429
43
6
2
2020-12-15T20:40: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,881
quarkusio/quarkus/13758/13711
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13711
https://github.com/quarkusio/quarkus/pull/13758
https://github.com/quarkusio/quarkus/pull/13758
1
close
IDE Launcher fails for gradle project containing a submodule without resources
**Describe the bug** We have a gradle project with some submodules. Some submodules have an empty resource folder. When starting the main method directly from the Intellij, we receive a null pointer exception. ``` Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:57) at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:92) at io.quarkus.runtime.Quarkus.run(Quarkus.java:79) at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) at io.quarkus.runtime.Quarkus.run(Quarkus.java:104) at org.qumea.Main.main(Main.java:11) Caused by: java.lang.reflect.InvocationTargetException 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.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:54) ... 5 more Caused by: java.lang.RuntimeException: java.lang.NullPointerException at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:60) ... 10 more Caused by: java.lang.NullPointerException at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:50) ... 10 more ``` **Expected behavior** Empty resource directories should probably be ignored. **To Reproduce** [submodule-no-resources.zip](https://github.com/quarkusio/quarkus/files/5643966/submodule-no-resources.zip) **Environment (please complete the following information):** - Quarkus version or git rev: 1.10.2.Final
94ea17a6ce5c86f3feb17343cb885827b4e547b5
684135ae9b3002caf1cee4ef0a18b64b6bbc54cf
https://github.com/quarkusio/quarkus/compare/94ea17a6ce5c86f3feb17343cb885827b4e547b5...684135ae9b3002caf1cee4ef0a18b64b6bbc54cf
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java index 5bd60db5765..37b665f7586 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java @@ -445,7 +445,7 @@ Set<String> checkForFileChange() { outputPath = rootPath; doCopy = false; } - if (rootPath == null) { + if (rootPath == null || outputPath == null) { continue; } Path root = Paths.get(rootPath); diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java index b2fdf7e7f57..35a2bc4aec6 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java @@ -12,10 +12,9 @@ /** * IDE entry point. - * + * <p> * This is launched from the core/launcher module. To avoid any shading issues core/launcher unpacks all its dependencies * into the jar file, then uses a custom class loader load them. - * */ public class IDELauncherImpl {
['independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/IDELauncherImpl.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java']
{'.java': 2}
2
2
0
0
2
13,736,782
2,681,607
357,923
3,783
110
28
5
2
1,775
112
437
38
1
1
2020-12-08T15:55: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,882
quarkusio/quarkus/13713/13671
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13671
https://github.com/quarkusio/quarkus/pull/13713
https://github.com/quarkusio/quarkus/pull/13713
1
fixes
Cannot find 'jvmArgs' in class io.quarkus.maven.GenerateCodeMojo
Hi, After upgrading to 1.10.2 (including maven plugin) from 1.9.2, I'm geting the following error when I run `mvn quarkus:dev` alone: `[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.10.2.Final:dev (default-cli) on project btrdkr: Unable to execute mojo: Unable to parse configuration of mojo io.quarkus:quarkus-maven-plugin:1.10.2.Final:generate-code for parameter jvmArgs: Cannot find 'jvmArgs' in class io.quarkus.maven.GenerateCodeMojo -> [Help 1]` ...this is after I first run `mvn compile`. If I run them together with `mvn compile quarkus:dev`, I get the exception when starting up: ``` 2020-12-03 16:11:56,003 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.security.cert.CertificateException: No X509TrustManager implementation available at java.base/sun.security.ssl.DummyX509TrustManager.checkServerTrusted(SSLContextImpl.java:1652) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:632) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369) at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1267) at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1254) at java.base/java.security.AccessController.doPrivileged(AccessController.java:691) at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1199) at io.netty.handler.ssl.SslHandler.runAllDelegatedTasks(SslHandler.java:1542) ... ``` This is because I use OIDC module and it tries to contact the OIDC server during startup using SSL. I have the following configuration for maven plugin: ``` <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.platform.version}</version> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> <goal>generate-code-tests</goal> </goals> </execution> </executions> <configuration> <jvmArgs>-Djavax.net.ssl.trustStoreType=JKS -Djavax.net.ssl.trustStore=${project.build.outputDirectory}/META-INF/security/cacerts -Djavax.net.ssl.trustStorePassword=changeit</jvmArgs> </configuration> </plugin> ``` It looks like the quarkus:dev mojo is not passing the jvmArgs to the JVM when starting it up. This used to work with 1.9.2 plugin. **To Reproduce** Use `<jvmArgs>...</jvmArgs>` in configuration of quarkus-maven-plugin and see that they are either not applied or executing `mvn quarkus:dev` alone bails out with error.
da81223f2eec6ae021b26de27d914aa06e605df3
ab836039d5e78716868d6d7e2a3a2a00454ce33d
https://github.com/quarkusio/quarkus/compare/da81223f2eec6ae021b26de27d914aa06e605df3...ab836039d5e78716868d6d7e2a3a2a00454ce33d
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 f4a39de666b..4ab9abca7f2 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -48,6 +48,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.cli.CommandLineUtils; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -623,7 +624,7 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { .deleteDevJar(deleteDevJar); if (jvmArgs != null) { - builder.jvmArgs(jvmArgs); + builder.jvmArgs(Arrays.asList(CommandLineUtils.translateCommandline(jvmArgs))); } builder.projectDir(project.getFile().getParentFile());
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
13,698,102
2,674,170
356,994
3,773
191
37
3
1
3,344
220
812
52
0
2
2020-12-04T17:58:31
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,883
quarkusio/quarkus/13697/13687
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13687
https://github.com/quarkusio/quarkus/pull/13697
https://github.com/quarkusio/quarkus/pull/13697
1
fixes
Unsafe concurrent ClassLoader use
**Describe the bug** I've noticed the following exception stack being ignored but logged in a CI test run: ``` 2020-12-03T20:03:03.4075698Z [INFO] Running io.quarkus.resteasy.test.ClasspathResourceTestCase 2020-12-03T20:03:04.3307728Z 2020-12-03 20:03:03,388 ERROR [org.jbo.exe.uncaught] (executor-thread-4) Thread Thread[executor-thread-4,5,] threw an uncaught exception: java.lang.RuntimeException: Unable to read org/jboss/threads/ThreadLocalResettingRunnable$Resetter.class 2020-12-03T20:03:04.3311111Z at io.quarkus.bootstrap.classloading.JarClassPathElement$1$1$1.apply(JarClassPathElement.java:121) 2020-12-03T20:03:04.3313722Z at io.quarkus.bootstrap.classloading.JarClassPathElement$1$1$1.apply(JarClassPathElement.java:108) 2020-12-03T20:03:04.3316967Z at io.quarkus.bootstrap.classloading.JarClassPathElement.withJarFile(JarClassPathElement.java:149) 2020-12-03T20:03:04.3320155Z at io.quarkus.bootstrap.classloading.JarClassPathElement.access$100(JarClassPathElement.java:33) 2020-12-03T20:03:04.3323321Z at io.quarkus.bootstrap.classloading.JarClassPathElement$1$1.getData(JarClassPathElement.java:108) 2020-12-03T20:03:04.3326627Z at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:400) 2020-12-03T20:03:04.3332639Z at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:365) 2020-12-03T20:03:04.3335164Z at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:31) 2020-12-03T20:03:04.3337123Z at java.base/java.lang.Thread.run(Thread.java:832) 2020-12-03T20:03:04.3338066Z at org.jboss.threads.JBossThread.run(JBossThread.java:479) 2020-12-03T20:03:04.3339091Z Caused by: java.util.zip.ZipException: ZipFile closed 2020-12-03T20:03:04.3340369Z at java.base/java.util.zip.ZipFile.ensureOpenOrZipException(ZipFile.java:832) 2020-12-03T20:03:04.3342034Z at java.base/java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:922) 2020-12-03T20:03:04.3343569Z at java.base/java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:445) 2020-12-03T20:03:04.3345719Z at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) 2020-12-03T20:03:04.3347235Z at java.base/java.io.FilterInputStream.read(FilterInputStream.java:106) 2020-12-03T20:03:04.3349996Z at io.quarkus.bootstrap.classloading.JarClassPathElement.readStreamContents(JarClassPathElement.java:231) 2020-12-03T20:03:04.3352995Z at io.quarkus.bootstrap.classloading.JarClassPathElement$1$1$1.apply(JarClassPathElement.java:113) 2020-12-03T20:03:04.3354368Z ... 9 more 2020-12-03T20:03:04.3354597Z ``` It would seem that there is no protection in `io.quarkus.bootstrap.classloading.JarClassPathElement` against a concurrent `close()` while an ongoing classloading event being performed.
993a5667fbb51aec5677e30e7210d07bb3be529a
1ce8862443d051f4b87e94d75f5841db49cc141d
https://github.com/quarkusio/quarkus/compare/993a5667fbb51aec5677e30e7210d07bb3be529a...1ce8862443d051f4b87e94d75f5841db49cc141d
diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java index 251ea050b9c..8ce92e2f850 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java @@ -1,7 +1,6 @@ package io.quarkus.bootstrap.classloading; import java.io.Closeable; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.security.ProtectionDomain; @@ -78,7 +77,7 @@ public Manifest getManifest() { } @Override - public void close() throws IOException { + public void close() { } }; diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/JarClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/JarClassPathElement.java index ada1f110c0e..9db8c2e9b21 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/JarClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/JarClassPathElement.java @@ -21,6 +21,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Function; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -49,17 +52,25 @@ public class JarClassPathElement implements ClassPathElement { private static final Logger log = Logger.getLogger(JarClassPathElement.class); public static final String META_INF_VERSIONS = "META-INF/versions/"; + private final File file; private final URL jarPath; private final Path root; - private JarFile jarFile; - private boolean closed; + private final Lock readLock; + private final Lock writeLock; + + //Closing the jarFile requires the exclusive lock, while reading data from the jarFile requires the shared lock. + private final JarFile jarFile; + private volatile boolean closed; public JarClassPathElement(Path root) { try { jarPath = root.toUri().toURL(); this.root = root; jarFile = JarFiles.create(file = root.toFile()); + ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); + this.readLock = readWriteLock.readLock(); + this.writeLock = readWriteLock.writeLock(); } catch (IOException e) { throw new UncheckedIOException("Error while reading file as JAR: " + root, e); } @@ -137,16 +148,21 @@ public boolean isDirectory() { } private <T> T withJarFile(Function<JarFile, T> func) { - if (closed) { - //we still need this to work if it is closed, so shutdown hooks work - //once it is closed it simply does not hold on to any resources - try (JarFile jarFile = JarFiles.create(file)) { + readLock.lock(); + try { + if (closed) { + //we still need this to work if it is closed, so shutdown hooks work + //once it is closed it simply does not hold on to any resources + try (JarFile jarFile = JarFiles.create(file)) { + return func.apply(jarFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + } else { return func.apply(jarFile); - } catch (IOException e) { - throw new RuntimeException(e); } - } else { - return func.apply(jarFile); + } finally { + readLock.unlock(); } } @@ -192,7 +208,7 @@ public Set<String> apply(JarFile jarFile) { @Override public ProtectionDomain getProtectionDomain(ClassLoader classLoader) { - URL url = null; + final URL url; try { URI uri = new URI("file", null, jarPath.getPath(), null); url = uri.toURL(); @@ -220,8 +236,13 @@ public Manifest apply(JarFile jarFile) { @Override public void close() throws IOException { - closed = true; - jarFile.close(); + writeLock.lock(); + try { + jarFile.close(); + closed = true; + } finally { + writeLock.unlock(); + } } public static byte[] readStreamContents(InputStream inputStream) throws IOException { diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java index c7ffad2f2e9..9341215bdd4 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java @@ -504,7 +504,7 @@ public void close() { //all resources are closed, however the CL can still be used //but after close no resources will be held past the scope of an operation try (ClassPathElement ignored = element) { - + //the close() operation is implied by the try-with syntax } catch (Exception e) { log.error("Failed to close " + element, e); }
['independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/JarClassPathElement.java', 'independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java', 'independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java']
{'.java': 3}
3
3
0
0
3
13,659,810
2,666,071
355,634
3,772
2,034
391
52
3
2,844
124
940
29
0
1
2020-12-04T10:47:31
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,885
quarkusio/quarkus/13587/13500
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13500
https://github.com/quarkusio/quarkus/pull/13587
https://github.com/quarkusio/quarkus/pull/13587
1
resolves
Qute extension method with parameters not working in loop
**Describe the bug** Given the following extension method: static Set<String> tags(Item item, String category) { return item.tagsForCategory(category); } The following works: {item.tags('foo')} // This prints ['foo', 'bar'] But the following doesn't: {#each item.tags('foo')} {it} {/each} The Quarkus build fails with: io.quarkus.qute.TemplateException: Found template problems (1): [1] Incorrect expression: it - property/method [tags('foo')] not found on class [org.acme.qute.Item] nor handled by an extension method The same problem occurs with the {#for} and {#let} tags. **Expected behavior** I would expect that I can use tags such {#each} and {#for} to loop over the results of a virtual method. **To Reproduce** See https://github.com/eamelink/quarkus-qute-issue-reproducer , and then the /qute/items path. **Environment - Darwin MacBook-Pro.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64 - Output of `java -version`: openjdk version "15" 2020-09-15 - Quarkus version or git rev: Quarkus 1.9.2
f29cd0a6a15c09558a67f4cc76f327a7cd4dd6d2
3d4a58e3148b77db77edd81d213a9496713049d0
https://github.com/quarkusio/quarkus/compare/f29cd0a6a15c09558a67f4cc76f327a7cd4dd6d2...3d4a58e3148b77db77edd81d213a9496713049d0
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 acafbda3fe1..406f97da1b5 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 @@ -421,7 +421,10 @@ void validateExpressions(TemplatesAnalysisBuildItem templatesAnalysis, BeanArchi List<TemplateExtensionMethodBuildItem> templateExtensionMethods, List<TypeCheckExcludeBuildItem> excludes, BuildProducer<IncorrectExpressionBuildItem> incorrectExpressions, - BuildProducer<ImplicitValueResolverBuildItem> implicitClasses) { + BuildProducer<ImplicitValueResolverBuildItem> implicitClasses, + BeanRegistrationPhaseBuildItem registrationPhase, + // This producer is needed to ensure the correct ordering, ie. this build step must be executed before the ArC validation step + BuildProducer<BeanConfiguratorBuildItem> configurators) { IndexView index = beanArchiveIndex.getIndex(); Function<String, String> templateIdToPathFun = new Function<String, String>() { @@ -431,20 +434,39 @@ public String apply(String id) { } }; + // IMPLEMENTATION NOTE: + // We do not support injection of synthetic beans with names + // Dependency on the ValidationPhaseBuildItem would result in a cycle in the build chain + Map<String, BeanInfo> namedBeans = registrationPhase.getContext().beans().withName() + .collect(toMap(BeanInfo::getName, Function.identity())); + // Map implicit class -> set of used members Map<ClassInfo, Set<String>> implicitClassToMembersUsed = new HashMap<>(); - for (TemplateAnalysis analysis : templatesAnalysis.getAnalysis()) { + for (TemplateAnalysis templateAnalysis : templatesAnalysis.getAnalysis()) { // Maps an expression generated id to the last match of an expression (i.e. the type of the last part) Map<Integer, Match> generatedIdsToMatches = new HashMap<>(); - for (Expression expression : analysis.expressions) { - if (skip(expression)) { + + for (Expression expression : templateAnalysis.expressions) { + if (expression.isLiteral()) { continue; } - generatedIdsToMatches.put(expression.getGeneratedId(), - validateNestedExpressions(analysis, null, new HashMap<>(), templateExtensionMethods, excludes, - incorrectExpressions, expression, index, implicitClassToMembersUsed, templateIdToPathFun, - generatedIdsToMatches)); + if (expression.hasNamespace()) { + if (expression.getNamespace().equals(EngineProducer.INJECT_NAMESPACE)) { + validateInjectExpression(templateAnalysis, expression, index, incorrectExpressions, + templateExtensionMethods, excludes, namedBeans, generatedIdsToMatches, + implicitClassToMembersUsed, + templateIdToPathFun); + } else { + continue; + } + } else { + generatedIdsToMatches.put(expression.getGeneratedId(), + validateNestedExpressions(templateAnalysis, null, new HashMap<>(), templateExtensionMethods, + excludes, + incorrectExpressions, expression, index, implicitClassToMembersUsed, templateIdToPathFun, + generatedIdsToMatches)); + } } } @@ -514,19 +536,23 @@ static Match validateNestedExpressions(TemplateAnalysis templateAnalysis, ClassI Info root = iterator.next(); if (rootClazz == null) { - // {foo.name} if (root.isTypeInfo()) { + // E.g. |org.acme.Item| match.clazz = root.asTypeInfo().rawClass; match.type = root.asTypeInfo().resolvedType; if (root.asTypeInfo().hint != null) { - processHints(templateAnalysis, root.asTypeInfo().hint, match, index, expression, generatedIdsToMatches); + processHints(templateAnalysis, root.asTypeInfo().hint, match, index, expression, generatedIdsToMatches, + incorrectExpressions); } } else { if (root.isProperty() && root.asProperty().hint != null) { // Root is not a type info but a property with hint - // We need to reset the iterator - processHints(templateAnalysis, root.asProperty().hint, match, index, expression, generatedIdsToMatches); - iterator = parts.iterator(); + // E.g. 'it<loop#123>' and 'STATUS<when#123>' + if (processHints(templateAnalysis, root.asProperty().hint, match, index, expression, + generatedIdsToMatches, incorrectExpressions)) { + // In some cases it's necessary to reset the iterator + iterator = parts.iterator(); + } } else { // No type info available results.put(expression.toOriginalString(), match); @@ -587,9 +613,6 @@ static Match validateNestedExpressions(TemplateAnalysis templateAnalysis, ClassI break; } else { match.type = resolveType(member, match, index); - if (match.type.kind() == org.jboss.jandex.Type.Kind.PRIMITIVE) { - break; - } if (match.type.kind() == Type.Kind.CLASS || match.type.kind() == Type.Kind.PARAMETERIZED_TYPE) { match.clazz = index.getClassByName(match.type.name()); } @@ -597,9 +620,13 @@ static Match validateNestedExpressions(TemplateAnalysis templateAnalysis, ClassI String hint = info.asProperty().hint; if (hint != null) { // For example a loop section needs to validate the type of an element - processHints(templateAnalysis, hint, match, index, expression, generatedIdsToMatches); + processHints(templateAnalysis, hint, match, index, expression, generatedIdsToMatches, + incorrectExpressions); } } + if (match.type != null && match.type.kind() == org.jboss.jandex.Type.Kind.PRIMITIVE) { + break; + } } } else { LOGGER.debugf( @@ -699,81 +726,43 @@ private void produceExtensionMethod(IndexView index, BuildProducer<TemplateExten priority, namespace)); } - @BuildStep - void validateInjectNamespaceExpressions(TemplatesAnalysisBuildItem analysis, BeanArchiveIndexBuildItem beanArchiveIndex, + private void validateInjectExpression(TemplateAnalysis templateAnalysis, Expression expression, IndexView index, BuildProducer<IncorrectExpressionBuildItem> incorrectExpressions, - List<TemplateExtensionMethodBuildItem> templateExtensionMethods, - List<TypeCheckExcludeBuildItem> excludes, - BeanRegistrationPhaseBuildItem registrationPhase, - // This producer is needed to ensure the correct ordering, ie. this build step must be executed before the ArC validation step - BuildProducer<BeanConfiguratorBuildItem> configurators, - BuildProducer<ImplicitValueResolverBuildItem> implicitClasses) { - - IndexView index = beanArchiveIndex.getIndex(); - Function<String, String> templateIdToPathFun = new Function<String, String>() { - @Override - public String apply(String id) { - return findTemplatePath(analysis, id); - } - }; - Map<TemplateAnalysis, Set<Expression>> injectExpressions = collectNamespaceExpressions(analysis, - EngineProducer.INJECT_NAMESPACE); - - if (!injectExpressions.isEmpty()) { - // IMPLEMENTATION NOTE: - // We do not support injection of synthetic beans with names - // Dependency on the ValidationPhaseBuildItem would result in a cycle in the build chain - Map<String, BeanInfo> namedBeans = registrationPhase.getContext().beans().withName() - .collect(toMap(BeanInfo::getName, Function.identity())); - - // Map implicit class -> set of used members - Map<ClassInfo, Set<String>> implicitClassToMembersUsed = new HashMap<>(); - - for (Entry<TemplateAnalysis, Set<Expression>> entry : injectExpressions.entrySet()) { - - Map<Integer, Match> generatedIdsToMatches = new HashMap<>(); - - for (Expression expression : entry.getValue()) { - Expression.Part firstPart = expression.getParts().get(0); - if (firstPart.isVirtualMethod()) { - incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), - "The inject: namespace must be followed by a bean name", - expression.getOrigin())); - continue; - } - String beanName; - if (expression.hasNamespace()) { - beanName = firstPart.getName(); - } else { - // inject:foo.labels<for-element> => foo - String firstInfoPart = Expressions.splitTypeInfoParts(firstPart.getTypeInfo()).get(0); - beanName = firstInfoPart.substring(EngineProducer.INJECT_NAMESPACE.length() + 1, - firstInfoPart.length()); - } - - BeanInfo bean = namedBeans.get(beanName); - if (bean != null) { - if (expression.getParts().size() == 1) { - // Only the bean needs to be validated - continue; - } - generatedIdsToMatches.put(expression.getGeneratedId(), - validateNestedExpressions(entry.getKey(), bean.getImplClazz(), new HashMap<>(), - templateExtensionMethods, excludes, incorrectExpressions, expression, index, - implicitClassToMembersUsed, templateIdToPathFun, generatedIdsToMatches)); + List<TemplateExtensionMethodBuildItem> templateExtensionMethods, List<TypeCheckExcludeBuildItem> excludes, + Map<String, BeanInfo> namedBeans, Map<Integer, Match> generatedIdsToMatches, + Map<ClassInfo, Set<String>> implicitClassToMembersUsed, Function<String, String> templateIdToPathFun) { + Expression.Part firstPart = expression.getParts().get(0); + if (firstPart.isVirtualMethod()) { + incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), + "The inject: namespace must be followed by a bean name", + expression.getOrigin())); + return; + } + String beanName; + if (expression.hasNamespace()) { + beanName = firstPart.getName(); + } else { + // inject:foo.labels<loop-element> => foo + String firstInfoPart = Expressions.splitTypeInfoParts(firstPart.getTypeInfo()).get(0); + beanName = firstInfoPart.substring(EngineProducer.INJECT_NAMESPACE.length() + 1, + firstInfoPart.length()); + } - } else { - // User is injecting a non-existing bean - incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), - beanName, null, expression.getOrigin())); - } - } + BeanInfo bean = namedBeans.get(beanName); + if (bean != null) { + if (expression.getParts().size() == 1) { + // Only the bean needs to be validated + return; } + generatedIdsToMatches.put(expression.getGeneratedId(), + validateNestedExpressions(templateAnalysis, bean.getImplClazz(), new HashMap<>(), + templateExtensionMethods, excludes, incorrectExpressions, expression, index, + implicitClassToMembersUsed, templateIdToPathFun, generatedIdsToMatches)); - for (Entry<ClassInfo, Set<String>> entry : implicitClassToMembersUsed.entrySet()) { - implicitClasses.produce(new ImplicitValueResolverBuildItem(entry.getKey(), - new TemplateDataBuilder().addIgnore(buildIgnorePattern(entry.getValue())).build())); - } + } else { + // User is injecting a non-existing bean + incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), + beanName, null, expression.getOrigin())); } } @@ -1078,35 +1067,58 @@ private static Type resolveType(AnnotationTarget member, Match match, IndexView return matchType; } - static void processHints(TemplateAnalysis templateAnalysis, String helperHint, Match match, IndexView index, - Expression expression, Map<Integer, Match> generatedIdsToMatches) { - if (LoopSectionHelper.Factory.HINT.equals(helperHint)) { + /** + * + * @param templateAnalysis + * @param helperHint + * @param match + * @param index + * @param expression + * @param generatedIdsToMatches + * @param incorrectExpressions + * @return {@code true} if it is necessary to reset the type info part iterator + */ + static boolean processHints(TemplateAnalysis templateAnalysis, String helperHint, Match match, IndexView index, + Expression expression, Map<Integer, Match> generatedIdsToMatches, + BuildProducer<IncorrectExpressionBuildItem> incorrectExpressions) { + if (helperHint == null || helperHint.isEmpty()) { + return false; + } + if (helperHint.equals(LoopSectionHelper.Factory.HINT_ELEMENT)) { // Iterable<Item>, Stream<Item> => Item // Map<String,Long> => Entry<String,Long> - processLoopHint(match, index, expression); - } else if (helperHint != null && helperHint.startsWith(WhenSectionHelper.Factory.HINT_PREFIX)) { + processLoopElementHint(match, index, expression, incorrectExpressions); + } else if (helperHint.startsWith(LoopSectionHelper.Factory.HINT_PREFIX)) { + Integer iterableExprId = Integer + .valueOf(helperHint.substring(LoopSectionHelper.Factory.HINT_PREFIX.length(), helperHint.length() - 1)); + Expression valueExpr = templateAnalysis.findExpression(iterableExprId); + if (valueExpr != null) { + Match valueExprMatch = generatedIdsToMatches.get(valueExpr.getGeneratedId()); + if (valueExprMatch != null) { + match.type = valueExprMatch.type; + match.clazz = valueExprMatch.clazz; + } + } + } else if (helperHint.startsWith(WhenSectionHelper.Factory.HINT_PREFIX)) { // If a value expression resolves to an enum we attempt to use the enum type to validate the enum constant // This basically transforms the type info "ON<when:12345>" into something like "|org.acme.Status|.ON" Integer valueExprId = Integer .valueOf(helperHint.substring(WhenSectionHelper.Factory.HINT_PREFIX.length(), helperHint.length() - 1)); - Expression valueExpr = null; - for (Expression e : templateAnalysis.expressions) { - if (e.getGeneratedId() == valueExprId) { - valueExpr = e; - break; - } - } + Expression valueExpr = templateAnalysis.findExpression(valueExprId); if (valueExpr != null) { Match valueExprMatch = generatedIdsToMatches.get(valueExpr.getGeneratedId()); if (valueExprMatch != null && valueExprMatch.clazz.isEnum()) { match.type = valueExprMatch.type; match.clazz = valueExprMatch.clazz; + return true; } } } + return false; } - static void processLoopHint(Match match, IndexView index, Expression expression) { + static void processLoopElementHint(Match match, IndexView index, Expression expression, + BuildProducer<IncorrectExpressionBuildItem> incorrectExpressions) { if (match.type.name().equals(DotNames.INTEGER)) { return; } @@ -1146,7 +1158,7 @@ static void processLoopHint(Match match, IndexView index, Expression expression) // CompletionStage<List<Item>> => List<Item> match.type = extractMatchType(closure, Names.COMPLETION_STAGE, firstParamType); match.clazz = index.getClassByName(match.type.name()); - processLoopHint(match, index, expression); + processLoopElementHint(match, index, expression, incorrectExpressions); return; } @@ -1154,10 +1166,10 @@ static void processLoopHint(Match match, IndexView index, Expression expression) match.type = matchType; match.clazz = index.getClassByName(match.type.name()); } else { - throw new TemplateException(expression.getOrigin(), String.format( - "Unsupported iterable type found in [%s]\\n\\t- matching type: %s \\n\\t- found in template [%s] on line %s", - expression.toOriginalString(), - match.type, expression.getOrigin().getTemplateId(), expression.getOrigin().getLine())); + incorrectExpressions.produce(new IncorrectExpressionBuildItem(expression.toOriginalString(), + "Unsupported iterable type found: " + match.type, expression.getOrigin())); + match.type = null; + match.clazz = null; } } @@ -1540,16 +1552,4 @@ private static boolean isExcluded(TypeCheck check, List<TypeCheckExcludeBuildIte return false; } - private boolean skip(Expression expression) { - if (expression.hasNamespace() || expression.isLiteral()) { - return true; - } - String typeInfo = expression.getParts().get(0).getTypeInfo(); - if (typeInfo != null && typeInfo.contains(":")) { - // An expression bound to a namespace expression - return true; - } - return false; - } - } diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatesAnalysisBuildItem.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatesAnalysisBuildItem.java index a235359a5c2..2597dde031e 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatesAnalysisBuildItem.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatesAnalysisBuildItem.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.Objects; -import java.util.Set; import io.quarkus.builder.item.SimpleBuildItem; import io.quarkus.qute.Expression; @@ -27,16 +26,25 @@ static class TemplateAnalysis { // Path or other user-defined id; may be null public final String id; public final String generatedId; - public final Set<Expression> expressions; + public final List<Expression> expressions; public final String path; - public TemplateAnalysis(String id, String generatedId, Set<Expression> expressions, String path) { + public TemplateAnalysis(String id, String generatedId, List<Expression> expressions, String path) { this.id = id; this.generatedId = generatedId; this.expressions = expressions; this.path = path; } + Expression findExpression(Integer id) { + for (Expression expression : expressions) { + if (expression.getGeneratedId() == id) { + return expression; + } + } + return null; + } + @Override public int hashCode() { final int prime = 31; diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TypeInfos.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TypeInfos.java index 32312f62ace..fe04f9a76d7 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TypeInfos.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TypeInfos.java @@ -66,13 +66,14 @@ static Info create(String typeInfo, Expression.Part part, IndexView index, Funct return new TypeInfo(typeInfo, part, helperHint(typeInfo.substring(endIdx, typeInfo.length())), resolvedType, rawClass); } - } else if (part.isVirtualMethod()) { - return new VirtualMethodInfo(typeInfo, part.asVirtualMethod()); } else { String hint = helperHint(typeInfo); if (hint != null) { typeInfo = typeInfo.substring(0, typeInfo.indexOf(LEFT_ANGLE)); } + if (part.isVirtualMethod() || Expressions.isVirtualMethod(typeInfo)) { + return new VirtualMethodInfo(typeInfo, part.asVirtualMethod()); + } return new PropertyInfo(typeInfo, part, hint); } } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopFailureTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopFailureTest.java index 732a3690568..a5f6b382faf 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopFailureTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopFailureTest.java @@ -1,5 +1,7 @@ package io.quarkus.qute.deployment.typesafe; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -22,7 +24,20 @@ public class TypeSafeLoopFailureTest { + "{#for foo in list}" + "{foo.name}={foo.ages}" + "{/}"), "templates/foo.html")) - .setExpectedException(TemplateException.class); + .assertException(t -> { + Throwable e = t; + TemplateException te = null; + while (e != null) { + if (e instanceof TemplateException) { + te = (TemplateException) e; + break; + } + e = e.getCause(); + } + assertNotNull(te); + assertTrue(te.getMessage().contains("Found template problems (1)"), te.getMessage()); + assertTrue(te.getMessage().contains("foo.ages"), te.getMessage()); + }); @Test public void testValidation() { diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopTest.java index 88a847419cd..9a59463a0a8 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopTest.java @@ -2,7 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.Arrays; import java.util.Collections; +import java.util.List; import javax.inject.Inject; @@ -13,6 +15,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.qute.Template; +import io.quarkus.qute.TemplateExtension; import io.quarkus.qute.deployment.Foo; import io.quarkus.qute.deployment.MyFooList; import io.quarkus.test.QuarkusUnitTest; @@ -22,7 +25,7 @@ public class TypeSafeLoopTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addClasses(Foo.class, MyFooList.class) + .addClasses(Foo.class, MyFooList.class, Item.class, Extensions.class) .addAsResource(new StringAsset("{@java.util.List<io.quarkus.qute.deployment.Foo> list}" + "{@io.quarkus.qute.deployment.MyFooList fooList}" + "{#for foo in list}" @@ -33,16 +36,33 @@ public class TypeSafeLoopTest { + "{foo.name}={foo.age}={foo.charlie.name}" + "{/}" + "::" - + "{fooList.get(0).name}"), "templates/foo.html")); + + "{fooList.get(0).name}" + + "::" + + "{#for item in items}{#each item.tags('foo')}{it}{/each}{/for}"), "templates/foo.html")); @Inject Template foo; @Test public void testValidation() { - assertEquals("bravo=10=BRAVO::alpha=1=ALPHA::alpha", - foo.data("list", Collections.singletonList(new Foo("bravo", 10l))) - .data("fooList", new MyFooList(new Foo("alpha", 1l))).render()); + List<Foo> foos = Collections.singletonList(new Foo("bravo", 10l)); + MyFooList myFoos = new MyFooList(new Foo("alpha", 1l)); + List<Item> items = Arrays.asList(new Item()); + assertEquals("bravo=10=BRAVO::alpha=1=ALPHA::alpha::foobar", + foo.data("list", foos, "fooList", myFoos, "items", items).render()); + } + + static class Item { + + } + + @TemplateExtension + static class Extensions { + + static List<String> tags(Item item, String foo) { + return Arrays.asList(foo, "bar"); + } + } } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java index df3911f9018..801b5fc4beb 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java @@ -34,7 +34,8 @@ public class ValidationFailuresTest { + "{movie.toNumber(age)}" + "{#each movie.mainCharacters}{it.boom(1)}{/}" // Template extension method must accept one param - + "{movie.toNumber}"), + + "{movie.toNumber}" + + "{#each movie}{it}{/each}"), "templates/movie.html")) .assertException(t -> { Throwable e = t; @@ -47,7 +48,7 @@ public class ValidationFailuresTest { e = e.getCause(); } assertNotNull(te); - assertTrue(te.getMessage().contains("Found template problems (8)"), te.getMessage()); + assertTrue(te.getMessage().contains("Found template problems (9)"), te.getMessage()); assertTrue(te.getMessage().contains("movie.foo"), te.getMessage()); assertTrue(te.getMessage().contains("movie.getName('foo')"), te.getMessage()); assertTrue(te.getMessage().contains("movie.findService(age)"), te.getMessage()); @@ -56,6 +57,9 @@ public class ValidationFailuresTest { assertTrue(te.getMessage().contains("movie.toNumber(age)"), te.getMessage()); assertTrue(te.getMessage().contains("it.boom(1)"), te.getMessage()); assertTrue(te.getMessage().contains("movie.toNumber"), te.getMessage()); + assertTrue( + te.getMessage().contains("Unsupported iterable type found: io.quarkus.qute.deployment.typesafe.Movie"), + te.getMessage()); }); @Test diff --git a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java index cc8cf0fc70e..881aaa69cd5 100644 --- a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java +++ b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java @@ -9,7 +9,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.function.Consumer; @@ -113,7 +112,7 @@ public TemplateInstance instance() { } @Override - public Set<Expression> getExpressions() { + public List<Expression> getExpressions() { throw new UnsupportedOperationException("Injected templates do not support getExpressions()"); } diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expression.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expression.java index c1f4f55a1f1..b75c7e2da19 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expression.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expression.java @@ -89,8 +89,8 @@ interface Part { * <li>type info that represents a fully qualified type name (including type parameters) - * {@code |TYPE_INFO|<section-hint>}; * for example {@code |org.acme.Foo|}, - * {@code |java.util.List<org.acme.Label>|} and {@code |org.acme.Foo|<for-element>}</li> - * <li>property; for example {@code foo} and {@code foo<for-element>}</li> + * {@code |java.util.List<org.acme.Label>|} and {@code |org.acme.Foo|<when#123>}</li> + * <li>property; for example {@code foo} and {@code foo<loop#123>}</li> * <li>virtual method; for example {@code foo.call(|org.acme.Bar|)}</li> * </ul> * diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/ExpressionNode.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/ExpressionNode.java index 8ec248def74..182afdbbc80 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/ExpressionNode.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/ExpressionNode.java @@ -1,7 +1,7 @@ package io.quarkus.qute; import java.util.Collections; -import java.util.Set; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.function.Function; @@ -50,8 +50,8 @@ Engine getEngine() { return engine; } - public Set<Expression> getExpressions() { - return Collections.singleton(expression); + public List<Expression> getExpressions() { + return Collections.singletonList(expression); } @Override diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java index d448aa419a9..f89e55c7b52 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java @@ -99,7 +99,8 @@ CompletionStage<ResultNode> nextElement(Object element, int index, boolean hasNe public static class Factory implements SectionHelperFactory<LoopSectionHelper> { - public static final String HINT = "<for-element>"; + public static final String HINT_ELEMENT = "<loop-element>"; + public static final String HINT_PREFIX = "<loop#"; private static final String ALIAS = "alias"; private static final String IN = "in"; private static final String ITERABLE = "iterable"; @@ -130,17 +131,25 @@ public Scope initializeBlock(Scope previousScope, BlockInfo block) { if (iterable == null) { iterable = ValueResolvers.THIS; } + // foo.items + // > |org.acme.Foo|.items<loop-element> + previousScope.setLastPartHint(HINT_ELEMENT); Expression iterableExpr = block.addExpression(ITERABLE, iterable); + previousScope.setLastPartHint(null); + String alias = block.getParameters().get(ALIAS); + if (iterableExpr.hasTypeInfo()) { + // it.name + // > it<loop#123>.name alias = alias.equals(Parameter.EMPTY) ? DEFAULT_ALIAS : alias; Scope newScope = new Scope(previousScope); - newScope.put(alias, iterableExpr.collectTypeInfo() + HINT); + newScope.putBinding(alias, alias + HINT_PREFIX + iterableExpr.getGeneratedId() + ">"); return newScope; } else { // Make sure we do not try to validate against the parent context Scope newScope = new Scope(previousScope); - newScope.put(alias, null); + newScope.putBinding(alias, null); return newScope; } } else { diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java index 0840748b259..b09b5ba8360 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java @@ -465,7 +465,7 @@ private void flushTag() { int spaceIdx = content.indexOf(" "); String key = content.substring(spaceIdx + 1, content.length()); String value = content.substring(1, spaceIdx); - currentScope.put(key, Expressions.TYPE_INFO_SEPARATOR + value + Expressions.TYPE_INFO_SEPARATOR); + currentScope.putBinding(key, Expressions.TYPE_INFO_SEPARATOR + value + Expressions.TYPE_INFO_SEPARATOR); sectionBlockStack.peek().addNode(new ParameterDeclarationNode(content, origin(0))); } else { @@ -705,8 +705,9 @@ static ExpressionImpl parseExpression(Supplier<Integer> idGenerator, String valu } List<Part> parts = new ArrayList<>(strParts.size()); Part first = null; - for (String strPart : strParts) { - Part part = createPart(idGenerator, namespace, first, strPart, scope, origin); + Iterator<String> strPartsIterator = strParts.iterator(); + while (strPartsIterator.hasNext()) { + Part part = createPart(idGenerator, namespace, first, strPartsIterator, scope, origin); if (!isValidIdentifier(part.getName())) { StringBuilder builder = new StringBuilder("Invalid identifier found ["); builder.append(value).append("]"); @@ -724,8 +725,10 @@ static ExpressionImpl parseExpression(Supplier<Integer> idGenerator, String valu return new ExpressionImpl(idGenerator.get(), namespace, parts, Result.NOT_FOUND, origin); } - private static Part createPart(Supplier<Integer> idGenerator, String namespace, Part first, String value, Scope scope, + private static Part createPart(Supplier<Integer> idGenerator, String namespace, Part first, + Iterator<String> strPartsIterator, Scope scope, Origin origin) { + String value = strPartsIterator.next(); if (Expressions.isVirtualMethod(value)) { String name = Expressions.parseVirtualMethodName(value); List<String> strParams = new ArrayList<>(Expressions.parseVirtualMethodParams(value)); @@ -756,10 +759,15 @@ private static Part createPart(Supplier<Integer> idGenerator, String namespace, if (namespace != null) { typeInfo = first != null ? value : namespace + NAMESPACE_SEPARATOR + value; } else if (first == null) { - typeInfo = scope.getBindingType(value); + // Try to find the binding type for the first part of the expression + typeInfo = scope.getBinding(value); } else if (first.getTypeInfo() != null) { typeInfo = value; } + if (typeInfo != null && !strPartsIterator.hasNext() && scope.getLastPartHint() != null) { + // If type info present then append hint to the last part + typeInfo += scope.getLastPartHint(); + } return new ExpressionImpl.PartImpl(value, typeInfo); } @@ -937,7 +945,7 @@ public String toString() { public void addParameter(String name, String type) { // {@org.acme.Foo foo} Scope currentScope = scopeStack.peek(); - currentScope.put(name, Expressions.TYPE_INFO_SEPARATOR + type + Expressions.TYPE_INFO_SEPARATOR); + currentScope.putBinding(name, Expressions.TYPE_INFO_SEPARATOR + type + Expressions.TYPE_INFO_SEPARATOR); } private static final SectionHelper ROOT_SECTION_HELPER = new SectionHelper() { diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Scope.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Scope.java index b6199638ee2..9f11ccc2b91 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Scope.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Scope.java @@ -7,39 +7,41 @@ public class Scope { public static final Scope EMPTY = new Scope(null) { @Override - public void put(String binding, String type) { + public void putBinding(String binding, String type) { throw new UnsupportedOperationException("Immutable empty scope"); } }; - private Scope parentScope; + private final Scope parentScope; private Map<String, String> bindings; private Map<String, Object> attributes; + // TODO: add proper API to handle this + private String lastPartHint; public Scope(Scope parentScope) { this.parentScope = parentScope; } - public void put(String binding, String type) { + public void putBinding(String binding, String type) { if (bindings == null) bindings = new HashMap<>(); bindings.put(binding, type); } - public String getBindingType(String binding) { + public String getBinding(String binding) { // we can contain null types to override outer scopes if (bindings != null && bindings.containsKey(binding)) return bindings.get(binding); - return parentScope != null ? parentScope.getBindingType(binding) : null; + return parentScope != null ? parentScope.getBinding(binding) : null; } public String getBindingTypeOrDefault(String binding, String defaultValue) { - String type = getBindingType(binding); + String type = getBinding(binding); return type != null ? type : defaultValue; } - public void setAttribute(String name, Object value) { + public void putAttribute(String name, Object value) { if (attributes == null) { attributes = new HashMap<>(); } @@ -50,4 +52,12 @@ public Object getAttribute(String name) { return attributes != null ? attributes.get(name) : null; } + public String getLastPartHint() { + return lastPartHint; + } + + public void setLastPartHint(String lastPartHint) { + this.lastPartHint = lastPartHint; + } + } diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionBlock.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionBlock.java index 43301f7f332..7bd99bb5afb 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionBlock.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionBlock.java @@ -4,7 +4,6 @@ import io.quarkus.qute.TemplateNode.Origin; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -54,8 +53,8 @@ public boolean isEmpty() { return nodes.isEmpty(); } - Set<Expression> getExpressions() { - Set<Expression> expressions = new HashSet<>(); + List<Expression> getExpressions() { + List<Expression> expressions = new ArrayList<>(); expressions.addAll(this.expressions.values()); for (TemplateNode node : nodes) { expressions.addAll(node.getExpressions()); diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionHelperFactory.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionHelperFactory.java index 0d83cd3f77f..3862f02e0f5 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionHelperFactory.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionHelperFactory.java @@ -89,6 +89,14 @@ default boolean hasParameter(String name) { return getParameters().containsKey(name); } + /** + * Parse and register an expression for the specified parameter. + * + * @param param + * @param value + * @return a new expression + * @see SectionInitContext#getExpression(String) + */ Expression addExpression(String param, String value); } @@ -98,6 +106,10 @@ default boolean hasParameter(String name) { */ public interface SectionInitContext extends ParserDelegate { + /** + * + * @return the parameters of the main block + */ default public Map<String, String> getParameters() { return getBlocks().get(0).parameters; } @@ -110,8 +122,20 @@ default public String getParameter(String name) { return getParameters().get(name); } + /** + * + * @param parameterName + * @return an expression registered for the specified param name, or {@code null} + * @see BlockInfo#addExpression(String, String) + */ public Expression getExpression(String parameterName); + /** + * Parse the specified value. The expression is not registered in the template. + * + * @param value + * @return a new expression + */ public Expression parseValue(String value); public List<SectionBlock> getBlocks(); diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionNode.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionNode.java index dbfe84b0beb..63ed6847c55 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionNode.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionNode.java @@ -2,7 +2,6 @@ import io.quarkus.qute.SectionHelper.SectionResolutionContext; import java.util.ArrayList; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -53,8 +52,8 @@ public String toString() { return builder.toString(); } - public Set<Expression> getExpressions() { - Set<Expression> expressions = new HashSet<>(); + public List<Expression> getExpressions() { + List<Expression> expressions = new ArrayList<>(); for (SectionBlock block : blocks) { expressions.addAll(block.getExpressions()); } diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SetSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SetSectionHelper.java index 473bdb285e8..091eddd7343 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/SetSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/SetSectionHelper.java @@ -68,7 +68,7 @@ public Scope initializeBlock(Scope previousScope, BlockInfo block) { Scope newScope = new Scope(previousScope); for (Entry<String, String> entry : block.getParameters().entrySet()) { Expression expr = block.addExpression(entry.getKey(), entry.getValue()); - newScope.put(entry.getKey(), expr.collectTypeInfo()); + newScope.putBinding(entry.getKey(), expr.collectTypeInfo()); } return newScope; } else { diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Template.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Template.java index 2de0e141f89..710a74dcd50 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Template.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Template.java @@ -1,7 +1,7 @@ package io.quarkus.qute; +import java.util.List; import java.util.Optional; -import java.util.Set; /** * Represents an immutable template definition. @@ -115,9 +115,9 @@ default String render() { /** * - * @return an immutable set of expressions used in the template + * @return an immutable list of expressions used in the template */ - Set<Expression> getExpressions(); + List<Expression> getExpressions(); /** * The id is unique for the engine instance. diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateImpl.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateImpl.java index 848c1711486..ae039b48365 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateImpl.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateImpl.java @@ -3,7 +3,6 @@ import io.smallrye.mutiny.Multi; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; @@ -31,7 +30,7 @@ public TemplateInstance instance() { } @Override - public Set<Expression> getExpressions() { + public List<Expression> getExpressions() { return root.getExpressions(); } diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateNode.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateNode.java index ae92a72b658..2036805350e 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateNode.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateNode.java @@ -1,8 +1,8 @@ package io.quarkus.qute; import java.util.Collections; +import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.concurrent.CompletionStage; /** @@ -19,10 +19,10 @@ public interface TemplateNode { /** * - * @return a set of expressions + * @return a list of expressions */ - default Set<Expression> getExpressions() { - return Collections.emptySet(); + default List<Expression> getExpressions() { + return Collections.emptyList(); } /** diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/WhenSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/WhenSectionHelper.java index dd71707dc65..9d1a93fa5a0 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/WhenSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/WhenSectionHelper.java @@ -127,24 +127,34 @@ public Scope initializeBlock(Scope previousScope, BlockInfo block) { Expression valueExpr = block.addExpression(VALUE, value); if (valueExpr.hasTypeInfo()) { // If type info is available we do add the expression id - previousScope.setAttribute(VALUE_EXPR_ID, valueExpr.getGeneratedId()); + previousScope.putAttribute(VALUE_EXPR_ID, valueExpr.getGeneratedId()); } } else if (ELSE.equals(block.getLabel())) { // No special handling required for "else" } else if (IS.equals(block.getLabel()) || CASE.equals(block.getLabel())) { Object valueExprId = previousScope.getAttribute(VALUE_EXPR_ID); - for (String param : block.getParameters().values()) { + int added = 0; + Iterator<String> it = block.getParameters().values().iterator(); + while (it.hasNext()) { + String param = it.next(); + if (added == 0 && it.hasNext()) { + // Skip the operator param + continue; + } + added++; if (valueExprId != null) { // This could be an enum switch - we need to add a hint in order to validate the enum constants properly - String binding = previousScope.getBindingType(param); - if (binding == null) { - binding = param; + String previousBinding = previousScope.getBinding(param); + String newBinding = previousBinding; + if (newBinding == null) { + newBinding = param; } // Append hint to the existing binding if needed // E.g. ON -> ON<when:12345> - binding += HINT_PREFIX + valueExprId + ">"; - previousScope.put(param, binding); + newBinding += HINT_PREFIX + valueExprId + ">"; + previousScope.putBinding(param, newBinding); block.addExpression(param, param); + previousScope.putBinding(param, previousBinding); } else { block.addExpression(param, param); } diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java index 03469c82f85..178ee44761e 100644 --- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java +++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java @@ -14,7 +14,6 @@ import java.util.Iterator; import java.util.List; import java.util.Optional; -import java.util.Set; import org.junit.jupiter.api.Test; public class ParserTest { @@ -86,21 +85,30 @@ public void testTypeInfos() { + "{/for}" + "{foo.call(labels,bar)}" + "{#when machine.status}{#is OK}..{#is NOK}{/when}"); - Set<Expression> expressions = template.getExpressions(); + List<Expression> expressions = template.getExpressions(); assertExpr(expressions, "foo.name", 2, "|org.acme.Foo|.name"); - assertExpr(expressions, "foo.items", 2, "|org.acme.Foo|.items"); - assertExpr(expressions, "item.name", 2, "|org.acme.Foo|.items<for-element>.name"); + + Expression fooItems = find(expressions, "foo.items"); + assertExpr(expressions, "foo.items", 2, "|org.acme.Foo|.items<loop-element>"); + assertExpr(expressions, "item.name", 2, "item<loop#" + fooItems.getGeneratedId() + ">.name"); assertExpr(expressions, "bar.name", 2, null); - assertExpr(expressions, "labels", 1, "|java.util.List<org.acme.Label>|"); - assertExpr(expressions, "it.name", 2, "|java.util.List<org.acme.Label>|<for-element>.name"); + + Expression labels = find(expressions, "labels"); + assertExpr(expressions, "labels", 1, "|java.util.List<org.acme.Label>|<loop-element>"); + assertExpr(expressions, "it.name", 2, "it<loop#" + labels.getGeneratedId() + ">.name"); + assertExpr(expressions, "inject:bean.name", 2, "inject:bean.name"); - assertExpr(expressions, "inject:bean.labels", 2, "inject:bean.labels"); - assertExpr(expressions, "it.value", 2, "inject:bean.labels<for-element>.value"); + + Expression beanLabels = find(expressions, "inject:bean.labels"); + assertExpr(expressions, "inject:bean.labels", 2, "inject:bean.labels<loop-element>"); + assertExpr(expressions, "it.value", 2, "it<loop#" + beanLabels.getGeneratedId() + ">.value"); + assertExpr(expressions, "foo.bar", 2, "|org.acme.Foo|.bar"); assertExpr(expressions, "baz.name", 2, "|org.acme.Foo|.bar.name"); assertExpr(expressions, "foo.baz", 2, null); assertExpr(expressions, "foo.call(labels,bar)", 2, "|org.acme.Foo|.call(labels,bar)"); + Expression machineStatusExpr = find(expressions, "machine.status"); assertExpr(expressions, "OK", 1, "OK<when#" + machineStatusExpr.getGeneratedId() + ">"); } @@ -253,6 +261,18 @@ public void testTextNodeCollapse() { assertEquals("next", ((TextNode) rootNodes.get(2)).getValue()); } + @Test + public void testGetExpressions() { + Template template = Engine.builder().addDefaults().build() + .parse("{foo}{#each items}{it.name}{#for foo in foos}{foo.name}{/for}{/each}"); + List<Expression> expressions = template.getExpressions(); + assertEquals("foo", expressions.get(0).toOriginalString()); + assertEquals("items", expressions.get(1).toOriginalString()); + assertEquals("it.name", expressions.get(2).toOriginalString()); + assertEquals("foos", expressions.get(3).toOriginalString()); + assertEquals("foo.name", expressions.get(4).toOriginalString()); + } + private void assertParserError(String template, String message, int line) { Engine engine = Engine.builder().addDefaultSectionHelpers().build(); try { @@ -266,14 +286,14 @@ private void assertParserError(String template, String message, int line) { } } - private void assertExpr(Set<Expression> expressions, String value, int parts, String typeInfo) { + private void assertExpr(List<Expression> expressions, String value, int parts, String typeInfo) { Expression expr = find(expressions, value); assertEquals(parts, expr.getParts().size()); assertEquals(typeInfo, expr.collectTypeInfo()); } - private Expression find(Set<Expression> expressions, String val) { + private Expression find(List<Expression> expressions, String val) { return expressions.stream().filter(e -> e.toOriginalString().equals(val)).findAny().get(); }
['independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionBlock.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/ExpressionNode.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java', 'extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/SetSectionHelper.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatesAnalysisBuildItem.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TypeInfos.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopTest.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateImpl.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/LoopSectionHelper.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionNode.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Template.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/TypeSafeLoopFailureTest.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Scope.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/WhenSectionHelper.java', 'independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Expression.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/TemplateNode.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/SectionHelperFactory.java']
{'.java': 21}
21
21
0
0
21
13,512,878
2,637,712
351,871
3,716
22,928
4,097
404
17
1,157
140
326
35
1
0
2020-12-01T14:42: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,873
quarkusio/quarkus/14180/14166
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14166
https://github.com/quarkusio/quarkus/pull/14180
https://github.com/quarkusio/quarkus/pull/14180
1
close
quarkus-maven-plugin generates extension project with failing DevMode test.
**Describe the bug** When using the quarkus-maven-plugin to generate a bare bones extension to build upon you get a project with generated tests of which the DevMode test fails after adjusting the pom.xml to include the needed maven-surefire-plugin configuration. **Expected behavior** I would expect the generated project, after adjustment of the pom for the maven-surefire-plugin to have a SUCCESS outcome when running mvn clean verify. **Actual behavior** The outcome is FAILURE with the following output: ``` [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running org.acme.quarkus.greeting.test.QuarkusGreetingDevModeTest [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.022 s <<< FAILURE! - in org.acme.quarkus.greeting.test.QuarkusGreetingDevModeTest [ERROR] org.acme.quarkus.greeting.test.QuarkusGreetingDevModeTest.test Time elapsed: 0.005 s <<< ERROR! org.junit.jupiter.api.extension.TestInstantiationException: Unable to create test proxy Caused by: java.lang.IllegalAccessException: class io.quarkus.test.QuarkusDevModeTest cannot access a member of class org.acme.quarkus.greeting.test.QuarkusGreetingDevModeTest with modifiers "" [INFO] Running org.acme.quarkus.greeting.test.QuarkusGreetingTest 2021-01-07 13:49:27,914 INFO [io.quarkus] (main) Quarkus 1.10.5.Final on JVM started in 0.082s. 2021-01-07 13:49:27,915 INFO [io.quarkus] (main) Profile test activated. 2021-01-07 13:49:27,916 INFO [io.quarkus] (main) Installed features: [quarkus-greeting] 2021-01-07 13:49:27,923 INFO [io.quarkus] (main) Quarkus stopped in 0.000s [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.687 s <<< FAILURE! - in org.acme.quarkus.greeting.test.QuarkusGreetingTest [ERROR] org.acme.quarkus.greeting.test.QuarkusGreetingTest Time elapsed: 1.687 s <<< ERROR! java.lang.RuntimeException: org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance Caused by: org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.IllegalStateException: Unable to locate CDIProvider [INFO] [INFO] Results: [INFO] [ERROR] Errors: [ERROR] QuarkusGreetingDevModeTest.test » TestInstantiation Unable to create test prox... [ERROR] QuarkusGreetingTest » Runtime org.junit.jupiter.api.extension.TestInstantiatio... [INFO] [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Greeting Extension - Parent 1.0-SNAPSHOT: [INFO] [INFO] Greeting Extension - Parent ........................ SUCCESS [ 0.096 s] [INFO] Greeting Extension - Runtime ....................... SUCCESS [ 1.530 s] [INFO] Greeting Extension - Deployment .................... FAILURE [ 3.789 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.614 s [INFO] Finished at: 2021-01-07T13:49:27+01:00 [INFO] ------------------------------------------------------------------------ ``` **To Reproduce** Steps to reproduce the behavior: 1. Generate the project using: ``` mvn io.quarkus:quarkus-maven-plugin:1.10.5.Final:create-extension -N \\ -DgroupId=org.acme \\ -DartifactId=quarkus-greeting \\ -Dversion=1.0-SNAPSHOT \\ -Dquarkus.nameBase="Greeting Extension" ``` 2. Update the parent pom.xml plugin management section too contain: ``` <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <systemPropertyVariables> <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> <maven.home>${maven.home}</maven.home> </systemPropertyVariables> </configuration> </plugin> ``` 3. Run the command: ``` $ mvn clean verify ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: ``` Darwin mac.local 17.7.0 Darwin Kernel Version 17.7.0: Sun Jun 2 20:31:42 PDT 2019; root:xnu-4570.71.46~1/RELEASE_X86_64 x86_64 ``` - Output of `java -version`: ``` openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02) OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing) ``` - GraalVM version (if different from Java): - - Quarkus version or git rev: ``` 1.10.5.Final ``` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): ``` Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Volumes/Data/Users/basp/.sdkman/candidates/maven/current Java version: 11.0.7, vendor: GraalVM Community, runtime: /Volumes/Data/Users/basp/.sdkman/candidates/java/20.1.0.r11-grl Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac" ```
771d0b74b9fa1de4dff81f53556ad90c4c1e99af
d2b2e3f5b1b65dabcc289a18bd8a6d1ccbbf6751
https://github.com/quarkusio/quarkus/compare/771d0b74b9fa1de4dff81f53556ad90c4c1e99af...d2b2e3f5b1b65dabcc289a18bd8a6d1ccbbf6751
diff --git a/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java b/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java index 10a0eaabb28..bea249e22f5 100644 --- a/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java +++ b/devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class [=artifactIdBaseCamelCase]DevModeTest { +public class [=artifactIdBaseCamelCase]DevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java index 36edbcfa75b..7b4e92a348f 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class AddToBomDevModeTest { +public class AddToBomDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java index ce6f909b567..5890739d629 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class ItestDevModeTest { +public class ItestDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java index 16ad0c52487..c6294029a5d 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class MinimalExtensionDevModeTest { +public class MinimalExtensionDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java index 28366191262..9786b73a468 100644 --- a/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class WithGrandParentDevModeTest { +public class WithGrandParentDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-current-directory-project/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java b/integration-tests/maven/src/test/resources/expected/new-extension-current-directory-project/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java index 6132fc535f3..d1a5fb8fc76 100644 --- a/integration-tests/maven/src/test/resources/expected/new-extension-current-directory-project/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/new-extension-current-directory-project/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class MyExtDevModeTest { +public class MyExtDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-project-with-jboss-parent/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java b/integration-tests/maven/src/test/resources/expected/new-extension-project-with-jboss-parent/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java index 6132fc535f3..d1a5fb8fc76 100644 --- a/integration-tests/maven/src/test/resources/expected/new-extension-project-with-jboss-parent/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/new-extension-project-with-jboss-parent/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class MyExtDevModeTest { +public class MyExtDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); diff --git a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java index 6132fc535f3..d1a5fb8fc76 100644 --- a/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java +++ b/integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java @@ -8,7 +8,7 @@ import io.quarkus.test.QuarkusDevModeTest; -class MyExtDevModeTest { +public class MyExtDevModeTest { @RegisterExtension static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() // Start hot reload (DevMode) test with your extension loaded .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
['integration-tests/maven/src/test/resources/expected/create-extension-pom-minimal/minimal-extension/deployment/src/test/java/org/acme/my/project/minimal/extension/test/MinimalExtensionDevModeTest.java', 'devtools/maven/src/main/resources/create-extension-templates/DevModeTest.java', 'integration-tests/maven/src/test/resources/expected/new-extension-current-directory-project/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java', 'integration-tests/maven/src/test/resources/expected/create-extension-pom-add-to-bom/add-to-bom/deployment/src/test/java/org/acme/my/project/add/to/bom/test/AddToBomDevModeTest.java', 'integration-tests/maven/src/test/resources/expected/new-extension-project-with-jboss-parent/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java', 'integration-tests/maven/src/test/resources/expected/new-extension-project/my-ext/deployment/src/test/java/org/acme/my/ext/test/MyExtDevModeTest.java', 'integration-tests/maven/src/test/resources/expected/create-extension-pom-with-grand-parent/with-grand-parent/deployment/src/test/java/org/acme/myproject/with/grand/parent/test/WithGrandParentDevModeTest.java', 'integration-tests/maven/src/test/resources/expected/create-extension-pom-itest/itest/deployment/src/test/java/org/acme/my/project/itest/test/ItestDevModeTest.java']
{'.java': 8}
8
8
0
0
8
14,212,969
2,772,552
369,743
3,934
100
27
2
1
5,326
507
1,498
105
0
8
2021-01-08T11:04: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,887
quarkusio/quarkus/13577/13484
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13484
https://github.com/quarkusio/quarkus/pull/13577
https://github.com/quarkusio/quarkus/pull/13577
1
fixes
Maven Devmode in Quarkus 1.10.0 not working when maven-toolchains-plugin is configured
**Describe the bug** When migrating from Quarkus 1.9.2.Final to 1.10.0.Final launching our maven projects (which have the [maven-toolchains-plugin](https://maven.apache.org/plugins/maven-toolchains-plugin/) configured) in dev mode fails. **Expected behavior** Executing `mvn quarkus:dev` should not fail to launch the application with Quarkus 1.10.0.Final **Actual behavior** Executing `mvn quarkus:dev` with Quarkus 1.10.0.Final results in: ``` C:\\>mvn quarkus:dev [INFO] Scanning for projects... [INFO] [INFO] --------------------------< com.example:test >-------------------------- [INFO] Building test 1.0.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- quarkus-maven-plugin:1.10.0.Final:dev (default-cli) @ test --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.387 s [INFO] Finished at: 2020-11-25T20:56:53+01:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.10.0.Final:dev (default-cli) on project test: Unable to execute mojo: The parameters 'toolchains' for goal org.apache.maven.plugins:maven-toolchains-plugin:3.0.0:toolchain are missing or invalid -> [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 ``` **To Reproduce** Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).](url) Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. create a ~/.m2/toolchains.xml file containing ```xml <?xml version="1.0" encoding="ISO-8859-1"?> <toolchains> <toolchain> <type>jdk</type> <provides> <version>11</version> <vendor>openjdk</vendor> </provides> <configuration> <jdkHome>/path/to/java11</jdkHome> </configuration> </toolchain> </toolchains> ``` 1. unzip the [test-project.zip](https://github.com/quarkusio/quarkus/files/5599063/test-project.zip) 1. run `mvn quarkus:dev` in the project folder **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Microsoft Windows [Version 10.0.18363.1139] - Output of `java -version`: openjdk version "11.0.9.1" 2020-11-04 LTS - GraalVM version (if different from Java): - Quarkus version or git rev: Quarkus 1.10.0.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) **Additional context** The issue might be introduced via https://github.com/quarkusio/quarkus/pull/12973
c2488e1b98ecce73abdfc2d9ea4119a98de602c5
d4250ca24adbe991dadc9eb10cacdc176327837a
https://github.com/quarkusio/quarkus/compare/c2488e1b98ecce73abdfc2d9ea4119a98de602c5...d4250ca24adbe991dadc9eb10cacdc176327837a
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 045924bd007..d39e7899552 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -35,6 +35,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Resource; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.BuildPluginManager; @@ -419,24 +420,39 @@ private void executeIfConfigured(String pluginGroupId, String pluginArtifactId, version(plugin.getVersion()), plugin.getDependencies()), goal(goal), - getPluginConfig(plugin), + getPluginConfig(plugin, goal), executionEnvironment( project, session, pluginManager)); } - private Xpp3Dom getPluginConfig(Plugin plugin) { - Xpp3Dom configuration = configuration(); - Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration(); - if (pluginConfiguration != null) { - //Filter out `test*` configurations - for (Xpp3Dom child : pluginConfiguration.getChildren()) { + private Xpp3Dom getPluginConfig(Plugin plugin, String goal) { + Xpp3Dom mergedConfig = null; + if (!plugin.getExecutions().isEmpty()) { + for (PluginExecution exec : plugin.getExecutions()) { + if (exec.getConfiguration() != null && exec.getGoals().contains(goal)) { + mergedConfig = mergedConfig == null ? (Xpp3Dom) exec.getConfiguration() + : Xpp3Dom.mergeXpp3Dom(mergedConfig, (Xpp3Dom) exec.getConfiguration(), true); + } + } + } + + if ((Xpp3Dom) plugin.getConfiguration() != null) { + mergedConfig = mergedConfig == null ? (Xpp3Dom) plugin.getConfiguration() + : Xpp3Dom.mergeXpp3Dom(mergedConfig, (Xpp3Dom) plugin.getConfiguration(), true); + } + + final Xpp3Dom configuration = configuration(); + if (mergedConfig != null) { + // Filter out `test*` configurations + for (Xpp3Dom child : mergedConfig.getChildren()) { if (!child.getName().startsWith("test")) { configuration.addChild(child); } } } + return configuration; }
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
13,517,868
2,638,651
352,059
3,722
1,512
324
30
1
3,092
304
848
69
4
2
2020-12-01T08:38:59
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,888
quarkusio/quarkus/13546/13508
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13508
https://github.com/quarkusio/quarkus/pull/13546
https://github.com/quarkusio/quarkus/pull/13546
1
fixes
JBang project fails to start using 1.10.0.Final version
**Describe the bug** JBang project fails to start using 1.10.0.Final version for dependencies version **Expected behavior** It should be able to start **Actual behavior** Fails to start with the following postBuild error > [jbang] Resolving dependencies... [jbang] Resolving io.quarkus:quarkus-resteasy:1.10.0.Final...Done [jbang] Dependencies resolved [jbang] Building jar... [jbang] Post build with io.quarkus.launcher.JBangIntegration Warning: failed to load configurator: java.util.ServiceConfigurationError: org.jboss.logmanager.EmbeddedConfigurator: Provider io.quarkus.bootstrap.logging.InitialConfigurator not a subtype at java.util.ServiceLoader.fail(ServiceLoader.java:239) at java.util.ServiceLoader.access$300(ServiceLoader.java:185) at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at org.jboss.logmanager.LogContext.getConfigurator(LogContext.java:222) at org.jboss.logmanager.LogContext.<clinit>(LogContext.java:38) at org.slf4j.impl.Slf4jLoggerFactory.getLogger(Slf4jLoggerFactory.java:34) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388) at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.<clinit>(DefaultRepositoryEventDispatcher.java:45) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:164) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125) at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278) at org.eclipse.aether.internal.impl.DefaultMetadataResolver.initService(DefaultMetadataResolver.java:119) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125) at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278) at org.apache.maven.repository.internal.DefaultVersionResolver.initService(DefaultVersionResolver.java:108) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125) at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.initService(DefaultRepositorySystem.java:143) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.newInstance(DefaultServiceLocator.java:169) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstances(DefaultServiceLocator.java:139) at org.eclipse.aether.impl.DefaultServiceLocator$Entry.getInstance(DefaultServiceLocator.java:125) at org.eclipse.aether.impl.DefaultServiceLocator.getService(DefaultServiceLocator.java:278) at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.newRepositorySystem(BootstrapMavenContext.java:662) at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRepositorySystem(BootstrapMavenContext.java:223) at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.resolveRemoteRepos(BootstrapMavenContext.java:476) at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getRemoteRepositories(BootstrapMavenContext.java:231) at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at dev.jbang.IntegrationManager.runIntegration(IntegrationManager.java:94) at dev.jbang.cli.BaseBuildCommand.buildJar(BaseBuildCommand.java:206) at dev.jbang.cli.BaseBuildCommand.build(BaseBuildCommand.java:129) at dev.jbang.cli.Run.prepareArtifacts(Run.java:70) at dev.jbang.cli.Run.doCall(Run.java:59) at dev.jbang.cli.BaseCommand.call(BaseCommand.java:80) at dev.jbang.cli.BaseCommand.call(BaseCommand.java:12) at picocli.CommandLine.executeUserObject(CommandLine.java:1933) at picocli.CommandLine.access$1200(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332) at picocli.CommandLine$RunLast.handle(CommandLine.java:2326) at picocli.CommandLine$RunLast.handle(CommandLine.java:2291) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159) at picocli.CommandLine.execute(CommandLine.java:2058) at dev.jbang.Main.main(Main.java:14) Nov 27, 2020 9:25:43 AM io.quarkus.deployment.QuarkusAugmentor run WARN: Using Java versions older than 11 to build Quarkus applications is deprecated and will be disallowed in a future release! [jbang] [ERROR] Issue running postBuild() [jbang] Run with --verbose for more details **To Reproduce** Steps to reproduce the behavior: 1. Generate a new JBang project using the command `jbang init -t qrest test.java` 2. Edit `test.java` file DEPS area dependency version to 1.10.0.Final version (//DEPS io.quarkus:quarkus-resteasy:1.10.0.Final) 3. Run project by executing `jbang test.java`
47e80c520dab5789ba4c82d8c2de9fb45377af60
d33b2b7f41b43a9694c420de2ca2630efed03f00
https://github.com/quarkusio/quarkus/compare/47e80c520dab5789ba4c82d8c2de9fb45377af60...d33b2b7f41b43a9694c420de2ca2630efed03f00
diff --git a/core/launcher/src/main/java/io/quarkus/launcher/JBangIntegration.java b/core/launcher/src/main/java/io/quarkus/launcher/JBangIntegration.java index e740b106183..68ff95ddc95 100644 --- a/core/launcher/src/main/java/io/quarkus/launcher/JBangIntegration.java +++ b/core/launcher/src/main/java/io/quarkus/launcher/JBangIntegration.java @@ -40,7 +40,8 @@ public Class<?> loadClass(String name) throws ClassNotFoundException { @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { - if (name.startsWith("org.") && !(name.startsWith("org.xml.") || name.startsWith("org.w3c."))) { + if (name.startsWith("org.") && !(name.startsWith("org.xml.") || name.startsWith("org.w3c.") + || name.startsWith("org.jboss."))) { //jbang has some but not all of the maven resolver classes we need on its //class path. These all start with org. so we filter them out to make sure //we get a complete class path @@ -51,7 +52,8 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE @Override public URL getResource(String name) { - if (name.startsWith("org/") && !(name.startsWith("org/xml/") || name.startsWith("org/w3c/"))) { + if (name.startsWith("org/") && !(name.startsWith("org/xml/") || name.startsWith("org/w3c/") + || name.startsWith("org/jboss/"))) { //jbang has some but not all of the maven resolver classes we need on its //class path. These all start with org. so we filter them out to make sure //we get a complete class path @@ -62,7 +64,8 @@ public URL getResource(String name) { @Override public Enumeration<URL> getResources(String name) throws IOException { - if (name.startsWith("org/") && !(name.startsWith("org/xml/") || name.startsWith("org/w3c/"))) { + if (name.startsWith("org/") && !(name.startsWith("org/xml/") || name.startsWith("org/w3c/") + || name.startsWith("org/jboss/"))) { //jbang has some but not all of the maven resolver classes we need on its //class path. These all start with org. so we filter them out to make sure //we get a complete class path
['core/launcher/src/main/java/io/quarkus/launcher/JBangIntegration.java']
{'.java': 1}
1
1
0
0
1
13,494,314
2,634,227
351,417
3,710
959
190
9
1
6,922
272
1,487
92
0
0
2020-11-30T01:40: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,890
quarkusio/quarkus/13418/13416
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13416
https://github.com/quarkusio/quarkus/pull/13418
https://github.com/quarkusio/quarkus/pull/13418
1
fixes
gRPC port not well configured in kubernetes.yml
**Describe the bug** The gRPC port defined in the application.properties is not reported in the kubernetes.yml generated. It’s only the default one that is used (9000) **Expected behavior** The specific gRPC port defined in the application.properties is used to defined service and container ports in the kubernetes.yml generated. **Actual behavior** The default gRPC port (9000) is defined in the kubernetes.yml for the service and the container port Kubernetes. yml generated : ```properties --- apiVersion: v1 kind: Service .... spec: ports: - name: http port: 3000 targetPort: 3000 - name: grpc-server port: 9000 targetPort: 9000 ... spec: .... ports: - containerPort: 3000 name: http protocol: TCP - containerPort: 9000 name: grpc-server protocol: TCP ``` **To Reproduce** https://github.com/elamotte7/mk8s-quarkus-ac/tree/main/grpc-server-k8s Steps to reproduce the behavior: 1. ./mvnw clean install -Dquarkus.profile=microk8s 2. Look at /target/kubernetes/kubernetes.yml **Configuration** ```properties quarkus.http.port=3000 ## gRPC server quarkus.grpc.server.port=3001 ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Darwin linux-d02699e69504.home 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64 - Output of `java -version`: openjdk version "11.0.4" 2019-07-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode) - GraalVM version (if different from Java): openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03) OpenJDK 64-Bit Server VM GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03, mixed mode, sharing) - Quarkus version or git rev: 1.9.2.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/coloneld/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.4, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home Default locale: fr_FR, platform encoding: UTF-8 OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac" Thanks for your help
068235a7d5fcc81a3df8b8c0a47e5fa09882cb7e
655ed003e85ebdcf7f92b7f62994d4a2fde64911
https://github.com/quarkusio/quarkus/compare/068235a7d5fcc81a3df8b8c0a47e5fa09882cb7e...655ed003e85ebdcf7f92b7f62994d4a2fde64911
diff --git a/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServerProcessor.java b/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServerProcessor.java index 1176d3c9fc4..f12aa9bf1dd 100644 --- a/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServerProcessor.java +++ b/extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServerProcessor.java @@ -64,7 +64,7 @@ void discoverBindableServices(BuildProducer<BindableServiceBuildItem> bindables, @BuildStep(onlyIf = IsNormal.class) public KubernetesPortBuildItem registerGrpcServiceInKubernetes(List<BindableServiceBuildItem> bindables) { if (!bindables.isEmpty()) { - int port = ConfigProvider.getConfig().getOptionalValue("quarkus.grpc-server.port", Integer.class) + int port = ConfigProvider.getConfig().getOptionalValue("quarkus.grpc.server.port", Integer.class) .orElse(9000); return new KubernetesPortBuildItem(port, GRPC_SERVER); }
['extensions/grpc/deployment/src/main/java/io/quarkus/grpc/deployment/GrpcServerProcessor.java']
{'.java': 1}
1
1
0
0
1
11,856,702
2,317,892
308,302
3,282
221
44
2
1
2,495
274
793
73
1
2
2020-11-22T08:42:09
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,892
quarkusio/quarkus/13391/13390
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13390
https://github.com/quarkusio/quarkus/pull/13391
https://github.com/quarkusio/quarkus/pull/13391
1
fixes
Quarkus GRPC client is setting wrong values for maxInboundMetadataSize and maxInboundMessageSize
**Describe the bug** The GRPC Channels class is setting user settings wrongly (quarkus/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java): ``` .maxInboundMetadataSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_HEADER_LIST_SIZE)) .maxInboundMetadataSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_MESSAGE_SIZE)) ``` Because of that the quarkus.grpc.clients."service-name".max-inbound-message-size setting does nothing. And the server part doesn't have a way of setting the max inbound metadata size. **Expected behavior** The runtime config uses the maxInboundMessageSize config so the the maxInboundMessageSize parameter, and the maxInboundMetadataSize config to set the maxInboundMetadataSize parameter **Actual behavior** The runtime config doesn't set the maxInboundMessageSize and uses the maxInboundMessageSize to set maxInboundMetadataSize **To Reproduce** Steps to reproduce the behavior: 1. Set the quarkus.grpc.clients."service-name".max-inbound-message-size config to 8mb 2. It won't set the max-inbound-message-size 3. Receive a message greater than 4mb and it will fail
068235a7d5fcc81a3df8b8c0a47e5fa09882cb7e
46380c43ddfa25046cd6aa29be2c758b48823620
https://github.com/quarkusio/quarkus/compare/068235a7d5fcc81a3df8b8c0a47e5fa09882cb7e...46380c43ddfa25046cd6aa29be2c758b48823620
diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java index 180b756ac87..75c5619dacf 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java @@ -278,6 +278,11 @@ public void handle(HttpServerOptions options) { if (configuration.maxInboundMessageSize.isPresent()) { builder.maxInboundMessageSize(configuration.maxInboundMessageSize.getAsInt()); } + + if (configuration.maxInboundMetadataSize.isPresent()) { + builder.maxInboundMetadataSize(configuration.maxInboundMetadataSize.getAsInt()); + } + Optional<Duration> handshakeTimeout = configuration.handshakeTimeout; if (handshakeTimeout.isPresent()) { builder.handshakeTimeout(handshakeTimeout.get().toMillis(), TimeUnit.MILLISECONDS); diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcServerConfiguration.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcServerConfiguration.java index 37f3d6ac6a6..ef18c860947 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcServerConfiguration.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcServerConfiguration.java @@ -34,6 +34,12 @@ public class GrpcServerConfiguration { */ public @ConfigItem OptionalInt maxInboundMessageSize; + /** + * The max inbound metadata size in bytes + */ + @ConfigItem + public OptionalInt maxInboundMetadataSize; + /** * The SSL/TLS config. */ diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java index 203c483995d..464c79fb500 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java @@ -69,8 +69,8 @@ public static Channel createChannel(String name) throws SSLException { .keepAliveWithoutCalls(config.keepAliveWithoutCalls) .maxHedgedAttempts(config.maxHedgedAttempts) .maxRetryAttempts(config.maxRetryAttempts) - .maxInboundMetadataSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_HEADER_LIST_SIZE)) - .maxInboundMetadataSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_MESSAGE_SIZE)) + .maxInboundMetadataSize(config.maxInboundMetadataSize.orElse(DEFAULT_MAX_HEADER_LIST_SIZE)) + .maxInboundMessageSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_MESSAGE_SIZE)) .negotiationType(NegotiationType.valueOf(config.negotiationType.toUpperCase())); if (config.retry) {
['extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcServerConfiguration.java', 'extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java', 'extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java']
{'.java': 3}
3
3
0
0
3
11,856,702
2,317,892
308,302
3,282
727
143
15
3
1,156
110
255
24
0
1
2020-11-19T19:18:35
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,893
quarkusio/quarkus/13371/13262
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13262
https://github.com/quarkusio/quarkus/pull/13371
https://github.com/quarkusio/quarkus/pull/13371
1
resolves
Error with RoutingContext Inject with Reactive routing
**Describe the bug** If I inject RoutingContext in a RequestScoped bean, an error are throwed when I try to get him. The problem is identified with reactive route (normal ou blocking handler). With Jax RS service, it's OK. **Expected behavior** Access RoutingContext bean inject in RequestScoped bean. **Actual behavior** ``` Reported exception: SLF4J: Failed toString() invocation on an object of type [io.quarkus.RequestScopedService_ClientProxy] Reported exception: javax.enterprise.inject.IllegalProductException: Normal scoped producer method may not return null: io.quarkus.vertx.http.runtime.CurrentVertxRequest.getCurrent() at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.create(CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.zig:178) at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.create(CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.zig:197) at io.quarkus.arc.impl.RequestContext.get(RequestContext.java:67) at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_ClientProxy.arc$delegate(CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_ClientProxy.zig:100) at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_ClientProxy.toString(CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_ClientProxy.zig:942) at java.base/java.lang.String.valueOf(String.java:2951) at io.quarkus.RequestScopedService.toString(RequestScopedService.java:20) at io.quarkus.RequestScopedService_ClientProxy.toString(RequestScopedService_ClientProxy.zig:161) at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:277) at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:249) at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:211) at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:161) at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:124) at org.jboss.slf4j.JBossLoggerAdapter.info(JBossLoggerAdapter.java:183) at io.quarkus.TestRoute.test(TestRoute.java:21) at io.quarkus.TestRoute_RouteHandler_test_996e1735fd0007ce67bd96d669ec34af05f4f2db.invoke(TestRoute_RouteHandler_test_996e1735fd0007ce67bd96d669ec34af05f4f2db.zig:109) at io.quarkus.vertx.web.runtime.RouteHandler.handle(RouteHandler.java:53) at io.quarkus.vertx.web.runtime.RouteHandler.handle(RouteHandler.java:17) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:95) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$16.handle(VertxHttpRecorder.java:1080) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$16.handle(VertxHttpRecorder.java:1051) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:306) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:284) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:85) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:74) at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) ``` **To Reproduce** With the attach project ``` $ curl localhost:8080/reactive/ javax.enterprise.inject.IllegalProductException: Normal scoped producer method may not return null: io.quarkus.vertx.http.runtime.CurrentVertxRequest.getCurrent() at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.create(CurrentVertxRequest_ProducerMethod_getCurrent_6dc23d16d53ba5c34e1e7b6f54290fd7b9aebd76_Bean.zig:178) ... [bug-inject-routing-context.tar.gz](https://github.com/quarkusio/quarkus/files/5532303/bug-inject-routing-context.tar.gz) [bug-inject-routing-context.tar.gz](https://github.com/quarkusio/quarkus/files/5532306/bug-inject-routing-context.tar.gz) 2020-11-12 18:45:46,881 INFO [io.qua.TestRoute] (vert.x-eventloop-thread-16) RequestScopedService: [FAILED toString()] $ curl localhost:8080/jaxrs/ 2020-11-12 18:46:31,058 INFO [io.qua.TestResource] (executor-thread-1) RequestScopedService: RequestScopedService{routingContext=io.vertx.ext.web.impl.RoutingContextImpl@4c88e5f5} ``` [bug-inject-routing-context.tar.gz](https://github.com/quarkusio/quarkus/files/5532316/bug-inject-routing-context.tar.gz)
0112d3b38961b2dd9d43b1ab46ea587b44809c12
a63ca77baaf6651a068990da0a6d51df873120db
https://github.com/quarkusio/quarkus/compare/0112d3b38961b2dd9d43b1ab46ea587b44809c12...a63ca77baaf6651a068990da0a6d51df873120db
diff --git a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java index c9e2fe6b6f8..425efffb2cf 100644 --- a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java +++ b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java @@ -27,6 +27,7 @@ import io.quarkus.vertx.web.runtime.MultiJsonArraySupport; import io.quarkus.vertx.web.runtime.MultiSseSupport; import io.quarkus.vertx.web.runtime.MultiSupport; +import io.quarkus.vertx.web.runtime.RouteHandler; import io.quarkus.vertx.web.runtime.RouteHandlers; import io.quarkus.vertx.web.runtime.ValidationSupport; import io.smallrye.mutiny.Multi; @@ -169,7 +170,7 @@ class Methods { .ofMethod(InjectableBean.class, "destroy", void.class, Object.class, CreationalContext.class); - static final MethodDescriptor OBJECT_CONSTRUCTOR = MethodDescriptor.ofConstructor(Object.class); + static final MethodDescriptor ROUTE_HANDLER_CONSTRUCTOR = MethodDescriptor.ofConstructor(RouteHandler.class); static final MethodDescriptor ROUTE_HANDLERS_SET_CONTENT_TYPE = MethodDescriptor .ofMethod(RouteHandlers.class, "setContentType", void.class, RoutingContext.class, String.class); diff --git a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java index e9f2d1991b5..4e7bae6d14a 100644 --- a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java +++ b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java @@ -388,8 +388,6 @@ void addAdditionalRoutes( } detectConflictingRoutes(matchers); - - recorder.clearCacheOnShutdown(shutdown); } @BuildStep(onlyIf = IsDevelopment.class) @@ -522,7 +520,7 @@ private String generateHandler(HandlerDescriptor desc, BeanInfo bean, MethodInfo + HashUtil.sha1(sigBuilder.toString() + hashSuffix); ClassCreator invokerCreator = ClassCreator.builder().classOutput(classOutput).className(generatedName) - .interfaces(RouteHandler.class).build(); + .superClass(RouteHandler.class).build(); // Initialized state FieldCreator beanField = invokerCreator.getFieldCreator("bean", InjectableBean.class) @@ -558,7 +556,7 @@ void implementConstructor(BeanInfo bean, ClassCreator invokerCreator, FieldCreat FieldCreator containerField, FieldCreator validatorField) { MethodCreator constructor = invokerCreator.getMethodCreator("<init>", void.class); // Invoke super() - constructor.invokeSpecialMethod(Methods.OBJECT_CONSTRUCTOR, constructor.getThis()); + constructor.invokeSpecialMethod(Methods.ROUTE_HANDLER_CONSTRUCTOR, constructor.getThis()); ResultHandle containerHandle = constructor .invokeStaticMethod(Methods.ARC_CONTAINER); diff --git a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/SimpleRouteTest.java b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/SimpleRouteTest.java index c2d0ef263f2..d36d20beffd 100644 --- a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/SimpleRouteTest.java +++ b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/SimpleRouteTest.java @@ -54,6 +54,7 @@ public void testSimpleRoute() { given().contentType("text/plain").body("world") .post("/body").then().body(is("Hello world!")); when().get("/request").then().statusCode(200).body(is("HellO!")); + when().get("/inject?foo=Hey").then().statusCode(200).body(is("Hey")); } @Test @@ -108,6 +109,11 @@ void request(RoutingContext context) { context.response().setStatusCode(200).end(transformer.transform("Hello!")); } + @Route + void inject(RoutingExchange exchange) { + exchange.ok(transformer.getFoo()); + } + } static class SimpleRoutesBean { @@ -157,10 +163,17 @@ String generate(String name) { @RequestScoped static class Transformer { + @Inject + RoutingContext context; + String transform(String message) { return message.replace('o', 'O'); } + String getFoo() { + return context.request().getParam("foo"); + } + } } diff --git a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandler.java b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandler.java index 024d5dd1475..f378da5ee0e 100644 --- a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandler.java +++ b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandler.java @@ -1,8 +1,12 @@ package io.quarkus.vertx.web.runtime; +import javax.enterprise.event.Event; + import io.quarkus.arc.Arc; import io.quarkus.arc.InjectableContext; import io.quarkus.arc.ManagedContext; +import io.quarkus.security.identity.SecurityIdentity; +import io.quarkus.vertx.http.runtime.CurrentVertxRequest; import io.quarkus.vertx.http.runtime.security.QuarkusHttpUser; import io.quarkus.vertx.web.Route; import io.vertx.core.AsyncResult; @@ -14,31 +18,40 @@ * * @see Route */ -public interface RouteHandler extends Handler<RoutingContext> { +public abstract class RouteHandler implements Handler<RoutingContext> { + + private final Event<SecurityIdentity> securityIdentityEvent; + private final CurrentVertxRequest currentVertxRequest; + + public RouteHandler() { + this.securityIdentityEvent = Arc.container().beanManager().getEvent().select(SecurityIdentity.class); + this.currentVertxRequest = Arc.container().instance(CurrentVertxRequest.class).get(); + } /** * Invokes the route method. * * @param context */ - void invoke(RoutingContext context); + public abstract void invoke(RoutingContext context); @Override - default void handle(RoutingContext context) { + public void handle(RoutingContext context) { QuarkusHttpUser user = (QuarkusHttpUser) context.user(); ManagedContext requestContext = Arc.container().requestContext(); //todo: how should we handle non-proactive authentication here? if (requestContext.isActive()) { if (user != null) { - RouteHandlers.fireSecurityIdentity(user.getSecurityIdentity()); + securityIdentityEvent.fire(user.getSecurityIdentity()); } invoke(context); } else { try { // Activate the context, i.e. set the thread locals requestContext.activate(); + currentVertxRequest.setCurrent(context); if (user != null) { - RouteHandlers.fireSecurityIdentity(user.getSecurityIdentity()); + securityIdentityEvent.fire(user.getSecurityIdentity()); } // Reactive routes can use async processing (e.g. mutiny Uni/Multi) and context propagation // 1. Store the state (which is basically a shared Map instance) diff --git a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandlers.java b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandlers.java index 7bc476142e6..6303c0be1c7 100644 --- a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandlers.java +++ b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandlers.java @@ -1,10 +1,5 @@ package io.quarkus.vertx.web.runtime; -import javax.enterprise.event.Event; - -import io.quarkus.arc.Arc; -import io.quarkus.arc.impl.LazyValue; -import io.quarkus.security.identity.SecurityIdentity; import io.vertx.core.Handler; import io.vertx.core.http.HttpServerResponse; import io.vertx.ext.web.RoutingContext; @@ -16,9 +11,6 @@ private RouteHandlers() { static final String CONTENT_TYPE = "content-type"; - private static final LazyValue<Event<SecurityIdentity>> SECURITY_IDENTITY_EVENT = new LazyValue<>( - RouteHandlers::createEvent); - public static void setContentType(RoutingContext context, String defaultContentType) { HttpServerResponse response = context.response(); context.addHeadersEndHandler(new Handler<Void>() { @@ -37,16 +29,4 @@ public void handle(Void aVoid) { }); } - static void fireSecurityIdentity(SecurityIdentity identity) { - SECURITY_IDENTITY_EVENT.get().fire(identity); - } - - static void clear() { - SECURITY_IDENTITY_EVENT.clear(); - } - - private static Event<SecurityIdentity> createEvent() { - return Arc.container().beanManager().getEvent().select(SecurityIdentity.class); - } - } diff --git a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java index 031b3b0eaf0..716a29b5a22 100644 --- a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java +++ b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java @@ -3,7 +3,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.function.Function; -import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; import io.quarkus.vertx.http.runtime.RouterProducer; import io.vertx.core.Handler; @@ -70,13 +69,4 @@ public io.vertx.ext.web.Route apply(Router router) { }; } - public void clearCacheOnShutdown(ShutdownContext shutdown) { - shutdown.addShutdownTask(new Runnable() { - @Override - public void run() { - RouteHandlers.clear(); - } - }); - } - }
['extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java', 'extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java', 'extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/VertxWebRecorder.java', 'extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandler.java', 'extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/SimpleRouteTest.java', 'extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/RouteHandlers.java']
{'.java': 6}
6
6
0
0
6
11,861,376
2,318,770
308,427
3,283
2,834
507
62
5
6,157
206
1,689
79
3
2
2020-11-19T09:17: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,894
quarkusio/quarkus/13346/13272
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13272
https://github.com/quarkusio/quarkus/pull/13346
https://github.com/quarkusio/quarkus/pull/13346
1
fixes
Make Quarkus Maven plugin smart "create" consistent with codestarts
**Describe the bug** Currently when providing no arguments to create, it asks: ```shell script Set the project groupId [org.acme.quarkus.sample]: Set the project artifactId [my-quarkus-project]: Set the project version [1.0-SNAPSHOT]: Do you want to create a REST resource? (y/n) [no]: y Set the resource classname [org.acme.quarkus.sample.HelloResource]: Set the resource path [/hello]: /andy ``` **Expected behavior** We should instead ask: ```shell script Set the project groupId [org.acme.quarkus.sample]: Set the project artifactId [my-quarkus-project]: Set the project version [1.0-SNAPSHOT]: What extensions do you wish to add (comma separated list): [] Do you want example code to get started (yes), or just an empty project (no) [yes]? ```
0f15a9a83c75034913aab0f547d4f5f11a532c5a
ef199aba5d327b981bcb53f267c9e04fb9e4dc2d
https://github.com/quarkusio/quarkus/compare/0f15a9a83c75034913aab0f547d4f5f11a532c5a...ef199aba5d327b981bcb53f267c9e04fb9e4dc2d
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 9261b005314..e4a0274c6d3 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java @@ -61,7 +61,10 @@ @Mojo(name = "create", requiresProject = false) public class CreateProjectMojo extends AbstractMojo { - private static final String DEFAULT_GROUP_ID = "org.acme.quarkus.sample"; + private static final String DEFAULT_GROUP_ID = "org.acme"; + private static final String DEFAULT_ARTIFACT_ID = "code-with-quarkus"; + private static final String DEFAULT_VERSION = "1.0.0-SNAPSHOT"; + private static final String DEFAULT_EXTENSIONS = "resteasy"; @Parameter(defaultValue = "${project}") protected MavenProject project; @@ -102,9 +105,22 @@ public class CreateProjectMojo extends AbstractMojo { @Parameter(property = "path") private String path; + /** + * This parameter is only working with the RESTEasy and Spring Web extensions and is going to be removed. + * Use packageName instead. + * + * {@code className} + */ @Parameter(property = "className") + @Deprecated private String className; + /** + * If not set, groupId will be used + */ + @Parameter(property = "packageName") + private String packageName; + @Parameter(property = "buildTool", defaultValue = "MAVEN") private String buildTool; @@ -228,6 +244,7 @@ public void execute() throws MojoExecutionException { .version(projectVersion) .sourceType(sourceType) .className(className) + .packageName(packageName) .extensions(extensions) .legacyCodegen(legacyCodegen) .noExamples(noExamples); @@ -352,15 +369,15 @@ private void askTheUserForMissingValues() throws MojoExecutionException { // If the user has disabled the interactive mode or if the user has specified the artifactId, disable the // user interactions. if (!session.getRequest().isInteractiveMode() || shouldUseDefaults()) { - // Inject default values in all non-set parameters + if (StringUtils.isBlank(projectArtifactId)) { + // we need to set it for the project directory + projectArtifactId = DEFAULT_ARTIFACT_ID; + } if (StringUtils.isBlank(projectGroupId)) { projectGroupId = DEFAULT_GROUP_ID; } - if (StringUtils.isBlank(projectArtifactId)) { - projectArtifactId = "my-quarkus-project"; - } if (StringUtils.isBlank(projectVersion)) { - projectVersion = "1.0-SNAPSHOT"; + projectVersion = DEFAULT_VERSION; } return; } @@ -373,28 +390,43 @@ private void askTheUserForMissingValues() throws MojoExecutionException { if (StringUtils.isBlank(projectArtifactId)) { projectArtifactId = prompter.promptWithDefaultValue("Set the project artifactId", - "my-quarkus-project"); + DEFAULT_ARTIFACT_ID); } if (StringUtils.isBlank(projectVersion)) { projectVersion = prompter.promptWithDefaultValue("Set the project version", - "1.0-SNAPSHOT"); + DEFAULT_VERSION); } - if (StringUtils.isBlank(className)) { - // Ask the user if he want to create a resource - String answer = prompter.promptWithDefaultValue("Do you want to create a REST resource? (y/n)", "no"); - if (isTrueOrYes(answer)) { - String defaultResourceName = projectGroupId.replace("-", ".") - .replace("_", ".") + ".HelloResource"; - className = prompter.promptWithDefaultValue("Set the resource classname", defaultResourceName); - if (StringUtils.isBlank(path)) { - path = prompter.promptWithDefaultValue("Set the resource path ", CreateUtils.getDerivedPath(className)); + if (legacyCodegen) { + if (StringUtils.isBlank(className)) { + // Ask the user if he want to create a resource + String answer = prompter.promptWithDefaultValue("Do you want to create a REST resource? (y/n)", "no"); + if (isTrueOrYes(answer)) { + String defaultResourceName = projectGroupId.replace("-", ".") + .replace("_", ".") + ".HelloResource"; + className = prompter.promptWithDefaultValue("Set the resource classname", defaultResourceName); + if (StringUtils.isBlank(path)) { + path = prompter.promptWithDefaultValue("Set the resource path ", + CreateUtils.getDerivedPath(className)); + } + } else { + className = null; + path = null; } - } else { - className = null; - path = null; } + } else { + if (extensions.isEmpty()) { + extensions = Arrays + .stream(prompter.promptWithDefaultValue("What extensions do you wish to add (comma separated list)", + DEFAULT_EXTENSIONS) + .split(",")) + .map(String::trim).filter(StringUtils::isNotEmpty) + .collect(Collectors.toSet()); + } + String answer = prompter.promptWithDefaultValue( + "Do you want example code to get started (yes), or just an empty project (no)", "yes"); + noExamples = answer.startsWith("n"); } } catch (IOException e) { @@ -417,13 +449,16 @@ private boolean isTrueOrYes(String answer) { } private void sanitizeOptions(SourceType sourceType) { - // If className is null, we won't create the REST resource, if (className != null) { className = sourceType.stripExtensionFrom(className); - if (!className.contains(".")) { - // No package name, inject one - className = projectGroupId.replace("-", ".").replace("_", ".") + "." + className; + int idx = className.lastIndexOf('.'); + if (idx >= 0 && StringUtils.isBlank(packageName)) { + // if it's a full qualified class name, we use the package name part (only if the packageName wasn't already defined) + packageName = className.substring(0, idx); + + // And we strip it from the className + className = className.substring(idx + 1); } if (StringUtils.isBlank(path)) { @@ -432,6 +467,7 @@ private void sanitizeOptions(SourceType sourceType) { path = "/" + path; } } + // if package name is empty, the groupId will be used as part of the CreateProject logic } private void sanitizeExtensions() { diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartData.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartData.java index d54be2a604a..77a35b738f4 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartData.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartData.java @@ -101,6 +101,7 @@ public static Map<String, Object> convertFromLegacy(Map<String, Object> legacy) } } + // TODO remove the class_name convertion when its removed private static String convertClassName(final Map<String, Object> legacyData) { Optional<String> classNameValue = NestedMaps.getValue(legacyData, "class_name"); if (classNameValue.isPresent()) { @@ -119,6 +120,7 @@ private static String convertPackageName(final Map<String, Object> legacyData) { if (packageNameValue.isPresent()) { return packageNameValue.get(); } + // TODO remove this block when class_name is removed Optional<String> classNameValue = NestedMaps.getValue(legacyData, "class_name"); if (classNameValue.isPresent()) { final String className = classNameValue.get(); @@ -127,6 +129,12 @@ private static String convertPackageName(final Map<String, Object> legacyData) { return className.substring(0, idx); } } + + // Default to cleaned groupId if packageName not set + Optional<String> groupIdValue = NestedMaps.getValue(legacyData, "project_groupId"); + if (groupIdValue.isPresent()) { + return groupIdValue.get().replace("-", ".").replace("_", "."); + } return null; } } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java index 942c1421aef..29d046e9806 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java @@ -95,6 +95,10 @@ public CreateProject resourcePath(String resourcePath) { return this; } + /** + * Use packageName instead as this one is only working with RESTEasy and SpringWeb + */ + @Deprecated public CreateProject className(String className) { if (className == null) { return this; @@ -106,6 +110,17 @@ public CreateProject className(String className) { return this; } + public CreateProject packageName(String packageName) { + if (packageName == null) { + return this; + } + if (!(SourceVersion.isName(packageName) && !SourceVersion.isKeyword(packageName))) { + throw new IllegalArgumentException(packageName + " is not a package name"); + } + setValue(PACKAGE_NAME, packageName); + return this; + } + public CreateProject extensions(Set<String> extensions) { if (extensions == null) { return this; @@ -219,7 +234,6 @@ public QuarkusCommandOutcome execute() throws QuarkusCommandException { setValue(IS_SPRING, true); if (containsRESTEasy(extensions)) { values.remove(CLASS_NAME); - values.remove(PACKAGE_NAME); values.remove(RESOURCE_PATH); } } diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java index 8a45c6f909d..e4fd4e1e838 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java @@ -67,6 +67,13 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws invocation.setValue(CLASS_NAME, className); } + // Default to cleaned groupId if packageName not set + final String pkgName = invocation.getStringValue(PACKAGE_NAME); + final String groupId = invocation.getStringValue(PROJECT_GROUP_ID); + if (pkgName == null && groupId != null) { + invocation.setValue(PACKAGE_NAME, groupId.replace("-", ".").replace("_", ".")); + } + final List<AppArtifactCoords> extensionsToAdd = computeCoordsFromQuery(invocation, extensionsQuery); // extensionsToAdd is null when an error occurred while matching extensions 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 d51a6834772..d2ebba6f4e3 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 @@ -60,7 +60,7 @@ public void testProjectGenerationFromScratch() throws MavenInvocationException, Properties properties = new Properties(); properties.put("projectGroupId", "org.acme"); properties.put("projectArtifactId", "acme"); - properties.put("projectVersion", "1.0-SNAPSHOT"); + properties.put("projectVersion", "1.0.0-SNAPSHOT"); InvocationResult result = setup(properties); assertThat(result.getExitCode()).isZero(); @@ -374,9 +374,9 @@ public void testThatDefaultPackageAreReplaced() throws Exception { assertThat(result.getExitCode()).isZero(); // As the directory is not empty (log) navigate to the artifactID directory - testDir = new File(testDir, "my-quarkus-project"); - check(new File(testDir, "src/main/java/org/acme/quarkus/sample/MyGreatResource.java"), - "package org.acme.quarkus.sample;"); + testDir = new File(testDir, "code-with-quarkus"); + check(new File(testDir, "src/main/java/org/acme/MyGreatResource.java"), + "package org.acme;"); } private void check(final File resource, final String contentsToFind) throws IOException { @@ -419,7 +419,7 @@ public void generateNewProjectAndRun() throws Exception { String resp = DevModeTestUtils.getHttpResponse(); assertThat(resp).containsIgnoringCase("ready").containsIgnoringCase("application").containsIgnoringCase("org.acme") - .containsIgnoringCase("1.0-SNAPSHOT"); + .containsIgnoringCase("1.0.0-SNAPSHOT"); String greeting = DevModeTestUtils.getHttpResponse("/hello"); assertThat(greeting).containsIgnoringCase("hello");
['devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java', 'independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/LegacyCreateProjectCommandHandler.java', 'independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartData.java', 'independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/CreateProject.java', 'integration-tests/maven/src/test/java/io/quarkus/maven/it/CreateProjectMojoIT.java']
{'.java': 5}
5
5
0
0
5
11,843,437
2,315,200
308,001
3,280
6,127
1,097
115
4
777
103
199
20
0
2
2020-11-17T17:55: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,874
quarkusio/quarkus/13962/13878
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13878
https://github.com/quarkusio/quarkus/pull/13962
https://github.com/quarkusio/quarkus/pull/13962
1
fixes
Cannot start a mutable-jar built under Windows 10 in docker-container with QUARKUS_LAUNCH_DEVMODE=true
**Describe the bug** When a mutable-jar, that was build on windows 10, is copied to a docker-container and started with `QUARKUS_LAUNCH_DEVMODE=true`, the container terminates by throwing a `java.lang.ClassNotFoundException`. **Expected behavior** Container starts and can be used in conjunction with `quarkus:remote-dev`. **Actual behavior** Container terminates on startup with the following stack trace: ``` Exception in thread "main" java.lang.ClassNotFoundException: io.quarkus.deployment.mutability.DevModeTask at java.base/java.net.URLClassLoader.findClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at io.quarkus.bootstrap.runner.DevModeMediator.doStart(DevModeMediator.java:49) at io.quarkus.bootstrap.runner.DevModeMediator.doDevMode(DevModeMediator.java:29) at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:34) at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:24) ``` **To Reproduce** - Checkout `https://github.com/turing85/quarkus-mutablejar-win10-bug` - Compile project, start docker-container: mvnw clean install -Dquarkus.container-image.build=true && docker run quarkus-bug/hello-app:1.0.0 **Configuration** **Environment (please complete the following information):** - Output of `uname -a` or `ver`: `Microsoft Windows [Version 10.0.19041.685]` - Output of `java -version`: openjdk 11.0.4 2019-07-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode) - GraalVM version (if different from Java): N/A - Quarkus version or git rev: `1.10.3.Final` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\\Users\\Marco\\.m2\\wrapper\\dists\\apache-maven-3.6.3-bin\\1iopthnavndlasol9gbrbg6bf2\\apache-maven-3.6.3 Java version: 11.0.4, vendor: AdoptOpenJDK, runtime: D:\\Java\\AdoptOpenJDK\\jdk-11.0.4.11-hotspot Default locale: en_GB, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
1561bdea9639ae7a7acca1cbe8a083052371862d
fe0879cfdf0e041ad08458adca94a1970cfa5321
https://github.com/quarkusio/quarkus/compare/1561bdea9639ae7a7acca1cbe8a083052371862d...fe0879cfdf0e041ad08458adca94a1970cfa5321
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java index 24997cddd86..b6b337bdc00 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java @@ -599,7 +599,8 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem, Map<AppArtifactKey, List<String>> relativePaths = new HashMap<>(); for (Map.Entry<AppArtifactKey, List<Path>> e : copiedArtifacts.entrySet()) { relativePaths.put(e.getKey(), - e.getValue().stream().map(s -> buildDir.relativize(s).toString()).collect(Collectors.toList())); + e.getValue().stream().map(s -> buildDir.relativize(s).toString().replace("\\\\", "/")) + .collect(Collectors.toList())); } //now we serialize the data needed to build up the reaugmentation class path diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PersistentAppModel.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PersistentAppModel.java index 4ef5aeb91f1..5a0efa6bd7b 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PersistentAppModel.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PersistentAppModel.java @@ -9,10 +9,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * A representation of AppModel, that has been serialized to disk for an existing application. - * + * <p> * This needs a slightly different representation than AppModel */ public class PersistentAppModel implements Serializable { @@ -35,7 +36,7 @@ public PersistentAppModel(String baseName, Map<AppArtifactKey, List<String>> pat this.baseName = baseName; this.userProvidersDirectory = userProvidersDirectory; appArtifact = new SerializedDep(appModel.getAppArtifact(), paths); - appArtifact.paths = Collections.singletonList(appArchivePath); + appArtifact.paths = Collections.singletonList(appArchivePath.replace("\\\\", "/")); deploymentDeps = new ArrayList<>(appModel.getDeploymentDependencies().size()); for (AppDependency i : appModel.getDeploymentDependencies()) { deploymentDeps.add(new SerializedDep(i, paths)); @@ -100,7 +101,11 @@ public SerializedDep(AppArtifact dependency, Map<AppArtifactKey, List<String>> p super(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()); - this.paths = paths.get(dependency.getKey()); + List<String> pathList = paths.get(dependency.getKey()); + if (pathList == null) { + pathList = Collections.emptyList(); + } + this.paths = pathList.stream().map(s -> s.replace("\\\\", "/")).collect(Collectors.toList()); } public SerializedDep(AppDependency dependency, Map<AppArtifactKey, List<String>> paths) {
['core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java', 'independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PersistentAppModel.java']
{'.java': 2}
2
2
0
0
2
13,880,769
2,707,536
361,317
3,825
856
152
14
2
2,335
191
657
45
1
1
2020-12-18T00:16:11
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,872
quarkusio/quarkus/14247/14233
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14233
https://github.com/quarkusio/quarkus/pull/14247
https://github.com/quarkusio/quarkus/pull/14247
1
fixes
"Unrecognized configuration key" regression in 1.11.0.CR1
**Describe the bug** When running in **native** mode with 1.11.0.CR1, we get "Unrecognized configuration key" warnings on a list of properties. those properties are all "quarkus" properties (we do not have any warnings on our applicative properties). some of those properties come from src/main/resources/application.yml, some properties come from runtime provided "application.yml", and some properties are not set at all in any of these 2 files. We do not have this behavior in 1.10.5 native, or 1.11.0.CR1 jvm. The interesting thing is that the program is running normally. that is those properties are correctly read from the config. **Expected behavior** No warnings "Unrecognized configuration key" in native mode. **Actual behavior** here is what we get at startup: ``` __ ____ __ _____ ___ __ ____ ______ --/ __ \\/ / / / _ | / _ \\/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\\ \\ --\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/ 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.logserver.display-env-variables" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.directive.base64" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.console.darken" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.directive.mongodb_uri" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.default-encoding" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.template-exception-handler" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.log-template-exceptions" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.smbj.hostname" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.boolean-format" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.object-wrapper-expose-fields" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.filter."org.jboss.threads".if-starts-with" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.directive.json" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.application.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 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.number-format" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.category."io.quarkus.vault".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 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.wrap-unchecked-exceptions" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.category."com.lodh.arte.ocpdeploy".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 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.logserver.erl-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 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.fallback-on-null-loop-variable" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.filter."org.hibernate.validator.internal.util.Version".if-starts-with" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.profile" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.log.min-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 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.file-paths" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.directive.indent" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.application.version" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:14,762 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.freemarker.directive.yaml" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo 2021-01-11 10:25:15,203 INFO [com.lod.art.log.LogServerHandlerRecorder] (main) Initializing LogServer Agent 2021-01-11 10:25:15,215 INFO [io.quarkus] (main) ocpdeploy 4.1.0-SNAPSHOT native (powered by Quarkus 1.11.0.CR1) started in 0.463s. 2021-01-11 10:25:15,215 INFO [io.quarkus] (main) Profile prod activated. 2021-01-11 10:25:15,215 INFO [io.quarkus] (main) Installed features: [cdi, config-yaml, freemarker, hibernate-validator, kubernetes-client, logserver, mutiny, openshift-client, rest-client, rest-client-jackson, smallrye-context-propagation, smbj, vault] ``` From all of these properties we have 3 cases: ***properties coming from src/main/resources/application.yaml*** ``` quarkus: log: min-level: DEBUG smbj: hostname: ${ocpdeploy.share.hostname:""} freemarker: file-paths: ${ocpdeploy.workspace-path} default-encoding: UTF-8 template-exception-handler: rethrow log-template-exceptions: false wrap-unchecked-exceptions: true fallback-on-null-loop-variable: true boolean-format: c number-format: computer object-wrapper-expose-fields: true directive: base64: ... indent: ... yaml: ... json: ... mongodb_uri: ... logserver: erl-url: ${ocpdeploy.erl.url} ``` which is all quarkus properties, except: ``` vault: kv-secret-engine-version: 1 ``` ***properties coming from runtime provided application.yaml*** ``` logserver: display-env-variables: false log: category: "...": level: DEBUG "io.quarkus.vault": level: DEBUG ``` which is all quarkus properties except vault properties: ``` quarkus: vault: url: ... authentication: kubernetes: role: ... secret-config-kv-path: creds: ... ``` ***properties not coming from our config either runtime or build time*** ``` quarkus.log.console.darken quarkus.log.filter."org.jboss.threads".if-starts-with quarkus.application.name quarkus.log.filter."org.hibernate.validator.internal.util.Version".if-starts-with quarkus.profile quarkus.application.version ``` **To Reproduce** We tried to reproduce in a simple "getting started" example, but did not succeed (instead we stumbled upon https://github.com/quarkusio/quarkus/issues/14229). so unfortunately we do not have a reproducer. I tried printing a few variables at startup (some coming from src/main/resources/application.yml, and some coming from the runtime provided application.yml): ``` @ConfigProperty(name = "quarkus.smbj.hostname") String quarkusSmbjHostname; @ConfigProperty(name = "quarkus.freemarker.default-encoding") String quarkusFreemarkerDefaultEncoding; @ConfigProperty(name = "quarkus.logserver.display-env-variables") Boolean quarkusLogServerDisplayEnvVariables; public void execute() throws InterruptedException, TemplateException, NoSuchAlgorithmException, IOException { log.info("quarkus.smbj.hostname => " + quarkusSmbjHostname); log.info("quarkus.freemarker.default-encoding => " + quarkusFreemarkerDefaultEncoding); log.info("quarkus.logserver.display-env-variables => " + quarkusLogServerDisplayEnvVariables); ``` in jvm mode I get (which is expected): ``` 2021-01-11 18:32:59,313 INFO (main) quarkus.smbj.hostname => ...some value... 2021-01-11 18:32:59,314 INFO (main) quarkus.freemarker.default-encoding => UTF-8 2021-01-11 18:32:59,315 INFO (main) quarkus.logserver.display-env-variables => false ``` in native mode I get the same values, but with the unexpected warnings, such as: ``` 2021-01-11 17:53:50,404 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.smbj.hostname" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo ``` so properties are read appropriately (which explains why the program is running normally). the only issue seems to be those invalid warnings.
2851a887b9ac012dcbf9f8e7341b63b796cb64ae
87715094d0e9430a6cd642359b477625c1d3efd4
https://github.com/quarkusio/quarkus/compare/2851a887b9ac012dcbf9f8e7341b63b796cb64ae...87715094d0e9430a6cd642359b477625c1d3efd4
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java index d561e386b5b..9136c61a379 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java @@ -453,6 +453,9 @@ public void run() { final ConfigPatternMap<Container> runTimeIgnored = ConfigPatternMap .merge(ConfigPatternMap.merge(buildTimePatternMap, buildTimeRunTimePatternMap, combinator), bootstrapPatternMap, combinator); + final ConfigPatternMap<Container> bootstrapIgnored = ConfigPatternMap + .merge(ConfigPatternMap.merge(buildTimePatternMap, + buildTimeRunTimePatternMap, combinator), runTimePatternMap, combinator); final MethodDescriptor siParserBody = generateParserBody(buildTimeRunTimePatternMap, buildTimeRunTimeIgnored, new StringBuilder("siParseKey"), false, Type.BUILD_TIME); @@ -460,7 +463,7 @@ public void run() { new StringBuilder("rtParseKey"), false, Type.RUNTIME); MethodDescriptor bsParserBody = null; if (bootstrapConfigSetupNeeded()) { - bsParserBody = generateParserBody(bootstrapPatternMap, null, + bsParserBody = generateParserBody(bootstrapPatternMap, bootstrapIgnored, new StringBuilder("bsParseKey"), false, Type.BOOTSTRAP); }
['core/deployment/src/main/java/io/quarkus/deployment/configuration/RunTimeConfigurationGenerator.java']
{'.java': 1}
1
1
0
0
1
14,223,570
2,774,575
369,981
3,937
424
79
5
1
11,957
1,386
3,073
153
1
9
2021-01-12T10:27:05
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,756
quarkusio/quarkus/17354/17322
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/17322
https://github.com/quarkusio/quarkus/pull/17354
https://github.com/quarkusio/quarkus/pull/17354
1
resolves
Quarkus random ConcurrentModificationException
## Issue After upgrading from `1.12.2.Final` to `1.13.4.Final` a lot of **random** `java.util.ConcurrentModificationException` are thrown when a rest API call is done. For example, it happens between FE(Angular) and BE communication, but also between micro-services(all Quarkus based). This makes local environment(dev mode) almost unusable. **P.S. This is reproducible only on local, running the dev mode.** Is something changed in this direction between mentioned Quarkus version? How can I debug it further? Please feel free to ask for more information. ## Example Here is an example, when FE calls the BE `/myc/api/user/me` ``` 021-05-18 10:08:05,388 ERROR [io.und.req.io] (executor-thread-37) Exception handling request e981e92b-df4b-4526-8b03-fd23e4e08faf-5 to /myc/api/user/me: java.util.ConcurrentModificationException at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1043) at java.base/java.util.ArrayList$Itr.next(ArrayList.java:997) at io.quarkus.arc.runtime.devconsole.Invocation$Builder.build(Invocation.java:173) at io.quarkus.arc.runtime.devconsole.Invocation$Builder.build(Invocation.java:174) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:71) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32) at com.connectis.myconnectis.adapters.web.infra.filters.AngularResourcesFilter_Subclass.doFilter(AngularResourcesFilter_Subclass.zig:1090) at com.connectis.myconnectis.adapters.web.infra.filters.AngularResourcesFilter_ClientProxy.doFilter(AngularResourcesFilter_ClientProxy.zig:444) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:67) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:247) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:56) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:111) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:108) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1.call(UndertowDeploymentRecorder.java:587) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227) at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:152) at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91) at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$1.handleRequest(UndertowDeploymentRecorder.java:119) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:290) at io.undertow.server.DefaultExchangeHandler.handle(DefaultExchangeHandler.java:18) at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5$1.run(UndertowDeploymentRecorder.java:413) at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:231) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at java.base/java.lang.Thread.run(Thread.java:836) at org.jboss.threads.JBossThread.run(JBossThread.java:501) ``` ## Env Info ### Java version ``` openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Linux amd64-64-Bit Compressed References 20210120_910 (JIT enabled, AOT enabled) OpenJ9 - 345e1b09e OMR - 741e94ea8 JCL - 0a86953833 based on jdk-11.0.10+9) ```
e1c2ba5d62deb298859e376d780f82b7add2462a
ae0320b82f73ebfe606b5e3f8483aa818e213af9
https://github.com/quarkusio/quarkus/compare/e1c2ba5d62deb298859e376d780f82b7add2462a...ae0320b82f73ebfe606b5e3f8483aa818e213af9
diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/Invocation.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/Invocation.java index 0ef49473142..4ac219e7108 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/Invocation.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/Invocation.java @@ -6,6 +6,7 @@ import java.time.ZoneId; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import io.quarkus.arc.InjectableBean; @@ -108,7 +109,8 @@ static class Builder { private long start; private long duration; private Method method; - private List<Builder> children; + // If async processing and the request context is not propagated a new child can be added when/after the builder is built + private final List<Builder> children = new CopyOnWriteArrayList<>(); private Builder parent; private Kind kind; private String message; @@ -159,9 +161,6 @@ Builder setMessage(String message) { } boolean addChild(Builder child) { - if (children == null) { - children = new ArrayList<>(); - } child.setParent(this); return children.add(child); } @@ -169,7 +168,7 @@ boolean addChild(Builder child) { Invocation build() { List<Invocation> invocations = null; if (children != null) { - invocations = new ArrayList<>(children.size()); + invocations = new ArrayList<>(); for (Builder builder : children) { invocations.add(builder.build()); } diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/InvocationInterceptor.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/InvocationInterceptor.java index b48fe233fd9..8b6573f5142 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/InvocationInterceptor.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/InvocationInterceptor.java @@ -58,7 +58,6 @@ public Object monitor(InvocationContext context) throws Exception { Object proceed(Invocation.Builder builder, InvocationContext context, ManagedContext requestContext, InvocationTree tree) throws Exception { long nanoTime = System.nanoTime(); - // Object result; try { return context.proceed(); } catch (Exception e) {
['extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/InvocationInterceptor.java', 'extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/devconsole/Invocation.java']
{'.java': 2}
2
2
0
0
2
16,498,194
3,207,820
425,073
4,482
540
96
10
2
6,506
257
1,546
82
0
2
2021-05-19T11:54: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,860
quarkusio/quarkus/14658/14626
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14626
https://github.com/quarkusio/quarkus/pull/14658
https://github.com/quarkusio/quarkus/pull/14658
1
fixes
quarkus.oidc.auth-server-url is missing in the all configuration guide
**Describe the bug** `quarkus.oidc.auth-server-url` and other found in https://github.com/quarkusio/quarkus/blob/df5f7d27916db069d2bcc0744ced7e79d2b79584/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java are missing in the https://quarkus.io/guides/all-config#quarkus-oidc_quarkus-oidc-openid-connect section. **Expected behavior** properties to be listed **Actual behavior** properties are not listed **To Reproduce** Visit https://quarkus.io/guides/all-config#quarkus-oidc_quarkus-oidc-openid-connect and observe missing properties. **Additional context** I think the generator is not scanning config items from super classes, in this case https://github.com/quarkusio/quarkus/blob/df5f7d27916db069d2bcc0744ced7e79d2b79584/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java hence that's why they are not showing. /cc @miguelsorianod thanks for spotting this.
92deaddfc8f88d248bc54eb952987921f01ea635
4ab3f175cd07cb90eb75a68b394b514273399c8c
https://github.com/quarkusio/quarkus/compare/92deaddfc8f88d248bc54eb952987921f01ea635...4ab3f175cd07cb90eb75a68b394b514273399c8c
diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDoItemFinder.java b/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDoItemFinder.java index f85409c707e..97133943a78 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDoItemFinder.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDoItemFinder.java @@ -19,7 +19,6 @@ import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.stringifyType; import java.io.IOException; -import java.nio.file.Path; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -63,14 +62,16 @@ class ConfigDoItemFinder { private final Properties javaDocProperties; private final Map<String, TypeElement> configGroupQualifiedNameToTypeElementMap; private final FsMap allConfigurationGroups; + private final FsMap allConfigurationRoots; public ConfigDoItemFinder(Set<ConfigRootInfo> configRoots, Map<String, TypeElement> configGroupQualifiedNameToTypeElementMap, - Properties javaDocProperties, Path allConfigurationGroupsDir) { + Properties javaDocProperties, FsMap allConfigurationGroups, FsMap allConfigurationRoots) { this.configRoots = configRoots; this.configGroupQualifiedNameToTypeElementMap = configGroupQualifiedNameToTypeElementMap; this.javaDocProperties = javaDocProperties; - this.allConfigurationGroups = new FsMap(allConfigurationGroupsDir); + this.allConfigurationGroups = allConfigurationGroups; + this.allConfigurationRoots = allConfigurationRoots; } /** @@ -97,6 +98,7 @@ ScannedConfigDocsItemHolder findInMemoryConfigurationItems() throws IOException final List<ConfigDocItem> configDocItems = recursivelyFindConfigItems(element, rootName, rootName, configPhase, false, sectionLevel, true); holder.addConfigRootItems(configRootInfo, configDocItems); + allConfigurationRoots.put(configRootInfo.getClazz().toString(), OBJECT_MAPPER.writeValueAsString(configDocItems)); } return holder; @@ -109,6 +111,27 @@ private List<ConfigDocItem> recursivelyFindConfigItems(Element element, String r ConfigPhase configPhase, boolean withinAMap, int sectionLevel, boolean generateSeparateConfigGroupDocsFiles) throws JsonProcessingException { List<ConfigDocItem> configDocItems = new ArrayList<>(); + TypeElement asTypeElement = (TypeElement) element; + TypeMirror superType = asTypeElement.getSuperclass(); + if (superType.getKind() != TypeKind.NONE) { + String key = superType.toString(); + String rawConfigItems = allConfigurationGroups.get(key); + if (rawConfigItems == null) { + rawConfigItems = allConfigurationRoots.get(key); + } + final List<ConfigDocItem> superTypeConfigItems; + if (rawConfigItems == null) { // element not yet scanned + Element superElement = ((DeclaredType) superType).asElement(); + superTypeConfigItems = recursivelyFindConfigItems(superElement, rootName, parentName, + configPhase, withinAMap, sectionLevel, generateSeparateConfigGroupDocsFiles); + } else { + superTypeConfigItems = OBJECT_MAPPER.readValue(rawConfigItems, LIST_OF_CONFIG_ITEMS_TYPE_REF); + } + + configDocItems.addAll(superTypeConfigItems); + + } + for (Element enclosedElement : element.getEnclosedElements()) { if (!enclosedElement.getKind().isField()) { continue; diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDocItemScanner.java b/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDocItemScanner.java index 1e1a43e1302..f0cf97b161b 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDocItemScanner.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDocItemScanner.java @@ -5,7 +5,6 @@ import static io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil.deriveConfigRootName; import java.io.IOException; -import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -32,15 +31,17 @@ final public class ConfigDocItemScanner { private final Map<String, TypeElement> configGroupsToTypeElement = new HashMap<>(); private final FsMap allExtensionGeneratedDocs; - private final Path allConfigurationGroupsDir = Constants.GENERATED_DOCS_PATH - .resolve("all-configuration-groups-generated-doc"); + private final FsMap allConfigGroupGeneratedDocs; private final FsMultiMap configurationRootsParExtensionFileName; public ConfigDocItemScanner() { this.allExtensionGeneratedDocs = new FsMap(Constants.GENERATED_DOCS_PATH .resolve("all-configuration-roots-generated-doc")); + this.allConfigGroupGeneratedDocs = new FsMap(Constants.GENERATED_DOCS_PATH + .resolve("all-configuration-groups-generated-doc")); this.configurationRootsParExtensionFileName = new FsMultiMap(Constants.GENERATED_DOCS_PATH .resolve("extensions-configuration-roots-list")); + } /** @@ -108,7 +109,7 @@ public Set<ConfigDocGeneratedOutput> scanExtensionsConfigurationItems(Properties Set<ConfigDocGeneratedOutput> configDocGeneratedOutputs = new HashSet<>(); final ConfigDoItemFinder configDoItemFinder = new ConfigDoItemFinder(configRoots, configGroupsToTypeElement, - javaDocProperties, allConfigurationGroupsDir); + javaDocProperties, allConfigGroupGeneratedDocs, allExtensionGeneratedDocs); final ScannedConfigDocsItemHolder inMemoryScannedItemsHolder = configDoItemFinder.findInMemoryConfigurationItems(); if (!inMemoryScannedItemsHolder.isEmpty()) { diff --git a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java index 699b44a587c..60d53bb4af2 100644 --- a/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java +++ b/extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java @@ -6,12 +6,13 @@ import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; +@ConfigGroup public class OidcCommonConfig { /** - * The base URL of the OpenID Connect (OIDC) server, for example, 'https://host:port/auth'. + * The base URL of the OpenID Connect (OIDC) server, for example, `https://host:port/auth`. * OIDC discovery endpoint will be called by default by appending a '.well-known/openid-configuration' path to this URL. * Note if you work with Keycloak OIDC server, make sure the base URL is in the following format: - * 'https://host:port/auth/realms/{realm}' where '{realm}' has to be replaced by the name of the Keycloak realm. + * `https://host:port/auth/realms/{realm}` where `{realm}` has to be replaced by the name of the Keycloak realm. */ @ConfigItem public Optional<String> authServerUrl = Optional.empty(); @@ -39,9 +40,9 @@ public class OidcCommonConfig { /** * The maximum amount of time connecting to the currently unavailable OIDC server will be attempted for. * The number of times the connection request will be repeated is calculated by dividing the value of this property by 2. - * For example, setting it to '20S' will allow for requesting the connection up to 10 times with a 2 seconds delay between + * For example, setting it to `20S` will allow for requesting the connection up to 10 times with a 2 seconds delay between * the retries. - * Note the 'connection-timeout' property does not affect this amount of time. + * Note the `connection-timeout` property does not affect this amount of time. */ @ConfigItem public Optional<Duration> connectionDelay = Optional.empty(); @@ -74,16 +75,16 @@ public class OidcCommonConfig { public static class Credentials { /** - * Client secret which is used for a 'client_secret_basic' authentication method. + * Client secret which is used for a `client_secret_basic` authentication method. * Note that a 'client-secret.value' can be used instead but both properties are mutually exclusive. */ @ConfigItem public Optional<String> secret = Optional.empty(); /** - * Client secret which can be used for the 'client_secret_basic' (default) and 'client_secret_post' + * Client secret which can be used for the `client_secret_basic` (default) and `client_secret_post` * and 'client_secret_jwt' authentication methods. - * Note that a 'secret.value' property can be used instead to support the 'client_secret_basic' method + * Note that a `secret.value` property can be used instead to support the `client_secret_basic` method * but both properties are mutually exclusive. */ @ConfigItem
['extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonConfig.java', 'core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDocItemScanner.java', 'core/processor/src/main/java/io/quarkus/annotation/processor/generate_doc/ConfigDoItemFinder.java']
{'.java': 3}
3
3
0
0
3
14,397,877
2,806,933
374,119
3,972
3,676
765
53
3
988
66
278
20
4
0
2021-01-27T22:59:45
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,852
quarkusio/quarkus/14923/14811
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14811
https://github.com/quarkusio/quarkus/pull/14923
https://github.com/quarkusio/quarkus/pull/14923
1
fixes
Undertow with TLS causes IllegalStateException: Request has already been read
**Describe the bug** If Undertow is used with TLS then request in DEV mode occasionally leading to a `java.lang.IllegalStateException: Request has already been read`. **Expected behavior** Requests should be processed correctly. **Actual behavior** Not every request but 30-70% returns with a `java.lang.IllegalStateException: Request has already been read`. **To Reproduce** Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. Checkout the reproducer project ````shell git clone https://github.com/renegrob/reproducer-base.git git checkout request-has-aldready-been-read ```` 2. Start Quarkus in DEV mode with ````shell ./gradlew quarkusDev` ```` 3. Issue a request via CURL or in the browser to https://localhost:8443/ or https://localhost:8443/void ```shell curl -k https://localhost:8443 curl -k https://localhost:8443/void ``` 4. Remove the line `implementation("io.quarkus:quarkus-undertow")` from the file `build.gradle.kts` and execute the http requests again. The problem is gone. But without Undertow it is not possible to inject `HttpServletRequest` in JAX-RS. **Configuration** ````yaml quarkus: http: insecure-requests: redirect host: 0.0.0.0 port: 8080 ssl-port: 8443 http2: true ssl: certificate: key-store-file-type: PKCS12 key-store-file: tls-server-keypair.p12 key-store-password: ****** ```` **Stacktrace** ```log java.lang.IllegalStateException: Request has already been read at io.vertx.core.http.impl.Http2ServerRequestImpl.checkEnded(Http2ServerRequestImpl.java:215) at io.vertx.core.http.impl.Http2ServerRequestImpl.pause(Http2ServerRequestImpl.java:241) at io.quarkus.vertx.http.runtime.ResumingRequestWrapper.pause(ResumingRequestWrapper.java:28) at io.vertx.ext.web.impl.HttpServerRequestWrapper.pause(HttpServerRequestWrapper.java:88) at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5.handle(UndertowDeploymentRecorder.java:377) at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$5.handle(UndertowDeploymentRecorder.java:374) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:332) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:310) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.doPermissionCheck(HttpAuthorizer.java:116) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.access$100(HttpAuthorizer.java:27) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$2.accept(HttpAuthorizer.java:133) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer$2.accept(HttpAuthorizer.java:122) at io.smallrye.mutiny.helpers.UniCallbackSubscriber.onItem(UniCallbackSubscriber.java:69) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) at io.smallrye.mutiny.operators.uni.builders.KnownItemUni.subscribing(KnownItemUni.java:25) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:50) at io.smallrye.mutiny.groups.UniSubscribe.with(UniSubscribe.java:70) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.doPermissionCheck(HttpAuthorizer.java:122) at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.checkPermission(HttpAuthorizer.java:99) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$3.handle(HttpSecurityRecorder.java:218) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$3.handle(HttpSecurityRecorder.java:210) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2$1.onItem(HttpSecurityRecorder.java:128) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2$1.onItem(HttpSecurityRecorder.java:118) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) at io.smallrye.mutiny.operators.uni.builders.KnownItemUni.subscribing(KnownItemUni.java:25) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:50) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2.onItem(HttpSecurityRecorder.java:118) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2.onItem(HttpSecurityRecorder.java:104) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) at io.smallrye.mutiny.operators.UniMemoizeOp.drain(UniMemoizeOp.java:145) at io.smallrye.mutiny.operators.UniMemoizeOp.onItem(UniMemoizeOp.java:171) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) at io.smallrye.mutiny.operators.uni.builders.SuppliedtemUni.subscribing(SuppliedtemUni.java:29) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:30) at io.smallrye.mutiny.operators.UniMemoizeOp.subscribing(UniMemoizeOp.java:70) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:50) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2.handle(HttpSecurityRecorder.java:104) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2.handle(HttpSecurityRecorder.java:51) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:86) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:75) at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: ````shell Linux automatix 5.8.0-41-generic #46~20.04.1-Ubuntu SMP Mon Jan 18 17:52:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ```` - Output of `java -version`: ````shell java -version openjdk version "11.0.10" 2021-01-19 LTS OpenJDK Runtime Environment Zulu11.45+27-CA (build 11.0.10+9-LTS) OpenJDK 64-Bit Server VM Zulu11.45+27-CA (build 11.0.10+9-LTS, mixed mode) ```` - GraalVM version (if different from Java): ````shell n/a ```` - Quarkus version or git rev: ````shell 1.11.1.Final ```` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): ````shell ------------------------------------------------------------ Gradle 6.5.1 ------------------------------------------------------------ Build time: 2020-06-30 06:32:47 UTC Revision: 66bc713f7169626a7f0134bf452abde51550ea0a Kotlin: 1.3.72 Groovy: 2.5.11 Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019 JVM: 11.0.10 (Azul Systems, Inc. 11.0.10+9-LTS) OS: Linux 5.8.0-41-generic amd64 ```` **Additional context** n/a
583d69cf6ae698a37365599d987d1a10e75ad10c
14f65f500745fd32067053009499254dd2534c84
https://github.com/quarkusio/quarkus/compare/583d69cf6ae698a37365599d987d1a10e75ad10c...14f65f500745fd32067053009499254dd2534c84
diff --git a/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java b/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java index da32629292d..594ed052c54 100644 --- a/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java +++ b/extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java @@ -374,7 +374,9 @@ public void run() { return new Handler<RoutingContext>() { @Override public void handle(RoutingContext event) { - event.request().pause(); + if (!event.request().isEnded()) { + event.request().pause(); + } //we handle auth failure directly event.remove(QuarkusHttpUser.AUTH_FAILURE_HANDLER); VertxHttpExchange exchange = new VertxHttpExchange(event.request(), allocator, executorService, event,
['extensions/undertow/runtime/src/main/java/io/quarkus/undertow/runtime/UndertowDeploymentRecorder.java']
{'.java': 1}
1
1
0
0
1
14,601,534
2,847,091
379,282
4,016
157
24
4
1
9,425
457
2,418
163
5
10
2021-02-09T05:11: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,853
quarkusio/quarkus/14921/14850
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14850
https://github.com/quarkusio/quarkus/pull/14921
https://github.com/quarkusio/quarkus/pull/14921
1
fixes
Resteasy Reactive Security Context Exception
Hello. I am trying to update the security context in a RequestFilter like this: `context.securityContext = GatewaySecurityContext(context.securityContext, principalDetails) `. This is working with RestEasy Classic. Unfortunately using RestEasy Reactive I am getting the following error: ``` io.quarkus.resteasy.reactive.server.runtime.security.SecurityContextOverrideHandler.updateIdentity(SecurityContextOverrideHandler.java:48) ``` The issue is that in the following code ``` Uni<SecurityIdentity> oldIdentity = currentIdentityAssociation.getDeferredIdentity(); currentIdentityAssociation.setIdentity(oldIdentity.map(new Function<SecurityIdentity, SecurityIdentity>() { ``` **oldIdentity** is **null** in the `SecurityContextOverrideHandler` class. Is there anything I need to be aware of or am I doing something wrong here ?
583d69cf6ae698a37365599d987d1a10e75ad10c
ceae2bc10381b54fa21e5534fe62b046efdab030
https://github.com/quarkusio/quarkus/compare/583d69cf6ae698a37365599d987d1a10e75ad10c...ceae2bc10381b54fa21e5534fe62b046efdab030
diff --git a/extensions/security/runtime/src/main/java/io/quarkus/security/runtime/SecurityIdentityAssociation.java b/extensions/security/runtime/src/main/java/io/quarkus/security/runtime/SecurityIdentityAssociation.java index b184aceeefe..c1af7b17381 100644 --- a/extensions/security/runtime/src/main/java/io/quarkus/security/runtime/SecurityIdentityAssociation.java +++ b/extensions/security/runtime/src/main/java/io/quarkus/security/runtime/SecurityIdentityAssociation.java @@ -48,7 +48,13 @@ public void setIdentity(Uni<SecurityIdentity> identity) { } public Uni<SecurityIdentity> getDeferredIdentity() { - return deferredIdentity; + if (deferredIdentity != null) { + return deferredIdentity; + } else if (identity != null) { + return Uni.createFrom().item(identity); + } else { + return deferredIdentity = identityProviderManager.authenticate(AnonymousAuthenticationRequest.INSTANCE); + } } @Override
['extensions/security/runtime/src/main/java/io/quarkus/security/runtime/SecurityIdentityAssociation.java']
{'.java': 1}
1
1
0
0
1
14,601,534
2,847,091
379,282
4,016
352
59
8
1
857
80
167
17
0
2
2021-02-09T04:49: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,856
quarkusio/quarkus/14855/14856
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14856
https://github.com/quarkusio/quarkus/pull/14855
https://github.com/quarkusio/quarkus/pull/14855
1
fixes
OIDC CodeAuthentitcationMechanism does not set state and session cookies 'secure` parameter to true if 'force-redirect-https-scheme' is enabled
**Description** As reported at https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/OIDC.20Session.20Cookie.20-.20Samesite.20.20Policy, the state and session cookies do not have `secure=true` as a result
95602076fa89d89e0db6c00709e07a0b9cc28530
299ca05b44253da37f56706b1ba32a45f4d7fb17
https://github.com/quarkusio/quarkus/compare/95602076fa89d89e0db6c00709e07a0b9cc28530...299ca05b44253da37f56706b1ba32a45f4d7fb17
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 6c02d5de2f0..306b5b4fe32 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 @@ -444,6 +444,14 @@ public static class Authentication { @ConfigItem public Map<String, String> extraParams; + /** + * If enabled the state, session and post logout cookies will have their 'secure' parameter set to 'true' + * when HTTP is used. It may be necessary when running behind an SSL terminating reverse proxy. + * The cookies will always be secure if HTTPS is used even if this property is set to false. + */ + @ConfigItem(defaultValue = "false") + public boolean cookieForceSecure; + /** * Cookie path parameter value which, if set, will be used to set a path parameter for the session, state and post * logout cookies. @@ -543,6 +551,14 @@ public void setRestorePathAfterRedirect(boolean restorePathAfterRedirect) { this.restorePathAfterRedirect = restorePathAfterRedirect; } + public boolean isCookieForceSecure() { + return cookieForceSecure; + } + + public void setCookieForceSecure(boolean cookieForceSecure) { + this.cookieForceSecure = cookieForceSecure; + } + public Optional<String> getCookiePath() { return cookiePath; } 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 8f81d6c8e64..2302c87f802 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 @@ -423,7 +423,7 @@ static ServerCookie createCookie(RoutingContext context, OidcTenantConfig oidcCo String name, String value, long maxAge) { ServerCookie cookie = new CookieImpl(name, value); cookie.setHttpOnly(true); - cookie.setSecure(context.request().isSSL()); + cookie.setSecure(oidcConfig.authentication.cookieForceSecure || context.request().isSSL()); cookie.setMaxAge(maxAge); LOG.debugf(name + " cookie 'max-age' parameter is set to %d", maxAge); Authentication auth = oidcConfig.getAuthentication();
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java']
{'.java': 2}
2
2
0
0
2
14,564,506
2,839,979
378,333
4,010
832
158
18
2
217
17
63
2
1
0
2021-02-05T14:13:33
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,857
quarkusio/quarkus/14777/14743
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14743
https://github.com/quarkusio/quarkus/pull/14777
https://github.com/quarkusio/quarkus/pull/14777
1
fixes
HashiCorp key vault does not override application.properties
**Describe the bug** HashiCorp vault does not override properties in application.properties **Expected behavior** Values in application.properties that share the same name described in vault should be overridden. **Actual behavior** Only the values in application.properties gets assigned. **To Reproduce** https://quarkus.io/guides/vault follow this guide while having a value for "a-private-key" in application.properties Steps to reproduce the behavior: 1. Create a secret in vault 2. Use the same secret with diffrent value in appliction.properties icable, add screenshots to help explain your problem.) **Environment ** Quarkus 1.11.1.Final
cb11c777cb6b1304cd20440b962d460730a9535a
4038434cfb68718d038be9d2d5c90ac174d83e27
https://github.com/quarkusio/quarkus/compare/cb11c777cb6b1304cd20440b962d460730a9535a...4038434cfb68718d038be9d2d5c90ac174d83e27
diff --git a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSourceProvider.java b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSourceProvider.java index d76e9fd1458..3dbfcdc16b1 100644 --- a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSourceProvider.java +++ b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSourceProvider.java @@ -18,6 +18,7 @@ public VaultConfigSourceProvider(VaultBootstrapConfig vaultBootstrapConfig) { @Override public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { - return Arrays.asList(new VaultConfigSource(150, vaultBootstrapConfig)); + // 270 is higher than the file system or jar ordinals, but lower than env vars + return Arrays.asList(new VaultConfigSource(270, vaultBootstrapConfig)); } }
['extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSourceProvider.java']
{'.java': 1}
1
1
0
0
1
14,512,667
2,830,486
377,063
4,001
249
51
3
1
678
83
143
23
1
0
2021-02-02T17:51: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,858
quarkusio/quarkus/14770/14678
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14678
https://github.com/quarkusio/quarkus/pull/14770
https://github.com/quarkusio/quarkus/pull/14770
1
fixes
Health configuration reference does not reflect the new /q namespace
The documentation at https://quarkus.io/guides/microprofile-health#configuration-reference does not reflect the new /q/.. namespace these endpoint defaults have been moved to.
483d1424b939b17497bfdea65916d4cf501ea7c3
0c4cbeb39bf87ea84d4a9e7ef64a926959f220dd
https://github.com/quarkusio/quarkus/compare/483d1424b939b17497bfdea65916d4cf501ea7c3...0c4cbeb39bf87ea84d4a9e7ef64a926959f220dd
diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index c86e957657a..3f8d8135b59 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -163,14 +163,15 @@ void build(SmallRyeHealthRecorder recorder, if (launchMode.getLaunchMode().isDevOrTest()) { String basePath = nonApplicationRootPathBuildItem.adjustPath(healthConfig.rootPath); displayableEndpoints.produce(new NotFoundPageDisplayableEndpointBuildItem(basePath)); + String subcontextBasePath = adjustSubcontextBasePath(basePath); displayableEndpoints - .produce(new NotFoundPageDisplayableEndpointBuildItem(basePath + healthConfig.livenessPath)); + .produce(new NotFoundPageDisplayableEndpointBuildItem(subcontextBasePath + healthConfig.livenessPath)); displayableEndpoints - .produce(new NotFoundPageDisplayableEndpointBuildItem(basePath + healthConfig.readinessPath)); + .produce(new NotFoundPageDisplayableEndpointBuildItem(subcontextBasePath + healthConfig.readinessPath)); displayableEndpoints - .produce(new NotFoundPageDisplayableEndpointBuildItem(basePath + healthConfig.groupPath)); + .produce(new NotFoundPageDisplayableEndpointBuildItem(subcontextBasePath + healthConfig.groupPath)); displayableEndpoints - .produce(new NotFoundPageDisplayableEndpointBuildItem(basePath + healthConfig.wellnessPath)); + .produce(new NotFoundPageDisplayableEndpointBuildItem(subcontextBasePath + healthConfig.wellnessPath)); } // Discover the beans annotated with @Health, @Liveness, @Readiness, @HealthGroup, @@ -225,9 +226,11 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes, .nonApplicationRoute() .build()); + String subcontextBasePath = adjustSubcontextBasePath(healthConfig.rootPath); + // Register the liveness handler routes.produce(new RouteBuildItem.Builder() - .route(healthConfig.rootPath + healthConfig.livenessPath) + .route(subcontextBasePath + healthConfig.livenessPath) .handler(new SmallRyeLivenessHandler()) .blockingRoute() .nonApplicationRoute() @@ -235,7 +238,7 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes, // Register the readiness handler routes.produce(new RouteBuildItem.Builder() - .route(healthConfig.rootPath + healthConfig.readinessPath) + .route(subcontextBasePath + healthConfig.readinessPath) .handler(new SmallRyeReadinessHandler()) .blockingRoute() .nonApplicationRoute() @@ -256,7 +259,7 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes, // Register the health group handlers routes.produce(new RouteBuildItem.Builder() - .route(healthConfig.rootPath + healthConfig.groupPath) + .route(subcontextBasePath + healthConfig.groupPath) .handler(new SmallRyeHealthGroupHandler()) .blockingRoute() .nonApplicationRoute() @@ -265,7 +268,7 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes, SmallRyeIndividualHealthGroupHandler handler = new SmallRyeIndividualHealthGroupHandler(); for (String healthGroup : healthGroups) { routes.produce(new RouteBuildItem.Builder() - .route(healthConfig.rootPath + healthConfig.groupPath + "/" + healthGroup) + .route(subcontextBasePath + healthConfig.groupPath + "/" + healthGroup) .handler(handler) .blockingRoute() .nonApplicationRoute() @@ -274,7 +277,7 @@ public void defineHealthRoutes(BuildProducer<RouteBuildItem> routes, // Register the wellness handler routes.produce(new RouteBuildItem.Builder() - .route(healthConfig.rootPath + healthConfig.wellnessPath) + .route(subcontextBasePath + healthConfig.wellnessPath) .handler(new SmallRyeWellnessHandler()) .blockingRoute() .nonApplicationRoute() @@ -292,9 +295,10 @@ public void includeInOpenAPIEndpoint(BuildProducer<AddToOpenAPIDefinitionBuildIt // Add to OpenAPI if OpenAPI is available if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI)) { String basePath = httpRootPath.adjustPath(nonApplicationRootPathBuildItem.adjustPath(healthConfig.rootPath)); + String subcontextBasePath = adjustSubcontextBasePath(basePath); HealthOpenAPIFilter filter = new HealthOpenAPIFilter(basePath, - basePath + healthConfig.livenessPath, - basePath + healthConfig.readinessPath); + subcontextBasePath + healthConfig.livenessPath, + subcontextBasePath + healthConfig.readinessPath); openAPIProducer.produce(new AddToOpenAPIDefinitionBuildItem(filter)); } } @@ -328,14 +332,16 @@ public void kubernetes(HttpBuildTimeConfig httpConfig, NonApplicationRootPathBui BuildProducer<KubernetesHealthLivenessPathBuildItem> livenessPathItemProducer, BuildProducer<KubernetesHealthReadinessPathBuildItem> readinessPathItemProducer) { + String subcontextBasePath = adjustSubcontextBasePath(healthConfig.rootPath); + livenessPathItemProducer.produce( new KubernetesHealthLivenessPathBuildItem( httpConfig - .adjustPath(frameworkRootPath.adjustPath(healthConfig.rootPath + healthConfig.livenessPath)))); + .adjustPath(frameworkRootPath.adjustPath(subcontextBasePath + healthConfig.livenessPath)))); readinessPathItemProducer.produce( new KubernetesHealthReadinessPathBuildItem( httpConfig - .adjustPath(frameworkRootPath.adjustPath(healthConfig.rootPath + healthConfig.readinessPath)))); + .adjustPath(frameworkRootPath.adjustPath(subcontextBasePath + healthConfig.readinessPath)))); } @BuildStep @@ -390,7 +396,6 @@ public void transform(TransformationContext ctx) { } // UI - @BuildStep void registerUiExtension( BuildProducer<GeneratedResourceBuildItem> generatedResourceProducer, @@ -499,4 +504,8 @@ public String updateApiUrl(String original, String healthPath) { private static boolean shouldInclude(LaunchModeBuildItem launchMode, SmallRyeHealthConfig healthConfig) { return launchMode.getLaunchMode().isDevOrTest() || healthConfig.ui.alwaysInclude; } + + private String adjustSubcontextBasePath(String basePath) { + return basePath.equals("/") ? "" : basePath; + } }
['extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java']
{'.java': 1}
1
1
0
0
1
14,496,235
2,827,196
376,695
3,998
2,959
544
37
1
179
18
37
3
1
0
2021-02-02T15:03:15
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,859
quarkusio/quarkus/14737/14608
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14608
https://github.com/quarkusio/quarkus/pull/14737
https://github.com/quarkusio/quarkus/pull/14737
1
closes
Vertx PgPool lost connection unexpectedly
When a user gets a connection from`pgPool` some milliseconds behind IDLE expiration time, then "sometimes" when you are going to use the connection, you get the following error from the server: `Fail to read any response from the server, the underlying connection might get lost unexpectedly.` So, looks that the connection it's available when you request it, but then disappears when you use it. **Expected behavior** The connection should be validated (maybe by a query), before return an available connection. **Actual behavior** An end-user could get a connection that is not available anymore. **To Reproduce** You could run the [following test](https://github.com/pjgg/beefy-scenarios/blob/feature/vertx-sql/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/dbpool/DbPostgresPoolTest.java#L100) [Jira Ref](https://issues.redhat.com/browse/QUARKUS-719)
515ca8a966c21c2c33fa9a37e2275c753351901f
827a16dd64ac6371fd849c64cee40db51aa9ff61
https://github.com/quarkusio/quarkus/compare/515ca8a966c21c2c33fa9a37e2275c753351901f...827a16dd64ac6371fd849c64cee40db51aa9ff61
diff --git a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java index 4885d0fbcad..5e0770fd8e6 100644 --- a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java +++ b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java @@ -110,7 +110,7 @@ public class DataSourceReactiveRuntimeConfig { public Duration reconnectInterval = Duration.ofSeconds(1L); /** - * The maximum time without data written to or read from a connection before it is removed from the pool. + * The maximum time without data written to or read from a connection before it is closed. */ @ConfigItem(defaultValueDocumentation = "no timeout") public Optional<Duration> idleTimeout = Optional.empty();
['extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java']
{'.java': 1}
1
1
0
0
1
14,491,551
2,826,276
376,588
3,995
206
41
2
1
894
103
211
18
2
0
2021-02-01T10:26: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,861
quarkusio/quarkus/14643/14591
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14591
https://github.com/quarkusio/quarkus/pull/14643
https://github.com/quarkusio/quarkus/pull/14643
1
resolves
The exceptions thrown into an event flow (or a separate thread) are quietly captured and the developer won´t know it
**Describe the bug** In the code into an event handler method or another way to generate a separate thread (for example created using _Executors.newSingleThreadExecutor()_ or something like that) the exceptions are not reported, it seems they are quietly captured in an external layer. **Expected behavior** In this code: ``` @ApplicationScoped public class EventsAndExceptions { private static final Logger LOGGER = Logger.getLogger(EventsAndExceptions.class.getCanonicalName()); @Inject EventBus bus; @ConsumeEvent("greeting") public void consume(String name) { LOGGER.log(Level.INFO, "Hello {0}", name.toUpperCase()); String nullReference = null; nullReference.toUpperCase(); LOGGER.log(Level.INFO, "See you soon {0}", name.toUpperCase()); } void startup(@Observes StartupEvent event) { bus.publish("greeting", "Vicent"); } } ``` ```2021-01-25 20:30:09,627 INFO [org.acm.EventsAndExceptions] (vert.x-eventloop-thread-1) Hello VICENT``` I expected the application to show the error, but it shows error nowhere. As expected, the last INFO log isn´t executed because the flow has been interrupted at the forced NPE, but the developer won´t know it If I capture explicitly the exception, evidently the catch block is invoked and the flow continues reaching the INFO log. ``` String nullReference = null; try { nullReference.toUpperCase(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Yes, this is a NPE", e); } ``` ```2021-01-25 20:30:09,627 INFO [org.acm.EventsAndExceptions] (vert.x-eventloop-thread-1) Hello VICENT 2021-01-25 20:30:09,633 SEVERE [org.acm.EventsAndExceptions] (vert.x-eventloop-thread-1) Yes, this is a NPE: java.lang.NullPointerException at org.acme.EventsAndExceptions.consume(EventsAndExceptions.java:28) at org.acme.EventsAndExceptions_ClientProxy.consume(EventsAndExceptions_ClientProxy.zig:188) ... at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) 2021-01-25 20:30:09,635 INFO [org.acm.EventsAndExceptions] (vert.x-eventloop-thread-1) See you soon VICENT ``` Am I doing something wrong? **Actual behavior** The application doest´t notify about the exception has been thown. **To Reproduce** I attach this zip file [this zip file](https://github.com/quarkusio/quarkus/files/5869258/code-with-quarkus-exceptions.zip) with a fresh project using only _vertx_ and _resteasy-mutiny_ extensions to have events support. Steps to reproduce the behavior: 1. Unzip the file 2. Change to its directory and execute it: _./mvnw compile quarkus:dev_ **Configuration** Not applicable **Screenshots** Not necessary **Environment (please complete the following information):** - Output of `uname -a` or `ver`: ``` Darwin iMac-de-Vicente-4.local 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64 ``` - 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): GraalVM CE 20.3.1 - Quarkus version or git rev: 1.11.0.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): ``` Maven home: /Users/vferrer/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home Default locale: es_ES, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac" ```
76e23bc8ff3a0a8c5705b0c60b1da898df3c7577
c120ab00dd2f3b26137e48180c3b2eb8d9bc3610
https://github.com/quarkusio/quarkus/compare/76e23bc8ff3a0a8c5705b0c60b1da898df3c7577...c120ab00dd2f3b26137e48180c3b2eb8d9bc3610
diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/BeanInvoker.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/BeanInvoker.java index d0a0741e3e4..ed4c248a87b 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/BeanInvoker.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/BeanInvoker.java @@ -10,7 +10,7 @@ */ public interface BeanInvoker<T> { - default void invoke(T param) { + default void invoke(T param) throws Exception { ManagedContext requestContext = Arc.container().requestContext(); if (requestContext.isActive()) { invokeBean(param); @@ -24,6 +24,6 @@ default void invoke(T param) { } } - void invokeBean(T param); + void invokeBean(T param) throws Exception; } 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 3798ecc8f9a..24829c01148 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 @@ -26,6 +26,7 @@ import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; import org.quartz.ScheduleBuilder; import org.quartz.SchedulerException; import org.quartz.SchedulerFactory; @@ -378,11 +379,15 @@ static class InvokerJob implements Job { } @Override - public void execute(JobExecutionContext context) { + public void execute(JobExecutionContext context) throws JobExecutionException { QuartzTrigger trigger = new QuartzTrigger(context); ScheduledInvoker scheduledInvoker = invokers.get(context.getJobDetail().getKey().getName()); if (scheduledInvoker != null) { // could be null from previous runs - scheduledInvoker.invoke(new QuartzScheduledExecution(trigger)); + try { + scheduledInvoker.invoke(new QuartzScheduledExecution(trigger)); + } catch (Exception e) { + throw new JobExecutionException(e); + } } } } diff --git a/extensions/scheduler/deployment/src/main/java/io/quarkus/scheduler/deployment/SchedulerProcessor.java b/extensions/scheduler/deployment/src/main/java/io/quarkus/scheduler/deployment/SchedulerProcessor.java index 79541952a95..1d2c3311699 100644 --- a/extensions/scheduler/deployment/src/main/java/io/quarkus/scheduler/deployment/SchedulerProcessor.java +++ b/extensions/scheduler/deployment/src/main/java/io/quarkus/scheduler/deployment/SchedulerProcessor.java @@ -263,7 +263,8 @@ private String generateInvoker(ScheduledBusinessMethodItem scheduledMethod, Clas .build(); // The descriptor is: void invokeBean(Object execution) - MethodCreator invoke = invokerCreator.getMethodCreator("invokeBean", void.class, Object.class); + MethodCreator invoke = invokerCreator.getMethodCreator("invokeBean", void.class, Object.class) + .addException(Exception.class); // InjectableBean<Foo: bean = Arc.container().bean("1"); // InstanceHandle<Foo> handle = Arc.container().instance(bean); // handle.get().ping(); diff --git a/extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SkipConcurrentExecutionInvoker.java b/extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SkipConcurrentExecutionInvoker.java index 9ece757b620..26b3658b473 100644 --- a/extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SkipConcurrentExecutionInvoker.java +++ b/extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SkipConcurrentExecutionInvoker.java @@ -31,7 +31,7 @@ public SkipConcurrentExecutionInvoker(ScheduledInvoker delegate, Event<SkippedEx } @Override - public void invoke(ScheduledExecution execution) { + public void invoke(ScheduledExecution execution) throws Exception { if (running.compareAndSet(false, true)) { try { delegate.invoke(execution); diff --git a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusConsumer.java b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusConsumer.java index 65a4e3454db..c22e827afcf 100644 --- a/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusConsumer.java +++ b/extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusConsumer.java @@ -102,7 +102,8 @@ static String generateInvoker(BeanInfo bean, MethodInfo method, .interfaces(EventConsumerInvoker.class).build(); // The method descriptor is: void invokeBean(Object message) - MethodCreator invoke = invokerCreator.getMethodCreator("invokeBean", void.class, Object.class); + MethodCreator invoke = invokerCreator.getMethodCreator("invokeBean", void.class, Object.class) + .addException(Exception.class); if (blocking) { MethodCreator isBlocking = invokerCreator.getMethodCreator("isBlocking", boolean.class); diff --git a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/deployment/MessageConsumerFailureTest.java b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/deployment/MessageConsumerFailureTest.java index fd6a95316e5..915097d4adb 100644 --- a/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/deployment/MessageConsumerFailureTest.java +++ b/extensions/vertx/deployment/src/test/java/io/quarkus/vertx/deployment/MessageConsumerFailureTest.java @@ -20,6 +20,8 @@ import io.quarkus.test.QuarkusUnitTest; import io.quarkus.vertx.ConsumeEvent; import io.smallrye.mutiny.Uni; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; import io.vertx.core.eventbus.EventBus; import io.vertx.core.eventbus.Message; import io.vertx.core.eventbus.ReplyException; @@ -33,6 +35,9 @@ public class MessageConsumerFailureTest { @Inject SimpleBean simpleBean; + @Inject + Vertx vertx; + @Inject EventBus eventBus; @@ -53,6 +58,30 @@ public void testFailure() throws InterruptedException { verifyFailure("foo-uni-failure-blocking", "boom", true); } + @Test + public void testFailureNoReplyHandler() throws InterruptedException { + Handler<Throwable> oldHandler = vertx.exceptionHandler(); + try { + BlockingQueue<Object> synchronizer = new LinkedBlockingQueue<>(); + vertx.exceptionHandler(new Handler<Throwable>() { + @Override + public void handle(Throwable event) { + try { + synchronizer.put(event); + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } + }); + eventBus.send("foo", "bar"); + Object ret = synchronizer.poll(2, TimeUnit.SECONDS); + assertTrue(ret instanceof IllegalStateException); + assertEquals("Foo is dead", ((IllegalStateException) ret).getMessage()); + } finally { + vertx.exceptionHandler(oldHandler); + } + } + void verifyFailure(String address, String expectedMessage, boolean explicit) throws InterruptedException { BlockingQueue<Object> synchronizer = new LinkedBlockingQueue<>(); eventBus.request(address, "hello", ar -> { diff --git a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxRecorder.java b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxRecorder.java index d656fad5029..b84270f741e 100644 --- a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxRecorder.java +++ b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxRecorder.java @@ -88,8 +88,13 @@ public void handle(Message<Object> m) { public void handle(Promise<Object> event) { try { invoker.invoke(m); - } catch (Throwable e) { - m.fail(ConsumeEvent.FAILURE_CODE, e.toString()); + } catch (Exception e) { + if (m.replyAddress() == null) { + // No reply handler + throw wrapIfNecessary(e); + } else { + m.fail(ConsumeEvent.FAILURE_CODE, e.toString()); + } } event.complete(); } @@ -97,8 +102,13 @@ public void handle(Promise<Object> event) { } else { try { invoker.invoke(m); - } catch (Throwable e) { - m.fail(ConsumeEvent.FAILURE_CODE, e.toString()); + } catch (Exception e) { + if (m.replyAddress() == null) { + // No reply handler + throw wrapIfNecessary(e); + } else { + m.fail(ConsumeEvent.FAILURE_CODE, e.toString()); + } } } } @@ -123,6 +133,14 @@ public void handle(AsyncResult<Void> ar) { } } + private RuntimeException wrapIfNecessary(Exception e) { + if (e instanceof RuntimeException) { + return (RuntimeException) e; + } else { + return new RuntimeException(e); + } + } + void unregisterMessageConsumers() { CountDownLatch latch = new CountDownLatch(messageConsumers.size()); for (MessageConsumer<?> messageConsumer : messageConsumers) {
['extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java', 'extensions/vertx/deployment/src/main/java/io/quarkus/vertx/deployment/EventBusConsumer.java', 'extensions/scheduler/runtime/src/main/java/io/quarkus/scheduler/runtime/SkipConcurrentExecutionInvoker.java', 'extensions/vertx/runtime/src/main/java/io/quarkus/vertx/runtime/VertxRecorder.java', 'extensions/scheduler/deployment/src/main/java/io/quarkus/scheduler/deployment/SchedulerProcessor.java', 'extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/BeanInvoker.java', 'extensions/vertx/deployment/src/test/java/io/quarkus/vertx/deployment/MessageConsumerFailureTest.java']
{'.java': 7}
7
7
0
0
7
14,384,290
2,804,256
373,794
3,964
2,680
412
47
6
3,810
400
1,056
92
1
7
2021-01-27T08:59:02
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,871
quarkusio/quarkus/14250/14229
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14229
https://github.com/quarkusio/quarkus/pull/14250
https://github.com/quarkusio/quarkus/pull/14250
1
closes
Log regression in 1.11.0.CR1 with native build and yaml configuration
**Describe the bug** Log level isn't set using the following snippet: ``` Logger log = Logger.getLogger(GreetingResource.class); log.debug("hello debug"); log.info("hello info"); ``` Please note this is a regression in 1.11.0.CR1 compared to 1.10.5.Final. **Expected behavior** Logging in DEBUG should be shown in the application output with both builds. **Actual behavior** Only INFO level is shown in native whereas both are with jvm build. **To Reproduce** I have setup a public repo (https://github.com/matthyx/quarkus-getting-started) with 2 branches containing the same example in both versions. Steps to reproduce the behavior: 1. git clone https://github.com/matthyx/quarkus-getting-started.git 2. ./mvnw package 3. ./mvnw package -Pnative -Dquarkus.native.container-build=true 4. cd mytest 5. ../target/getting-started-1.0.0-SNAPSHOT-runner 6. (separate terminal) curl http://127.0.0.1:8080/hello 7. java -jar ../target/getting-started-1.0.0-SNAPSHOT-runner.jar 8. (separate terminal) curl http://127.0.0.1:8080/hello **Configuration** ```properties # src/main/resources/application.yml quarkus: log: min-level: DEBUG ``` ```properties # config/application.yml quarkus: http: port: 18080 log: category: "org.acme.getting.started": level: TRACE ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux parrot 5.9.0-2parrot1-amd64 #1 SMP Debian 5.9.6-2parrot1 (2020-11-17) x86_64 GNU/Linux - Output of `java -version`: openjdk version "11.0.9.1" 2020-11-04 OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1) OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1, mixed mode, sharing) - GraalVM version (if different from Java): quay.io/quarkus/ubi-quarkus-native-image 20.3.0-java11 - Quarkus version or git rev: 1.11.0.CR1 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
1268f72827462aa2cc8aac340c536b22a6d366e0
ceff592c8f8cf7733d1529181e18e42ebeddfe9e
https://github.com/quarkusio/quarkus/compare/1268f72827462aa2cc8aac340c536b22a6d366e0...ceff592c8f8cf7733d1529181e18e42ebeddfe9e
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 5e91d51af1f..6d21c64f18b 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 @@ -171,23 +171,22 @@ void registerMetrics(LogMetricsHandlerRecorder recorder, LogBuildTimeConfig log, void setUpMinLevelLogging(LogBuildTimeConfig log, final BuildProducer<GeneratedClassBuildItem> generatedTraceLogger) { ClassOutput output = new GeneratedClassGizmoAdaptor(generatedTraceLogger, false); - if (log.categories.isEmpty() || allMinLevelInfoOrHigher(log.categories)) { - generateDefaultLoggers(output); + if (log.categories.isEmpty() || allMinLevelInfoOrHigher(log.minLevel.intValue(), log.categories)) { + generateDefaultLoggers(log.minLevel, output); } else { generateCategoryMinLevelLoggers(log.categories, log.minLevel, output); } } - private static boolean allMinLevelInfoOrHigher(Map<String, CategoryBuildTimeConfig> categories) { + private static boolean allMinLevelInfoOrHigher(int minLogLevel, Map<String, CategoryBuildTimeConfig> categories) { return categories.values().stream() - .allMatch(categoryConfig -> categoryConfig.minLevel.getLevel().intValue() >= org.jboss.logmanager.Level.INFO - .intValue()); + .allMatch(categoryConfig -> categoryConfig.minLevel.getLevel().intValue() >= minLogLevel); } - private static void generateDefaultLoggers(ClassOutput output) { - generateDefaultLoggingLogger(output); + private static void generateDefaultLoggers(Level minLevel, ClassOutput output) { + generateDefaultLoggingLogger(minLevel, output); generateDefaultLoggerNode(output); - generateLogManagerLogger(output, LoggingResourceProcessor::generateMinLevelDefault); + generateLogManagerLogger(output, LoggingResourceProcessor.generateMinLevelDefault(minLevel.getName())); } private static void generateCategoryMinLevelLoggers(Map<String, CategoryBuildTimeConfig> categories, Level minLevel, @@ -307,10 +306,13 @@ private static ResultHandle getParamLevelIntValue(MethodCreator method) { .invokeVirtualMethod(MethodDescriptor.ofMethod(Level.class, "intValue", int.class), level); } - private static BranchResult generateMinLevelDefault(MethodCreator method, FieldDescriptor nameAliasDescriptor) { - final ResultHandle levelIntValue = getParamLevelIntValue(method); - final ResultHandle infoLevelIntValue = getLogManagerLevelIntValue("INFO", method); - return method.ifIntegerGreaterEqual(levelIntValue, infoLevelIntValue); + private static BiFunction<MethodCreator, FieldDescriptor, BranchResult> generateMinLevelDefault( + String defaultMinLevelName) { + return (method, nameAliasDescriptor) -> { + final ResultHandle levelIntValue = getParamLevelIntValue(method); + final ResultHandle infoLevelIntValue = getLogManagerLevelIntValue(defaultMinLevelName, method); + return method.ifIntegerGreaterEqual(levelIntValue, infoLevelIntValue); + }; } private static ResultHandle getLogManagerLevelIntValue(String levelName, BytecodeCreator method) { @@ -320,7 +322,7 @@ private static ResultHandle getLogManagerLevelIntValue(String levelName, Bytecod .invokeVirtualMethod(MethodDescriptor.ofMethod(Level.class, "intValue", int.class), infoLevel); } - private static void generateDefaultLoggingLogger(ClassOutput output) { + private static void generateDefaultLoggingLogger(Level minLevel, ClassOutput output) { try (ClassCreator cc = ClassCreator.builder().setFinal(true) .className(LOGGING_LOGGER_CLASS_NAME) .classOutput(output).build()) { @@ -328,10 +330,14 @@ private static void generateDefaultLoggingLogger(ClassOutput output) { AnnotationCreator targetClass = cc.addAnnotation("com.oracle.svm.core.annotate.TargetClass"); targetClass.addValue("className", "org.jboss.logging.Logger"); - // Constant fold these methods to return false, - // since the build time log level is above this level. - generateFalseFoldMethod("isTraceEnabled", cc); - generateFalseFoldMethod("isDebugEnabled", cc); + if (minLevel.intValue() >= org.jboss.logmanager.Level.INFO.intValue()) { + // Constant fold these methods to return false, + // since the build time log level is above this level. + generateFalseFoldMethod("isTraceEnabled", cc); + generateFalseFoldMethod("isDebugEnabled", cc); + } else if (minLevel.intValue() == org.jboss.logmanager.Level.DEBUG.intValue()) { + generateFalseFoldMethod("isTraceEnabled", cc); + } } }
['core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java']
{'.java': 1}
1
1
0
0
1
14,226,860
2,775,177
370,046
3,937
3,045
571
40
1
2,020
216
620
53
4
3
2021-01-12T13:10: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,862
quarkusio/quarkus/14599/14583
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14583
https://github.com/quarkusio/quarkus/pull/14599
https://github.com/quarkusio/quarkus/pull/14599
1
fixes
RunnerClassLoader sanitizeName cannot handle 0 length name argument
I've been working to make camel-k use the Quarkus fast-jar package format. With Kotlin based Camel routes, the application statup fails. I'm no Kotlin expert, but its bootstrap is calling `getResources("")` on the `ClassLoader` (not sure if that's valid or not). When the [name argument](https://github.com/quarkusio/quarkus/blob/993a5667fbb51aec5677e30e7210d07bb3be529a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java#L132) passed to `RunnerClassLoader.sanitizeName` is an empty string, then an exception is thrown: ``` 2021-01-25 13:24:08,916 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): 2021-01-25 14:29:11,572 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47) at java.base/java.lang.String.charAt(String.java:693) at io.quarkus.bootstrap.runner.RunnerClassLoader.sanitizeName(RunnerClassLoader.java:150) at io.quarkus.bootstrap.runner.RunnerClassLoader.findResources(RunnerClassLoader.java:180) at java.base/java.lang.ClassLoader.getResources(ClassLoader.java:1467) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.rawClassPathFromKeyResourcePath(jvmClasspathUtil.kt:130) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.classPathFromTypicalResourceUrls(jvmClasspathUtil.kt:143) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt$classpathFromClassloader$1.invoke(jvmClasspathUtil.kt:87) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt$classpathFromClassloader$1.invoke(jvmClasspathUtil.kt) at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:315) at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303) at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:169) at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194) at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:752) at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:782) at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:773) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.classpathFromClassloader(jvmClasspathUtil.kt:92) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.scriptCompilationClasspathFromContextOrNull(jvmClasspathUtil.kt:275) at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.scriptCompilationClasspathFromContext(jvmClasspathUtil.kt:298) at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassloader(jvmScriptCompilation.kt:57) at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassloader$default(jvmScriptCompilation.kt:54) ```
3620f89ab7ce4e3368305e7c9f752e363d102c77
88a7ebd5e193a639afee9d65800bd847b62020ab
https://github.com/quarkusio/quarkus/compare/3620f89ab7ce4e3368305e7c9f752e363d102c77...88a7ebd5e193a639afee9d65800bd847b62020ab
diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java index 053f4e32e58..ecaa699dcb0 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java @@ -147,7 +147,7 @@ protected URL findResource(String name) { } private String sanitizeName(final String name) { - if (name.charAt(0) == '/') { + if (name.length() > 0 && name.charAt(0) == '/') { return name.substring(1); } return name;
['independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/RunnerClassLoader.java']
{'.java': 1}
1
1
0
0
1
14,348,910
2,797,679
372,949
3,958
96
29
2
1
2,888
132
733
29
1
1
2021-01-25T22:38: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,863
quarkusio/quarkus/14576/14569
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14569
https://github.com/quarkusio/quarkus/pull/14576
https://github.com/quarkusio/quarkus/pull/14576
1
fixes
How to properly register XMLGregorianCalendar?
Already for some time some warning is bugging me when our Quarkus app is starting up. This is regardless of the Quarkus version, seeing this warning on both 1.10 and 1.11 We generate some Java code from XSD files for a REST Client implementation using JAXB. The XSD contains a datetime field which translates to a `javax.xml.datatype.XMLGregorianCalendar`. And gives me the following warning on start up: ``` 2021-01-23 11:13:19,751 WARN [io.qua.dep.ste.ReflectiveHierarchyStep] (build-6) Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index: - javax.xml.datatype.XMLGregorianCalendar (source: RestClientProcessor > nl.wjglerum.xml.Prices) Consider adding them to the index either by creating a Jandex index for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.");. ``` I tried the following options without any success: - adding an empty `beans.xml` in `META-INF` - adding the jandex maven plugin to build the Jandex index - adding an annotation to register the class with `@RegisterForReflection(targets = XMLGregorianCalendar.class)` - adding it using `application.properties`, unfortunately I couldn't figure out what to add here. Sample repo to reproduce the warning: https://github.com/wjglerum/quarkus-xml Also see zulip https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/How.20to.20properly.20register.20XMLGregorianCalendar.3F
b0b6424b53ce8fcda5baa42feb81bb38dae8f8f1
1807e8c4b27797b7320be4b0d48c827de9319206
https://github.com/quarkusio/quarkus/compare/b0b6424b53ce8fcda5baa42feb81bb38dae8f8f1...1807e8c4b27797b7320be4b0d48c827de9319206
diff --git a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java index 25907901934..9b36faf6761 100644 --- a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java +++ b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java @@ -61,6 +61,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; @@ -110,6 +111,9 @@ class JaxbProcessor { private static final List<DotName> JAXB_ROOT_ANNOTATIONS = Arrays.asList(XML_ROOT_ELEMENT, XML_TYPE, XML_REGISTRY); + private static final List<DotName> IGNORE_TYPES = Collections + .singletonList(DotName.createSimple("javax.xml.datatype.XMLGregorianCalendar")); + @Inject ApplicationArchivesBuildItem applicationArchivesBuildItem; @@ -178,6 +182,13 @@ void processAnnotationsAndIndexFiles( } } + @BuildStep + void ignoreWarnings(BuildProducer<ReflectiveHierarchyIgnoreWarningBuildItem> ignoreWarningProducer) { + for (DotName type : IGNORE_TYPES) { + ignoreWarningProducer.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(type)); + } + } + @BuildStep void registerClasses( BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps,
['extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java']
{'.java': 1}
1
1
0
0
1
14,354,093
2,798,684
373,066
3,959
542
109
11
1
1,503
187
360
19
2
1
2021-01-25T11:02: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,865
quarkusio/quarkus/14511/14510
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14510
https://github.com/quarkusio/quarkus/pull/14511
https://github.com/quarkusio/quarkus/pull/14511
1
fixes
ConcurrentModificationException thrown when closing a connection on a reactive pool
**Describe the bug** While operating database, an exceptions is thrown randomly (but very often), here's the stacktrace: ``` Caused by: java.util.ConcurrentModificationException at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013) at java.base/java.util.ArrayList$Itr.next(ArrayList.java:967) at io.quarkus.reactive.datasource.runtime.ThreadLocalPool.scanForAbandonedConnections(ThreadLocalPool.java:75) at io.quarkus.reactive.datasource.runtime.ThreadLocalPool.pool(ThreadLocalPool.java:68) at io.quarkus.reactive.datasource.runtime.ThreadLocalPool.preparedQuery(ThreadLocalPool.java:108) at io.vertx.mutiny.sqlclient.Pool.preparedQuery(Pool.java:149) at io.vertx.mutiny.pgclient.PgPool_2d3061477c44a6b700dc3f9c4fe453a846636193_Synthetic_ClientProxy.preparedQuery(PgPool_2d3061477c44a6b700dc3f9c4fe453a846636193_Synthetic_ClientProxy.zig:275) at com.buguroo.environment.traveler.service.dao.UserCountryDao.forCompanyAndUser(UserCountryDao.java:44) at com.buguroo.environment.traveler.service.dao.UserCountryDao_Subclass.forCompanyAndUser$$superaccessor3(UserCountryDao_Subclass.zig:589) at com.buguroo.environment.traveler.service.dao.UserCountryDao_Subclass$$function$$3.apply(UserCountryDao_Subclass$$function$$3.zig:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:127) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:100) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:32) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:53) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:26) at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:340) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32) at com.buguroo.environment.traveler.service.dao.UserCountryDao_Subclass.forCompanyAndUser(UserCountryDao_Subclass.zig:544) at com.buguroo.environment.traveler.service.dao.UserCountryDao_ClientProxy.forCompanyAndUser(UserCountryDao_ClientProxy.zig:191) at com.buguroo.environment.traveler.service.FrequentTravelerService.getOpinion(FrequentTravelerService.java:39) at com.buguroo.environment.traveler.service.FrequentTravelerService_ClientProxy.getOpinion(FrequentTravelerService_ClientProxy.zig:157) at com.buguroo.environment.traveler.FrequentTravelerListener.process(FrequentTravelerListener.java:57) at com.buguroo.environment.traveler.FrequentTravelerListener_Subclass.process$$superaccessor1(FrequentTravelerListener_Subclass.zig:400) at com.buguroo.environment.traveler.FrequentTravelerListener_Subclass$$function$$1.apply(FrequentTravelerListener_Subclass$$function$$1.zig:33) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54) at io.smallrye.faulttolerance.FaultToleranceInterceptor.lambda$null$1(FaultToleranceInterceptor.java:178) ... 6 more ``` From what it seems, the code was introduced in https://github.com/quarkusio/quarkus/pull/14134 . In fact the behaviour disappears if I turn back to 1.10.5. The PR contains a test, but the test does not cover the scenario because it fails only when the "dead" connection is not the last (because it calls close which ends up modifying `allConnections`). **Expected behavior** Not to throw an exception ;). However, I'm wondering if I'm doing something wrong in my code because I wouldn't expect pools to be closed this often. **Actual behavior** The added exception is thrown. **To Reproduce** Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. 2. 3. **Configuration** Configuring reactive database connection pooling. **Screenshots** N/A **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux <redacted> 5.4.0-54-generic #60-Ubuntu SMP Fri Nov 6 10:37:59 UTC 2020 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): - Quarkus version or git rev: 1.11.0 - 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.4.0-54-generic", arch: "amd64", family: "unix" ``` **Additional context** N/A
d49e1af592c21c4d6da9fe5a35fff1140165693d
93264866c74a4153a7b2041d95dfa36b2ad94862
https://github.com/quarkusio/quarkus/compare/d49e1af592c21c4d6da9fe5a35fff1140165693d...93264866c74a4153a7b2041d95dfa36b2ad94862
diff --git a/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/runtime/ConnectionPoolsClosedTest.java b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/runtime/ConnectionPoolsClosedTest.java index ef3892b0e94..7dc8bec3e87 100644 --- a/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/runtime/ConnectionPoolsClosedTest.java +++ b/extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/runtime/ConnectionPoolsClosedTest.java @@ -40,6 +40,45 @@ public void connectionsFromOtherThreadsGetClosed() throws ExecutionException, In Assert.assertTrue(globalPool.trackedSize() == 0); } + /** + * This test makes sure that when the closed connection is not the last one in the list + * of closed connections, no exception is thrown. + */ + @Test + public void connectionsThatAreNotTheLastGetClosedSuccessfully() + throws ExecutionException, InterruptedException { + ExecutorService e = Executors.newFixedThreadPool(3); + try { + TestableThreadLocalPool globalPool = new TestableThreadLocalPool(); + Assert.assertTrue(globalPool.trackedSize() == 0); + final TestPoolInterface p1 = grabPoolFromLongLivingThread(globalPool, e); + Assert.assertFalse(p1.isClosed()); + Assert.assertTrue(globalPool.trackedSize() == 1); + final TestPoolInterface p2 = grabPoolFromLongLivingThread(globalPool, e); + Assert.assertFalse(p1.isClosed()); + Assert.assertFalse(p2.isClosed()); + Assert.assertFalse(p1.isClosed()); + Assert.assertFalse(p2.isClosed()); + Assert.assertTrue(globalPool.trackedSize() == 2); + e.shutdown(); + while (!e.isTerminated()) { + Thread.sleep(1); + } + final TestPoolInterface p3 = grabPoolFromOtherThread(globalPool); + Assert.assertTrue(p1.isClosed()); + Assert.assertTrue(p2.isClosed()); + Assert.assertFalse(p3.isClosed()); + Assert.assertTrue(globalPool.trackedSize() == 1); + globalPool.close(); + Assert.assertTrue(p1.isClosed()); + Assert.assertTrue(p2.isClosed()); + Assert.assertTrue(p3.isClosed()); + Assert.assertTrue(globalPool.trackedSize() == 0); + } finally { + e.shutdown(); + } + } + /** * Here we check that when explicit close of a thread-local * specific pool is closed, we also de-reference it. @@ -84,4 +123,15 @@ private TestPoolInterface grabPoolFromOtherThread(TestableThreadLocalPool global return poolInstance; } + private TestPoolInterface grabPoolFromLongLivingThread(TestableThreadLocalPool globalPool, + ExecutorService e) + throws InterruptedException, ExecutionException { + AtomicReference<Thread> thread = new AtomicReference<>(); + final Future<TestPoolInterface> creation = e.submit(() -> { + thread.set(Thread.currentThread()); + return globalPool.pool(); + }); + return creation.get(); + } + } diff --git a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/ThreadLocalPool.java b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/ThreadLocalPool.java index 5ad8da4b20c..4474217ef2b 100644 --- a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/ThreadLocalPool.java +++ b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/ThreadLocalPool.java @@ -72,13 +72,19 @@ PoolType pool() { } private final void scanForAbandonedConnections() { + ArrayList<PoolAndThread> garbage = new ArrayList<>(); for (PoolAndThread pair : allConnections) { if (pair.isDead()) { - //This might potentially close the connection a second time, - //so we need to ensure implementations allow it. - pair.close(); + garbage.add(pair); } } + //This needs a second loop, as the close() operation + //will otherwise trigger a concurrent modification on the iterator. + for (PoolAndThread dead : garbage) { + //This might potentially close the connection a second time, + //so we need to ensure implementations allow it. + dead.close(); + } } private void checkPoolIsOpen() {
['extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/ThreadLocalPool.java', 'extensions/reactive-datasource/deployment/src/test/java/io/quarkus/reactive/datasource/runtime/ConnectionPoolsClosedTest.java']
{'.java': 2}
2
2
0
0
2
14,327,271
2,793,517
372,380
3,949
632
110
12
1
5,549
331
1,467
87
1
3
2021-01-22T09:12:18
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,867
quarkusio/quarkus/14477/13871
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13871
https://github.com/quarkusio/quarkus/pull/14477
https://github.com/quarkusio/quarkus/pull/14477
1
fixes
Hibernate Proxy classes generated with incorrect java release version
**Describe the bug** We can set the java release version to be used through maven property `maven.compiler.release` (e.g. `<maven.compiler.release>11</maven.compiler.release>`) When the project is then compiled with a `javac` version >= 11 and run with java 11, an `java.lang.UnsupportedClassVersionError` is thrown on application startup. **Expected behavior** All sources should be compiled to target the specified java release, and the application should start up. **Actual behavior** On application startup, the following exception is thrown: ``` Exception in thread "main" java.lang.ExceptionInInitializerError at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) at java.base/java.lang.Class.newInstance(Unknown Source) at io.quarkus.runtime.Quarkus.run(Quarkus.java:61) at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) at io.quarkus.runtime.Quarkus.run(Quarkus.java:104) at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) Caused by: java.lang.RuntimeException: Failed to start quarkus at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:249) ... 9 more Caused by: java.lang.UnsupportedClassVersionError: de/turing85/HelloEntity$HibernateProxy$0mzonqkm has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(Unknown Source) at java.base/java.security.SecureClassLoader.defineClass(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Unknown Source) at io.quarkus.hibernate.orm.runtime.proxies.ProxyDefinitions.generateProxyClass(ProxyDefinitions.java:127) at io.quarkus.hibernate.orm.runtime.proxies.ProxyDefinitions.createFromMetadata(ProxyDefinitions.java:61) at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:318) 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:58) at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:53) at io.quarkus.deployment.steps.ArcProcessor$generateResources-1025303321.deploy_0(ArcProcessor$generateResources-1025303321.zig:127) at io.quarkus.deployment.steps.ArcProcessor$generateResources-1025303321.deploy(ArcProcessor$generateResources-1025303321.zig:40) at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:207) ... 9 more ``` **To Reproduce** - Checkout `https://github.com/turing85/quarkus-hibernate-javaversion-bug` - verify `javac` version is `>11`: > javac -version javac 14.0.2 - Compile project, start docker-container: ./mvnw clean install -Dquarkus.container-image.build=true && docker run quarkus-bug/hello-app:1.0.0 **Environment (please complete the following information):** - Output of `uname -a` or `ver`: `Linux XXX 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux` - Output of `java -version`: openjdk 14.0.2 2020-07-14 OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing) - GraalVM version (if different from Java): N/A - Quarkus version or git rev: `1.10.3.Final` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/marco/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 14.0.2, vendor: AdoptOpenJDK, runtime: /opt/adoptOpenJDK/14.0.2+12 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.4.0-58-generic", arch: "amd64", family: "unix" **Additional Information:** The problem starts occurring if and only if `quarkus.datasource.db-kind` is set.
65ccca02b3efea831f1fe1841b8054556263599e
181afe86a49a2284ab0b5ce1a36b957dba98aacf
https://github.com/quarkusio/quarkus/compare/65ccca02b3efea831f1fe1841b8054556263599e...181afe86a49a2284ab0b5ce1a36b957dba98aacf
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java index a03ac63041a..1310099e050 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java @@ -12,6 +12,7 @@ import io.quarkus.deployment.QuarkusClassWriter; import io.quarkus.gizmo.Gizmo; +import net.bytebuddy.ClassFileVersion; /** * Used to transform bytecode by registering to @@ -27,7 +28,8 @@ */ public final class HibernateEntityEnhancer implements BiFunction<String, ClassVisitor, ClassVisitor> { - private static final BytecodeProvider PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl(); + private static final BytecodeProvider PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl( + ClassFileVersion.JAVA_V8); @Override public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) { diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java index 5c407026288..63429b0969c 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java @@ -5,6 +5,7 @@ import org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl; import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper; +import net.bytebuddy.ClassFileVersion; import net.bytebuddy.dynamic.DynamicType; /** @@ -29,7 +30,7 @@ private ByteBuddyProxyHelper getByteBuddyProxyHelper() { //Lazy initialization of Byte Buddy: we'll likely need it, but if we can avoid loading it //in some corner cases it's worth avoiding it. if (this.byteBuddyProxyHelper == null) { - bytecodeProvider = new BytecodeProviderImpl(); + bytecodeProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8); this.byteBuddyProxyHelper = bytecodeProvider.getByteBuddyProxyHelper(); } return this.byteBuddyProxyHelper; diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java index 45d565aa06f..f58b947e41f 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java @@ -7,6 +7,8 @@ import org.hibernate.bytecode.spi.ProxyFactoryFactory; import org.hibernate.service.spi.ServiceRegistryImplementor; +import net.bytebuddy.ClassFileVersion; + /** * We need a different implementation of ProxyFactoryFactory during the build than at runtime, * so to allow metadata validation. This implementation is then swapped after the metadata has been recorded. @@ -22,7 +24,7 @@ public final class BootstrapOnlyProxyFactoryFactoryInitiator implements Standard @Override public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { - BytecodeProviderImpl bbProvider = new BytecodeProviderImpl(); + BytecodeProviderImpl bbProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8); return bbProvider.getProxyFactoryFactory(); } diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java index 1e7662652a5..b44d9cb114a 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java @@ -18,6 +18,8 @@ import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper; import org.jboss.logging.Logger; +import net.bytebuddy.ClassFileVersion; + /** * Runtime proxies are used by Hibernate ORM to handle a number of corner cases; * in particular Enhanced Proxies need special consideration in Quarkus as @@ -191,7 +193,7 @@ private static final class LazyBytecode implements Supplier<ByteBuddyProxyHelper @Override public ByteBuddyProxyHelper get() { if (helper == null) { - bytecodeProvider = new BytecodeProviderImpl(); + bytecodeProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8); helper = bytecodeProvider.getByteBuddyProxyHelper(); } return helper;
['extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java', 'extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java', 'extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java', 'extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java']
{'.java': 4}
4
4
0
0
4
14,328,820
2,793,873
372,414
3,950
908
174
15
4
5,159
355
1,304
80
1
1
2021-01-21T12:08:05
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,868
quarkusio/quarkus/14458/9194
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/9194
https://github.com/quarkusio/quarkus/pull/14458
https://github.com/quarkusio/quarkus/pull/14458
1
fixes
Exception logged by quarkus after SSE client is closed - "Failed to mark a promise as failure because it has failed already: DefaultChannelPromise failure: java.nio.channels.ClosedChannelException"
**Describe the bug** I have a service method which SSE clients can use to subscribe to a stream. It returns a Multi. I have a second method which can be used to emit data. The SSE clients receive the data. Everything works fine, and as expected, except that after a client has disconnected, a warning is logged that it `Failed to mark a promise as failure because it has failed already: DefaultChannelPromise failure: java.nio.channels.ClosedChannelException`. **Expected behavior** No warning should be logged, as nothing abnormal has actually happened. **Actual behavior** A warning is logged, as shown above. **To Reproduce** Steps to reproduce the behavior: 1. Create a method which clients can used to subscribe to SSEs: ``` /** * allows a caller to subscribe to changes of a certain type of object */ @GET @Path("/changes/{subscriberId}") @Produces(MediaType.SERVER_SENT_EVENTS) public Multi<AnObject> changes(@PathParam("subscriberId") String subscriberId, @QueryParam("type") List<String> type) { SubscriberModel subscriberModel = SUBSCRIBERS.computeIfAbsent(subscriberId, k -> new SubscriberModel()); subscriberModel.setId(subscriberId); return Multi.createFrom() .emitter(e -> { subscriberModel.setEmitter(e); e.onTermination(() -> { logger.info("Removing subscriber " + subscriberId); e.complete(); SUBSCRIBERS.remove(subscriberId); // even though the above works nicely, there is an exception logged by quarkus, afterwards. // see https://stackoverflow.com/questions/61694510/how-to-handle-a-closedchannelexception-on-a-reactive-streams-http-connection-clo // }); }, BackPressureStrategy.ERROR); } ``` 2. Create a method used to emit data to all subscribers: ``` /** * test method in order to emit an object to ALL subscribers */ @GET @Path("/emit") @Produces(MediaType.APPLICATION_JSON) public Response emit() { logger.info("emitting to " + SUBSCRIBERS.size() + " subscribers"); SUBSCRIBERS.values().forEach(sm -> sm.emit(new AnObject(UUID.randomUUID(), "anObject")) ); return Response.noContent().build(); } ``` 3. subscribe using curl: `curl -v -X GET localhost:8086/objects/changes/aClient` 4. hit ctrl+c to close that client. Nothing happens yet in Quarkus, but that is OK, because it is quite standard to use a heart beat to deal with that. This is also required in some SSE servlet implementations. 5. emit an event using curl: `curl -v -X GET localhost:8086/objects/emit` 6. the subscriber is correctly removed from the model 7. the unexpected warning is logged **Configuration** ```properties # the following line is not really used, as the native libraries are not depended upon in the pom. quarkus.vertx.prefer-native-transport=true quarkus.http.port=8086 quarkus.log.file.enable=true quarkus.log.file.level=INFO quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n quarkus.log.category."ch.maxant.kdc.objects".level=DEBUG ``` **Screenshots** ``` 2020-05-10 14:26:12,366 INFO [ch.max.kdc.obj.ObjectResource] (vert.x-eventloop-thread-6) Removing subscriber aClient 2020-05-10 14:30:59,200 WARN [io.net.cha.AbstractChannelHandlerContext] (vert.x-eventloop-thread-6) Failed to mark a promise as failure because it has failed already: DefaultChannelPromise@22021ebc(failure: java.nio.channels.ClosedChannelException), unnotified cause: java.nio.channels.ClosedChannelException at io.netty.channel.AbstractChannel$AbstractUnsafe.newClosedChannelException(AbstractChannel.java:957) at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:865) at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1367) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:715) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:762) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.vertx.core.net.impl.ConnectionBase.write(ConnectionBase.java:124) at io.vertx.core.net.impl.ConnectionBase.lambda$queueForWrite$2(ConnectionBase.java:215) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) : io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1 at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) at io.netty.handler.codec.http.DefaultHttpContent.release(DefaultHttpContent.java:92) at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88) at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:867) at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1367) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:715) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:762) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:788) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:756) at io.vertx.core.net.impl.ConnectionBase.write(ConnectionBase.java:124) at io.vertx.core.net.impl.ConnectionBase.lambda$queueForWrite$2(ConnectionBase.java:215) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux hades-ubuntu 5.3.0-51-generic #44-Ubuntu SMP Wed Apr 22 21:09:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux - Output of `java -version`: openjdk 11.0.7 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu219.10) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu219.10, mixed mode, sharing) - GraalVM version (if different from Java): - Quarkus version or git rev: 1.4.2.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /snap/intellij-idea-community/226/plugins/maven/lib/maven3 Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.3.0-51-generic", arch: "amd64", family: "unix" **Additional context** (Add any other context about the problem here.)
0e4796dda846e962d239438ec8ebc9c7003a48fc
d07da7d92d710a5f126a9a008e09ac08ece8dfea
https://github.com/quarkusio/quarkus/compare/0e4796dda846e962d239438ec8ebc9c7003a48fc...d07da7d92d710a5f126a9a008e09ac08ece8dfea
diff --git a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxOutputStream.java b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxOutputStream.java index ea3e339db0d..3dd4255d70d 100644 --- a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxOutputStream.java +++ b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxOutputStream.java @@ -142,11 +142,7 @@ private CompletionStage<Void> asyncFlush(boolean isLast) { if (pooledBuffer != null) { ByteBuf sentBuffer = pooledBuffer; pooledBuffer = null; - CompletionStage<Void> ret = response.writeNonBlocking(sentBuffer, isLast); - return ret.whenComplete((v, t) -> { - if (t != null) - sentBuffer.release(); - }); + return response.writeNonBlocking(sentBuffer, isLast); } return CompletableFuture.completedFuture(null); }
['extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxOutputStream.java']
{'.java': 1}
1
1
0
0
1
14,324,904
2,793,138
372,321
3,950
295
55
6
1
10,058
611
2,158
166
1
4
2021-01-20T22:00:45
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,869
quarkusio/quarkus/14353/14313
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14313
https://github.com/quarkusio/quarkus/pull/14353
https://github.com/quarkusio/quarkus/pull/14353
1
fixes
Quarkus Form Authentication...404 Response
**Description** I'm using form authentication (quarkus.http.auth.form.enabled = true) with security-jpa and it works fine except when there is a post authorization error. Also, my spa is located in resources/META-INF/resources During my development I had a null pointer in the endpoint I set up as a re-direct. I corrected the logic, then re-submitted my login to j_security_check and got a 404. This one took me awhile to figure out the issue. Since the error occured after authentication, my browser had the quarkus-credential cookie and subsequent attempts to login with the cookie present triggers a 404 response. I built a unit test to reproduce the error: public void testFormBasedAuthentication() { ValidatableResponse response = given() .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body("j_username=read.only&j_password=jackplane") .post("j_security_check") .then() .statusCode(Status.FOUND.getStatusCode()) .cookie("quarkus-credential",notNullValue()); String cookie = response.extract().cookie("quarkus-credential"); // submit another login with the cookie received in the prior response given() .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body("j_username=read.only&j_password=jackplane") .cookie("quarkus-credential", cookie, "") .post("j_security_check") .then() .statusCode(Status.FOUND.getStatusCode()) .cookie("xsrf-token",notNullValue()); } Is this operating as intended to prevent subsequent login when a cookie is currently valid? If so, a 404 doesn't seem to be the correct status code. **Implementation ideas** Could the form based authentication logic return a different response ?
4c323ae72d2466c72ada1d2fbf773653748a4a84
50ec961e8ddefa923717b60c7d3fc767c4c619f7
https://github.com/quarkusio/quarkus/compare/4c323ae72d2466c72ada1d2fbf773653748a4a84...50ec961e8ddefa923717b60c7d3fc767c4c619f7
diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java index c8985925854..e2983588465 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java @@ -45,7 +45,8 @@ public JavaArchive get() { @BeforeAll public static void setup() { TestIdentityController.resetRoles() - .add("admin", "admin", "admin"); + .add("admin", "admin", "admin") + .add("test", "test", "admin"); } @Test @@ -90,6 +91,33 @@ public void testFormBasedAuthSuccess() { .statusCode(200) .body(equalTo("admin:/admin")); + //now authenticate with a different user + RestAssured + .given() + .filter(cookies) + .redirects().follow(false) + .when() + .formParam("j_username", "test") + .formParam("j_password", "test") + .post("/j_security_check") + .then() + .assertThat() + .statusCode(302) + .header("location", containsString("/admin")) + .cookie("quarkus-credential", + RestAssuredMatchers.detailedCookie().value(notNullValue()).secured(false)); + + RestAssured + .given() + .filter(cookies) + .redirects().follow(false) + .when() + .get("/admin") + .then() + .assertThat() + .statusCode(200) + .body(equalTo("test:/admin")); + } @Test diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java index 062965097f7..d30b1ff676f 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java @@ -147,21 +147,21 @@ static Uni<ChallengeData> getRedirect(final RoutingContext exchange, final Strin public Uni<SecurityIdentity> authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { - PersistentLoginManager.RestoreResult result = loginManager.restore(context); - if (result != null) { - Uni<SecurityIdentity> ret = identityProviderManager - .authenticate(new TrustedAuthenticationRequest(result.getPrincipal())); - return ret.onItem().invoke(new Consumer<SecurityIdentity>() { - @Override - public void accept(SecurityIdentity securityIdentity) { - loginManager.save(securityIdentity, context, result, context.request().isSSL()); - } - }); - } - if (context.normalisedPath().endsWith(postLocation) && context.request().method().equals(HttpMethod.POST)) { + //we always re-auth if it is a post to the auth URL return runFormAuth(context, identityProviderManager); } else { + PersistentLoginManager.RestoreResult result = loginManager.restore(context); + if (result != null) { + Uni<SecurityIdentity> ret = identityProviderManager + .authenticate(new TrustedAuthenticationRequest(result.getPrincipal())); + return ret.onItem().invoke(new Consumer<SecurityIdentity>() { + @Override + public void accept(SecurityIdentity securityIdentity) { + loginManager.save(securityIdentity, context, result, context.request().isSSL()); + } + }); + } return Uni.createFrom().optional(Optional.empty()); } }
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java']
{'.java': 2}
2
2
0
0
2
14,277,235
2,784,535
371,162
3,947
1,308
212
24
1
1,940
185
381
31
0
0
2021-01-17T23:18:14
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,870
quarkusio/quarkus/14351/14333
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14333
https://github.com/quarkusio/quarkus/pull/14351
https://github.com/quarkusio/quarkus/pull/14351
1
fixes
NPE in ArtemisJmsProducer.connectionFactory()
**Describe the bug** A minimal application using `quarkus-artemis-jms` fails to start with strange NPE. See full code below. **Expected behavior** The application should start and initialize JMS ConnectionFactory without any exceptions. **Actual behavior** NPE immediately after startup: ``` 2021-01-15 21:49:53,977 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.NullPointerException at io.quarkus.artemis.jms.runtime.ArtemisJmsProducer.connectionFactory(ArtemisJmsProducer.java:21) at io.quarkus.artemis.jms.runtime.ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_Bean.create(ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_Bean.zig:166) at io.quarkus.artemis.jms.runtime.ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_Bean.create(ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_Bean.zig:197) at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96) at io.quarkus.arc.impl.AbstractSharedContext.access$000(AbstractSharedContext.java:14) at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29) at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26) at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26) at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69) at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26) at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:17) at io.quarkus.artemis.jms.runtime.ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_ClientProxy.arc$delegate(ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_ClientProxy.zig:68) at io.quarkus.artemis.jms.runtime.ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_ClientProxy.createContext(ArtemisJmsProducer_ProducerMethod_connectionFactory_77384d97dd5fab56fb7d89e045176235cbda65cd_ClientProxy.zig:146) at Bean2.doSomething(Bean2.java:16) at Bean2_ClientProxy.doSomething(Bean2_ClientProxy.zig:155) at Bean1.onStart(Bean1.java:10) at Bean1_Observer_onStart_31a1bd3f2053c759a740ca423787158a0219f934.notify(Bean1_Observer_onStart_31a1bd3f2053c759a740ca423787158a0219f934.zig:179) at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282) at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:267) at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69) at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23) at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:60) at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent-858218658.deploy_0(LifecycleEventsBuildStep$startupEvent-858218658.zig:81) at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent-858218658.deploy(LifecycleEventsBuildStep$startupEvent-858218658.zig:40) at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:400) at io.quarkus.runtime.Application.start(Application.java:90) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:97) at io.quarkus.runtime.Quarkus.run(Quarkus.java:62) at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) at io.quarkus.runtime.Quarkus.run(Quarkus.java:104) at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) 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$3.run(StartupActionImpl.java:134) at java.base/java.lang.Thread.run(Thread.java:834) ``` **To Reproduce** Create a project consisting of the following two Java source files and a pom.xml, then run `mvn quarkus:dev`. ```java import io.quarkus.runtime.StartupEvent; import javax.enterprise.event.Observes; import javax.inject.Singleton; @Singleton public class Bean1 { public void onStart(@Observes StartupEvent ev, Bean2 bean2) { bean2.doSomething(); } } ``` ```java import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.jms.ConnectionFactory; @ApplicationScoped public class Bean2 { private final ConnectionFactory connectionFactory; @Inject public Bean2(ConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } public void doSomething() { connectionFactory.createContext(); } } ``` ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>reproducer</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <quarkus.version>1.10.5.Final</quarkus.version> </properties> <build> <plugins> <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.version}</version> <executions> <execution> <id>quarkus-build</id> <goals> <goal>build</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-bom</artifactId> <version>${quarkus.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-artemis-jms</artifactId> </dependency> </dependencies> </project> ``` **Configuration** ```properties quarkus.artemis.url=tcp://localhost:61616 ``` **Environment (please complete the following information):** - Output of `uname -a`: `Linux 5.4.48-gentoo #2 SMP Wed Oct 7 20:15:36 MSK 2020 x86_64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz GenuineIntel GNU/Linux` - Output of `java -version`: `openjdk version "11.0.9.1" 2020-11-04 LTS` - Quarkus version or git rev: `1.10.5.Final` - Build tool (output of `mvnw --version`): `Apache Maven 3.6.3`
4c323ae72d2466c72ada1d2fbf773653748a4a84
1101835903956a6d4fa8e12a2f2213783e3ac601
https://github.com/quarkusio/quarkus/compare/4c323ae72d2466c72ada1d2fbf773653748a4a84...1101835903956a6d4fa8e12a2f2213783e3ac601
diff --git a/extensions/artemis-jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java b/extensions/artemis-jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java index a2343bbc064..f8621d8fd8f 100644 --- a/extensions/artemis-jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java +++ b/extensions/artemis-jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java @@ -1,11 +1,12 @@ package io.quarkus.artemis.jms.deployment; -import io.quarkus.arc.deployment.AdditionalBeanBuildItem; -import io.quarkus.arc.deployment.BeanContainerBuildItem; +import javax.enterprise.context.ApplicationScoped; +import javax.jms.ConnectionFactory; + +import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.artemis.core.deployment.ArtemisBuildTimeConfig; import io.quarkus.artemis.core.deployment.ArtemisJmsBuildItem; import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfig; -import io.quarkus.artemis.jms.runtime.ArtemisJmsProducer; import io.quarkus.artemis.jms.runtime.ArtemisJmsRecorder; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -18,12 +19,10 @@ public class ArtemisJmsProcessor { @BuildStep - void load(BuildProducer<AdditionalBeanBuildItem> additionalBean, BuildProducer<FeatureBuildItem> feature, - BuildProducer<ArtemisJmsBuildItem> artemisJms) { + void load(BuildProducer<FeatureBuildItem> feature, BuildProducer<ArtemisJmsBuildItem> artemisJms) { artemisJms.produce(new ArtemisJmsBuildItem()); feature.produce(new FeatureBuildItem(Feature.ARTEMIS_JMS)); - additionalBean.produce(AdditionalBeanBuildItem.unremovableOf(ArtemisJmsProducer.class)); } @BuildStep @@ -36,9 +35,17 @@ HealthBuildItem health(ArtemisBuildTimeConfig buildConfig) { @Record(ExecutionTime.RUNTIME_INIT) @BuildStep ArtemisJmsConfiguredBuildItem configure(ArtemisJmsRecorder recorder, ArtemisRuntimeConfig runtimeConfig, - BeanContainerBuildItem beanContainer) { + BuildProducer<SyntheticBeanBuildItem> syntheticBeanProducer) { + + SyntheticBeanBuildItem connectionFactory = SyntheticBeanBuildItem.configure(ConnectionFactory.class) + .supplier(recorder.getConnectionFactorySupplier(runtimeConfig)) + .scope(ApplicationScoped.class) + .defaultBean() + .unremovable() + .setRuntimeInit() + .done(); + syntheticBeanProducer.produce(connectionFactory); - recorder.setConfig(runtimeConfig, beanContainer.getValue()); return new ArtemisJmsConfiguredBuildItem(); } } diff --git a/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsProducer.java b/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsProducer.java deleted file mode 100644 index 7e4748c7a17..00000000000 --- a/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsProducer.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.quarkus.artemis.jms.runtime; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.jms.ConnectionFactory; - -import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; - -import io.quarkus.arc.DefaultBean; -import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfig; - -@ApplicationScoped -public class ArtemisJmsProducer { - - private ArtemisRuntimeConfig config; - - @Produces - @ApplicationScoped - @DefaultBean - public ConnectionFactory connectionFactory() { - return new ActiveMQJMSConnectionFactory(config.url, - config.username.orElse(null), config.password.orElse(null)); - } - - public ArtemisRuntimeConfig getConfig() { - return config; - } - - public void setConfig(ArtemisRuntimeConfig config) { - this.config = config; - } -} diff --git a/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java b/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java index fffef19ee83..8069ced0bba 100644 --- a/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java +++ b/extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java @@ -1,13 +1,23 @@ package io.quarkus.artemis.jms.runtime; -import io.quarkus.arc.runtime.BeanContainer; +import java.util.function.Supplier; + +import javax.jms.ConnectionFactory; + +import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; + import io.quarkus.artemis.core.runtime.ArtemisRuntimeConfig; import io.quarkus.runtime.annotations.Recorder; @Recorder public class ArtemisJmsRecorder { - public void setConfig(ArtemisRuntimeConfig config, BeanContainer container) { - container.instance(ArtemisJmsProducer.class).setConfig(config); + public Supplier<ConnectionFactory> getConnectionFactorySupplier(ArtemisRuntimeConfig config) { + return new Supplier<ConnectionFactory>() { + @Override + public ConnectionFactory get() { + return new ActiveMQJMSConnectionFactory(config.url, config.username.orElse(null), config.password.orElse(null)); + } + }; } }
['extensions/artemis-jms/deployment/src/main/java/io/quarkus/artemis/jms/deployment/ArtemisJmsProcessor.java', 'extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsProducer.java', 'extensions/artemis-jms/runtime/src/main/java/io/quarkus/artemis/jms/runtime/ArtemisJmsRecorder.java']
{'.java': 3}
3
3
0
0
3
14,277,235
2,784,535
371,162
3,947
2,952
584
71
3
7,397
322
1,941
159
4
5
2021-01-17T19:46:32
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,895
quarkusio/quarkus/13335/13317
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13317
https://github.com/quarkusio/quarkus/pull/13335
https://github.com/quarkusio/quarkus/pull/13335
1
fixes
Quarkus HTTP response gets messed up under load
**Describe the bug** The issue title might be a bit misleading, still trying to understand. Last week, we had an application starting to return broken HTTP response (more on this below) under load on OpenShift (important as the limited concurrency may be the issue). ``` while true; do curl -XGET -i -Hx-rh-identity:`cat rhid` localhost:8080/api/notifications/v1.0/notifications/defaults; done; ``` The application is using Mutiny, Reactor, and R2DBC. It does an R2DBC query and the result is produced in a reactor epoll thread (Thread[reactor-tcp-epoll-7,5,executor]). The HTTP endpoint is returning a `Uni<List<Endpoint>>`. Under load, it sometimes returns: ``` HTTP/1.1 200 OK Content-Length: 0 ``` and sometimes: ``` HTTP/1.1 200 OK Content-Length: 706 Content-Type: application/json [{...}][{...}] ``` So 2 concatenated responses. We have verified that the item provided by the Uni is correct, so the issue is around the HTTP response write and flush. As the endpoint is async, the request is suspended and resume. But it seems that the resuming may lead to a wrong (Vert.x) context. **To Reproduce** Unfortunately, I was not able to reproduce it locally. It only happens in OpenShift. I believe it's because of the limited parallelism (and so limited event loop) which means they may be reused by multiple requests.
a13443c875465f2ff0cfe5b04b5aa293288a94ac
912d62eb7832d1f3914c847671be45e3212695b4
https://github.com/quarkusio/quarkus/compare/a13443c875465f2ff0cfe5b04b5aa293288a94ac...912d62eb7832d1f3914c847671be45e3212695b4
diff --git a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java index d74ee5fc520..38502bac3d2 100644 --- a/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java +++ b/extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java @@ -3,6 +3,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Executor; import javax.enterprise.inject.Instance; @@ -126,9 +128,10 @@ private void dispatch(RoutingContext routingContext, InputStream is, VertxOutput hostSupplier, dispatcher.getDispatcher(), vertxResponse, requestContext, executor); vertxRequest.setInputStream(is); - try { - ResteasyContext.pushContext(SecurityContext.class, new QuarkusResteasySecurityContext(request, routingContext)); - ResteasyContext.pushContext(RoutingContext.class, routingContext); + Map<Class<?>, Object> map = new HashMap<>(); + map.put(SecurityContext.class, new QuarkusResteasySecurityContext(request, routingContext)); + map.put(RoutingContext.class, routingContext); + try (ResteasyContext.CloseableContext restCtx = ResteasyContext.addCloseableContextDataLevel(map)) { ContextUtil.pushContext(routingContext); dispatcher.service(ctx, request, response, vertxRequest, vertxResponse, true); } catch (Failure e1) {
['extensions/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/standalone/VertxRequestHandler.java']
{'.java': 1}
1
1
0
0
1
11,841,671
2,314,844
307,962
3,280
620
119
9
1
1,377
200
340
39
0
3
2020-11-17T07:29: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,896
quarkusio/quarkus/13325/13289
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13289
https://github.com/quarkusio/quarkus/pull/13325
https://github.com/quarkusio/quarkus/pull/13325
1
fixes
Suspicious CI failure in AddExtensionsMojoTest.testAddSingleDependency
First, I wonder a bit why we end up having the Gradle repo in a Maven test. AFAIU, the bootstrap resolver both includes Maven and Gradle but I wonder if we could have an architecture where we have only Maven when using Maven and only Gradle when using Gradle? Apart, from that, I think the issue is probably related to an issue with the Gradle repo... but... I don't think downloading an empty artifact is ok? See: `Downloading from google-maven-central: https://maven-central-eu.storage-download.googleapis.com/repos/central/data///-.pom` So I wonder if there's something fishy? ``` Downloading from gradle-official-repository: https://repo.gradle.org/gradle/libs-releases-local/io/quarkus/quarkus-bom/maven-metadata.xml [debug] The requested Quarkus platform BOM version is available on the classpath Downloading from google-maven-central: https://maven-central-eu.storage-download.googleapis.com/repos/central/data///-.pom Downloading from jboss-maven-central-proxy: https://repository.jboss.org/nexus/content/repositories/central///-.pom Downloading from gradle-official-repository: https://repo.gradle.org/gradle/libs-releases-local///-.pom Downloading from central: https://repo.maven.apache.org/maven2///-.pom Error: Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 489.866 s <<< FAILURE! - in io.quarkus.maven.AddExtensionsMojoTest Error: io.quarkus.maven.AddExtensionsMojoTest.testAddSingleDependency Time elapsed: 301.002 s <<< ERROR! org.apache.maven.plugin.MojoExecutionException: Unable to update the pom.xml file at io.quarkus.maven.AddExtensionMojo.doExecute(AddExtensionMojo.java:80) at io.quarkus.maven.QuarkusProjectMojoBase.execute(QuarkusProjectMojoBase.java:112) at io.quarkus.maven.AddExtensionMojoTest.testAddSingleDependency(AddExtensionMojoTest.java:51) 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 org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162) at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548) Caused by: java.lang.RuntimeException: org.apache.maven.plugin.MojoExecutionException: Failed to collect dependencies for the project at io.quarkus.maven.QuarkusProjectMojoBase.lambda$execute$1(QuarkusProjectMojoBase.java:97) at io.quarkus.maven.MavenProjectBuildFile.getDependencies(MavenProjectBuildFile.java:117) at io.quarkus.devtools.project.buildfile.BuildFile.getDependenciesKeys(BuildFile.java:135) at io.quarkus.devtools.project.buildfile.BuildFile.withoutAlreadyInstalled(BuildFile.java:92) at io.quarkus.devtools.project.buildfile.BuildFile.install(BuildFile.java:45) at io.quarkus.devtools.commands.handlers.AddExtensionsCommandHandler.execute(AddExtensionsCommandHandler.java:45) at io.quarkus.devtools.commands.AddExtensions.execute(AddExtensions.java:56) at io.quarkus.maven.AddExtensionMojo.doExecute(AddExtensionMojo.java:75) ... 70 more Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to collect dependencies for the project at io.quarkus.maven.QuarkusProjectMojoBase.projectDependencies(QuarkusProjectMojoBase.java:345) at io.quarkus.maven.QuarkusProjectMojoBase.lambda$execute$1(QuarkusProjectMojoBase.java:95) ... 77 more Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to collect dependencies for ::pom: at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:226) at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:216) at io.quarkus.maven.QuarkusProjectMojoBase.projectDependencies(QuarkusProjectMojoBase.java:329) ... 78 more Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to read artifact descriptor for ::pom: at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:206) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:284) at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.collectDependencies(MavenArtifactResolver.java:224) ... 80 more Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for ::pom: at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255) at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171) at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:200) ... 82 more Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact ::pom: from/to gradle-official-repository (https://repo.gradle.org/gradle/libs-releases-local/): Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207) at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:240) ... 84 more Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact ::pom: from/to gradle-official-repository (https://repo.gradle.org/gradle/libs-releases-local/): Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:52) at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369) at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75) at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:644) at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:499) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:401) ... 87 more Caused by: org.apache.maven.wagon.TransferFailedException: Transfer failed for https://repo.gradle.org/gradle/libs-releases-local////-.pom 524 Origin Time-out at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1196) at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:1138) at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:126) at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88) at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61) at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run(WagonTransporter.java:567) at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:435) at org.eclipse.aether.transport.wagon.WagonTransporter.get(WagonTransporter.java:412) at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:457) at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:364) ... 92 more ```
03d0fd6821b7212e35427aa305ab1573f35d3e02
362864355d04006806b0f9a8784660ca03a462b7
https://github.com/quarkusio/quarkus/compare/03d0fd6821b7212e35427aa305ab1573f35d3e02...362864355d04006806b0f9a8784660ca03a462b7
diff --git a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java index 0c0ac849a79..406b018e54f 100644 --- a/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java +++ b/independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java @@ -375,7 +375,8 @@ private QuarkusPlatformDescriptor resolveJsonArtifactFromBom(AppModelResolver ar throw new IllegalStateException("Failed to resolve the platform BOM using the provided coordinates", e); } log.debug( - "Failed to resolve Quarkus platform BOM using the default coordinates, falling back to the bundled Quarkus platform artifacts"); + "Failed to resolve Quarkus platform BOM using the default coordinates %s:%s:%s, falling back to the bundled Quarkus platform artifacts", + bomGroupId, bomArtifactId, bomVersion); } Model bundledBom = loadBundledPom(); diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java b/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java index bf2799d2323..a99524f7b5d 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java @@ -12,35 +12,90 @@ import org.apache.commons.io.FileUtils; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.resolution.ArtifactDescriptorResult; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; +import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils; + class AddExtensionMojoTest { - private static final File MIN_POM = new File("src/test/resources/projects/simple-pom-it/pom.xml"); + private static final File MIN_POM = new File("target/test-classes/projects/simple-pom-it/pom.xml"); private static final File OUTPUT_POM = new File("target/test-classes/add-extension/pom.xml"); private static final String DEP_GAV = "org.apache.commons:commons-lang3:3.8.1"; private AddExtensionMojo mojo; @BeforeEach - void init() throws IOException { + void init() throws Exception { mojo = getMojo(); mojo.project = new MavenProject(); mojo.project.setPomFile(OUTPUT_POM); mojo.project.setFile(OUTPUT_POM); - Model model = new Model(); - mojo.project.setModel(model); - mojo.project.setOriginalModel(model); FileUtils.copyFile(MIN_POM, OUTPUT_POM); + + Model model = ModelUtils.readModel(OUTPUT_POM.toPath()); model.setPomFile(OUTPUT_POM); + mojo.project.setOriginalModel(model); + + final MavenArtifactResolver mvn = new MavenArtifactResolver( + new BootstrapMavenContext(BootstrapMavenContext.config() + .setCurrentProject(OUTPUT_POM.getAbsolutePath()) + .setOffline(true))); + mojo.repoSystem = mvn.getSystem(); + mojo.repoSession = mvn.getSession(); + mojo.repos = mvn.getRepositories(); + mojo.remoteRepositoryManager = mvn.getRemoteRepositoryManager(); + + final Model effectiveModel = model.clone(); + final DependencyManagement dm = new DependencyManagement(); + effectiveModel.setDependencyManagement(dm); + final Artifact projectPom = new DefaultArtifact(ModelUtils.getGroupId(model), model.getArtifactId(), null, "pom", + ModelUtils.getVersion(model)); + final ArtifactDescriptorResult descriptor = mvn.resolveDescriptor(projectPom); + descriptor.getManagedDependencies().forEach(d -> { + final Dependency dep = new Dependency(); + Artifact a = d.getArtifact(); + dep.setGroupId(a.getGroupId()); + dep.setArtifactId(a.getArtifactId()); + dep.setClassifier(a.getClassifier()); + dep.setType(a.getExtension()); + dep.setVersion(a.getVersion()); + if (d.getOptional() != null) { + dep.setOptional(d.getOptional()); + } + dep.setScope(d.getScope()); + dm.addDependency(dep); + }); + descriptor.getDependencies().forEach(d -> { + final Dependency dep = new Dependency(); + Artifact a = d.getArtifact(); + dep.setGroupId(a.getGroupId()); + dep.setArtifactId(a.getArtifactId()); + dep.setClassifier(a.getClassifier()); + dep.setType(a.getExtension()); + dep.setVersion(a.getVersion()); + if (d.getOptional() != null) { + dep.setOptional(d.getOptional()); + } + dep.setScope(d.getScope()); + effectiveModel.addDependency(dep); + }); + descriptor.getProperties().entrySet().forEach(p -> effectiveModel.getProperties().setProperty(p.getKey(), + p.getValue() == null ? "" : p.getValue().toString())); + mojo.project.setModel(effectiveModel); } - protected AddExtensionMojo getMojo() { + protected AddExtensionMojo getMojo() throws Exception { return new AddExtensionMojo(); }
['independent-projects/tools/platform-descriptor-resolver-json/src/main/java/io/quarkus/platform/descriptor/resolver/json/QuarkusJsonPlatformDescriptorResolver.java', 'integration-tests/maven/src/test/java/io/quarkus/maven/AddExtensionMojoTest.java']
{'.java': 2}
2
2
0
0
2
11,839,267
2,314,390
307,924
3,280
368
71
3
1
14,680
499
3,126
146
11
1
2020-11-16T17:44:52
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,897
quarkusio/quarkus/13310/13309
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13309
https://github.com/quarkusio/quarkus/pull/13310
https://github.com/quarkusio/quarkus/pull/13310
1
fixes
Quarkus KafkaStream application do not close immediately when no broker is present
**Describe the bug** Quarkus application using the kafka-stream extension do not close immediately if the kafka broker is not available at the time the application starts. **Expected behavior** If no broker available the application have to shutdown immediately **Actual behavior** When closing the application, the admin client that is used by the kafkastream extension do not close immediately because it waits to perform startup task (querying metadata) that need to timeout before closing the admin client. **To Reproduce** * Start a kafkastream application without starting any kafka broker * Quit the application (with Ctrl-C) * Wait (60s) and read the following message : ` 2020-11-16 12:05:28,601 WARN [org.apa.kaf.cli.NetworkClient] (kafka-admin-client-thread | adminclient-1) [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. 2020-11-16 12:05:29,410 INFO [org.apa.kaf.cli.adm.int.AdminMetadataManager] (kafka-admin-client-thread | adminclient-1) [AdminClient clientId=adminclient-1] Metadata update failed: org.apache.kafka.common.errors.TimeoutException: Call(callName=fetchMetadata, deadlineMs=1605524729409) timed out at 1605524729410 after 1 attempt(s) Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. 2020-11-16 12:05:29,773 INFO [org.apa.kaf.cli.adm.int.AdminMetadataManager] (kafka-admin-client-thread | adminclient-1) [AdminClient clientId=adminclient-1] Metadata update failed: org.apache.kafka.common.errors.TimeoutException: Call(callName=fetchMetadata, deadlineMs=1605524759410) timed out at 9223372036854775807 after 1 attempt(s) Caused by: org.apache.kafka.common.errors.TimeoutException: The AdminClient thread has exited. ` Regards
15162d6328b29df57232b1b6033fed871016cd93
3332526bba96e8de8e37b83016cf06ea1e65a78b
https://github.com/quarkusio/quarkus/compare/15162d6328b29df57232b1b6033fed871016cd93...3332526bba96e8de8e37b83016cf06ea1e65a78b
diff --git a/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/KafkaStreamsProducer.java b/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/KafkaStreamsProducer.java index 088e7cb81a7..bf90ed4a76d 100644 --- a/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/KafkaStreamsProducer.java +++ b/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/KafkaStreamsProducer.java @@ -122,7 +122,7 @@ void onStop(@Observes ShutdownEvent event) { kafkaStreams.close(); } if (kafkaAdminClient != null) { - kafkaAdminClient.close(); + kafkaAdminClient.close(Duration.ZERO); } }
['extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/KafkaStreamsProducer.java']
{'.java': 1}
1
1
0
0
1
11,835,572
2,313,644
307,836
3,279
90
14
2
1
1,833
191
450
23
0
0
2020-11-16T11:19:00
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,931
quarkusio/quarkus/12627/12443
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12443
https://github.com/quarkusio/quarkus/pull/12627
https://github.com/quarkusio/quarkus/pull/12627
1
fixes
Hibernate Validator - @Valid Object causes CNFE
**Describe the bug** I noticed an odd behaviour in one of my apps during dev mode. mvn clean install runs sucessfully on the project. `@Valid Object` causes a CNFE for javax.servlet.Filter. The project did not use servlets however. After a bit of debugging, I found this place in the Hibernate Validator extension: https://github.com/quarkusio/quarkus/blob/8f24c19880db64b86d1ee8c1d998ff3c6340acab/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java#L308-L317 It was adding the JaxRsMetricsFilter to the set of classes that need validation. In turn, this loaded at runtime the servlet Filter class. Removing the `@Valid Object` constraint solved the problem for me. **Expected behavior** Quarkus should not blindly add every class it finds as possible class that needs validation. E.g. most of the quarkus internal classes may never need to be validated in user applications. **Actual behavior** ``` 2020-10-01 12:40:16,931 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: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$3.run(StartupActionImpl.java:134) at java.base/java.lang.Thread.run(Thread.java:834) 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:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at java.base/java.lang.Class.newInstance(Class.java:584) at io.quarkus.runtime.Quarkus.run(Quarkus.java:60) at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) at io.quarkus.runtime.Quarkus.run(Quarkus.java:106) at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) ... 6 more Caused by: java.lang.RuntimeException: Failed to start quarkus at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:288) ... 15 more Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:400) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:398) at io.quarkus.deployment.steps.HibernateValidatorProcessor$build-642046765.deploy_0(HibernateValidatorProcessor$build-642046765.zig:4092) at io.quarkus.deployment.steps.HibernateValidatorProcessor$build-642046765.deploy(HibernateValidatorProcessor$build-642046765.zig:40) at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:202) ... 15 more Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter 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 io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406) at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363) ... 26 more ``` **To Reproduce** Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. [metrics-cnfe-filter.zip](https://github.com/quarkusio/quarkus/files/5311294/metrics-cnfe-filter.zip) Steps to reproduce the behavior: 1. Download the attached reproducer 2. mvnw quarkus:dev 3. Look into the console, quarkus does not start, and the exception is printed. **Environment (please complete the following information):** - Output of `uname -a` or `ver`: MSYS_NT-10.0 NANB7NLNVP2 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys - Quarkus version or git rev: 1.8.1.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\\Users\\mnp\\.m2\\wrapper\\dists\\apache-maven-3.6.3-bin\\1iopthnavndlasol9gbrbg6bf2\\apache-maven-3.6.3 Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: C:\\eclipse\\tools\\zulu11.39.15-ca-jdk11.0.7-win_x64 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
51efcd48a78837efddca696e3f37d420ba136fa7
c85ea20679c7f51c6f999cf2df5a43ae3795bd3b
https://github.com/quarkusio/quarkus/compare/51efcd48a78837efddca696e3f37d420ba136fa7...c85ea20679c7f51c6f999cf2df5a43ae3795bd3b
diff --git a/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java b/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java index 5e6efce6602..d1e8ccb539a 100644 --- a/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java +++ b/extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java @@ -47,6 +47,7 @@ import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.processor.BeanInfo; import io.quarkus.arc.processor.BuiltinScope; +import io.quarkus.arc.processor.DotNames; import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.Capability; import io.quarkus.deployment.Feature; @@ -307,6 +308,11 @@ private static void contributeBuiltinConstraints(Set<String> builtinConstraints, private static void contributeClass(Set<DotName> classNamesCollector, IndexView indexView, DotName className) { classNamesCollector.add(className); + + if (DotNames.OBJECT.equals(className)) { + return; + } + for (ClassInfo subclass : indexView.getAllKnownSubclasses(className)) { if (Modifier.isAbstract(subclass.flags())) { // we can avoid adding the abstract classes here: either they are parent classes
['extensions/hibernate-validator/deployment/src/main/java/io/quarkus/hibernate/validator/deployment/HibernateValidatorProcessor.java']
{'.java': 1}
1
1
0
0
1
11,466,757
2,240,394
298,389
3,168
128
26
6
1
5,585
357
1,419
86
2
1
2020-10-09T10:34: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,922
quarkusio/quarkus/12838/12837
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12837
https://github.com/quarkusio/quarkus/pull/12838
https://github.com/quarkusio/quarkus/pull/12838
1
fixes
Memory leak via MojoLogger.logSupplier
`MojoLogger.logSupplier` is a static field holding a reference to the following chain of refs: `BuildMojo` -> `BuildMojo.repoSession` -> `DefaultRepositorySystemSession.cache` When building Camel Quarkus with [mvnd](https://github.com/mvndaemon/mvnd), this prevents the cache (900+ MB on the heap) from being garbage collected after the build. A PR follows.
a04e76e53cb1e418e8a1756eb68fe353777b84ae
fe375237067a69ef8eb2315d93e7cb7a725f1441
https://github.com/quarkusio/quarkus/compare/a04e76e53cb1e418e8a1756eb68fe353777b84ae...fe375237067a69ef8eb2315d93e7cb7a725f1441
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java index fade91e4779..34d4afebd31 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java @@ -9,6 +9,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -120,4 +121,11 @@ protected void doExecute() throws MojoExecutionException { } } } + + @Override + public void setLog(Log log) { + super.setLog(log); + MojoLogger.delegate = log; + } + } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/GenerateConfigMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/GenerateConfigMojo.java index 20a22c8e99c..95ea468a7ca 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/GenerateConfigMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/GenerateConfigMojo.java @@ -12,6 +12,7 @@ import org.apache.maven.model.Resource; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -86,10 +87,6 @@ public class GenerateConfigMojo extends AbstractMojo { @Parameter(defaultValue = "${file}") private String file; - public GenerateConfigMojo() { - MojoLogger.logSupplier = this::getLog; - } - @Override public void execute() throws MojoExecutionException { @@ -152,4 +149,10 @@ public void execute() throws MojoExecutionException { throw new MojoExecutionException("Failed to generate config file", e); } } + + @Override + public void setLog(Log log) { + super.setLog(log); + MojoLogger.delegate = log; + } } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/MojoLogger.java b/devtools/maven/src/main/java/io/quarkus/maven/MojoLogger.java index a903de27547..dd03ff05971 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/MojoLogger.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/MojoLogger.java @@ -3,7 +3,6 @@ import java.text.MessageFormat; import java.util.Collections; import java.util.Map; -import java.util.function.Supplier; import org.apache.maven.plugin.logging.Log; import org.apache.maven.shared.utils.logging.MessageBuilder; @@ -17,7 +16,7 @@ public class MojoLogger implements LoggerProvider { static final Object[] NO_PARAMS = new Object[0]; - public static volatile Supplier<Log> logSupplier; + public static volatile Log delegate; @Override public Logger getLogger(final String name) { @@ -25,9 +24,8 @@ public Logger getLogger(final String name) { @Override protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) { - final Supplier<Log> logSupplier = MojoLogger.logSupplier; - if (logSupplier != null) { - Log log = logSupplier.get(); + final Log log = delegate; + if (log != null) { String text; if (parameters == null || parameters.length == 0) { text = String.valueOf(message); @@ -47,9 +45,8 @@ protected void doLog(final Level level, final String loggerClassName, final Obje @Override protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) { - final Supplier<Log> logSupplier = MojoLogger.logSupplier; - if (logSupplier != null) { - Log log = logSupplier.get(); + final Log log = delegate; + if (log != null) { String text; if (parameters == null) { try { @@ -73,10 +70,9 @@ protected void doLogf(final Level level, final String loggerClassName, final Str @Override public boolean isEnabled(final Level level) { - final Supplier<Log> logSupplier = MojoLogger.logSupplier; - if (logSupplier == null) + final Log log = delegate; + if (log == null) return false; - Log log = logSupplier.get(); switch (level) { case FATAL: case ERROR: diff --git a/devtools/maven/src/main/java/io/quarkus/maven/NativeImageMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/NativeImageMojo.java index cab6e5c7bc7..1cf0e37c589 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/NativeImageMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/NativeImageMojo.java @@ -12,6 +12,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -176,10 +177,6 @@ public class NativeImageMojo extends AbstractMojo { @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true) private List<RemoteRepository> repos; - public NativeImageMojo() { - MojoLogger.logSupplier = this::getLog; - } - @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -415,4 +412,10 @@ private Map<String, String> createCustomConfig() { } + @Override + public void setLog(Log log) { + super.setLog(log); + MojoLogger.delegate = log; + } + } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java index 37833fafa9f..bf6d0ed94b8 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java @@ -6,6 +6,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -77,10 +78,6 @@ public abstract class QuarkusBootstrapMojo extends AbstractMojo { private AppArtifactKey projectId; private boolean clearUberJarProp; - protected QuarkusBootstrapMojo() { - MojoLogger.logSupplier = this::getLog; - } - @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!beforeExecute()) { @@ -96,6 +93,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + @Override + public void setLog(Log log) { + super.setLog(log); + MojoLogger.delegate = log; + } + protected void clearUberJarProp() { this.clearUberJarProp = true; }
['devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java', 'devtools/maven/src/main/java/io/quarkus/maven/GenerateConfigMojo.java', 'devtools/maven/src/main/java/io/quarkus/maven/NativeImageMojo.java', 'devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java', 'devtools/maven/src/main/java/io/quarkus/maven/MojoLogger.java']
{'.java': 5}
5
5
0
0
5
11,595,846
2,267,066
301,821
3,218
1,817
370
59
5
367
44
91
7
1
0
2020-10-20T20:44:45
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,923
quarkusio/quarkus/12821/12804
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12804
https://github.com/quarkusio/quarkus/pull/12821
https://github.com/quarkusio/quarkus/pull/12821
1
fix
Cannot use multiple persistence units in same transaction
**Describe the bug** Given two Java packages configured in two separate persistence units, it is not possible to query entities in both of them within the same transaction. The query for the second persistence unit will always fail, while the first one works (i.e. no matter which PU is queried first, the other will fail). Querying the PUs outside of a transaction succeeds, though. **Expected behavior** It should be possible to query two different persistence units within the same transaction. **Actual behavior** The second query always fails with `java.lang.IllegalArgumentException: Could not locate ordinal parameter [1], expecting one of []` **To Reproduce** [panache-multipe-persistence-units.zip](https://github.com/quarkusio/quarkus/files/5403827/panache-multipe-persistence-units.zip) Steps to reproduce the behavior: 1. unzip above archive (code is based on hibernate-orm-panache-quickstart) 2. invoke `mvn test` 3. see test class fail in `org.acme.hibernate.orm.panache.MultiPersistenceUnitTest.testBothQueriesInTx()`, while tests doing the same outside of a transaction succeed **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Darwin C02Z74E4LVDQ 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64 - Output of `java -version`: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode) - GraalVM version (if different from Java): - Quarkus version or git rev: 1.8.3-Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3
26bf3d7804414ce134192111aa551231ac4e6adc
2007bafdeb29b7ac24437d5d3516aa5a2385f733
https://github.com/quarkusio/quarkus/compare/26bf3d7804414ce134192111aa551231ac4e6adc...2007bafdeb29b7ac24437d5d3516aa5a2385f733
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceResourceInjectionUnitsTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceResourceInjectionUnitsTest.java index 89a767295fb..543ad6b995e 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceResourceInjectionUnitsTest.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceResourceInjectionUnitsTest.java @@ -58,4 +58,12 @@ public void testUserInInventoryEntityManager() { assertThatThrownBy(() -> inventoryEntityManager.persist(user)).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Unknown entity"); } + + @Test + @Transactional + public void testAccessBothPersistenceUnits() { + testUser(); + testPlane(); + } + } diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/entitymanager/TransactionScopedEntityManager.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/entitymanager/TransactionScopedEntityManager.java index 46652e3f4c2..f91ce93e5fd 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/entitymanager/TransactionScopedEntityManager.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/entitymanager/TransactionScopedEntityManager.java @@ -30,51 +30,55 @@ public class TransactionScopedEntityManager implements EntityManager { protected static final String TRANSACTION_IS_NOT_ACTIVE = "Transaction is not active, consider adding @Transactional to your method to automatically activate one."; + private final TransactionManager transactionManager; - private final TransactionSynchronizationRegistry tsr; - private final EntityManagerFactory emf; + private final TransactionSynchronizationRegistry transactionSynchronizationRegistry; + private final EntityManagerFactory entityManagerFactory; private final String unitName; - private static final Object transactionKey = new Object(); - private final Instance<RequestScopedEntityManagerHolder> requestScopedEms; + private final String entityManagerKey; + private final Instance<RequestScopedEntityManagerHolder> requestScopedEntityManagers; public TransactionScopedEntityManager(TransactionManager transactionManager, - TransactionSynchronizationRegistry tsr, - EntityManagerFactory emf, - String unitName, Instance<RequestScopedEntityManagerHolder> requestScopedEms) { + TransactionSynchronizationRegistry transactionSynchronizationRegistry, + EntityManagerFactory entityManagerFactory, + String unitName, + Instance<RequestScopedEntityManagerHolder> requestScopedEntityManagers) { this.transactionManager = transactionManager; - this.tsr = tsr; - this.emf = emf; + this.transactionSynchronizationRegistry = transactionSynchronizationRegistry; + this.entityManagerFactory = entityManagerFactory; this.unitName = unitName; - this.requestScopedEms = requestScopedEms; + this.entityManagerKey = this.getClass().getSimpleName() + "-" + unitName; + this.requestScopedEntityManagers = requestScopedEntityManagers; } EntityManagerResult getEntityManager() { if (isInTransaction()) { - EntityManager em = (EntityManager) tsr.getResource(transactionKey); - if (em != null) { - return new EntityManagerResult(em, false, true); + EntityManager entityManager = (EntityManager) transactionSynchronizationRegistry.getResource(entityManagerKey); + if (entityManager != null) { + return new EntityManagerResult(entityManager, false, true); } - EntityManager newEm = emf.createEntityManager(); - newEm.joinTransaction(); - tsr.putResource(transactionKey, newEm); - tsr.registerInterposedSynchronization(new Synchronization() { + EntityManager newEntityManager = entityManagerFactory.createEntityManager(); + newEntityManager.joinTransaction(); + transactionSynchronizationRegistry.putResource(entityManagerKey, newEntityManager); + transactionSynchronizationRegistry.registerInterposedSynchronization(new Synchronization() { @Override public void beforeCompletion() { - newEm.flush(); + newEntityManager.flush(); } @Override public void afterCompletion(int i) { - newEm.close(); + newEntityManager.close(); } }); - return new EntityManagerResult(newEm, false, true); + return new EntityManagerResult(newEntityManager, false, true); } else { //this will throw an exception if the request scope is not active //this is expected as either the request scope or an active transaction //is required to properly managed the EM lifecycle - RequestScopedEntityManagerHolder requestScopedEms = this.requestScopedEms.get(); - return new EntityManagerResult(requestScopedEms.getOrCreateEntityManager(unitName, emf), false, false); + RequestScopedEntityManagerHolder requestScopedEntityManagers = this.requestScopedEntityManagers.get(); + return new EntityManagerResult(requestScopedEntityManagers.getOrCreateEntityManager(unitName, entityManagerFactory), + false, false); } } @@ -109,7 +113,7 @@ public void persist(Object entity) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.persist(entity); + emr.entityManager.persist(entity); } } @@ -120,7 +124,7 @@ public <T> T merge(T entity) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - return emr.em.merge(entity); + return emr.entityManager.merge(entity); } } @@ -131,7 +135,7 @@ public void remove(Object entity) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.remove(entity); + emr.entityManager.remove(entity); } } @@ -139,7 +143,7 @@ public void remove(Object entity) { public <T> T find(Class<T> entityClass, Object primaryKey) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.find(entityClass, primaryKey); + return emr.entityManager.find(entityClass, primaryKey); } } @@ -147,7 +151,7 @@ public <T> T find(Class<T> entityClass, Object primaryKey) { public <T> T find(Class<T> entityClass, Object primaryKey, Map<String, Object> properties) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.find(entityClass, primaryKey, properties); + return emr.entityManager.find(entityClass, primaryKey, properties); } } @@ -155,7 +159,7 @@ public <T> T find(Class<T> entityClass, Object primaryKey, Map<String, Object> p public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.find(entityClass, primaryKey, lockMode); + return emr.entityManager.find(entityClass, primaryKey, lockMode); } } @@ -163,7 +167,7 @@ public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String, Object> properties) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.find(entityClass, primaryKey, lockMode, properties); + return emr.entityManager.find(entityClass, primaryKey, lockMode, properties); } } @@ -171,7 +175,7 @@ public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode public <T> T getReference(Class<T> entityClass, Object primaryKey) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getReference(entityClass, primaryKey); + return emr.entityManager.getReference(entityClass, primaryKey); } } @@ -182,21 +186,21 @@ public void flush() { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.flush(); + emr.entityManager.flush(); } } @Override public void setFlushMode(FlushModeType flushMode) { try (EntityManagerResult emr = getEntityManager()) { - emr.em.setFlushMode(flushMode); + emr.entityManager.setFlushMode(flushMode); } } @Override public FlushModeType getFlushMode() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getFlushMode(); + return emr.entityManager.getFlushMode(); } } @@ -207,7 +211,7 @@ public void lock(Object entity, LockModeType lockMode) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.lock(entity, lockMode); + emr.entityManager.lock(entity, lockMode); } } @@ -218,7 +222,7 @@ public void lock(Object entity, LockModeType lockMode, Map<String, Object> prope if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.lock(entity, lockMode, properties); + emr.entityManager.lock(entity, lockMode, properties); } } @@ -229,7 +233,7 @@ public void refresh(Object entity) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.refresh(entity); + emr.entityManager.refresh(entity); } } @@ -240,7 +244,7 @@ public void refresh(Object entity, Map<String, Object> properties) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.refresh(entity, properties); + emr.entityManager.refresh(entity, properties); } } @@ -251,7 +255,7 @@ public void refresh(Object entity, LockModeType lockMode) { if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.refresh(entity, lockMode); + emr.entityManager.refresh(entity, lockMode); } } @@ -262,28 +266,28 @@ public void refresh(Object entity, LockModeType lockMode, Map<String, Object> pr if (!emr.allowModification) { throw new TransactionRequiredException(TRANSACTION_IS_NOT_ACTIVE); } - emr.em.refresh(entity, lockMode, properties); + emr.entityManager.refresh(entity, lockMode, properties); } } @Override public void clear() { try (EntityManagerResult emr = getEntityManager()) { - emr.em.clear(); + emr.entityManager.clear(); } } @Override public void detach(Object entity) { try (EntityManagerResult emr = getEntityManager()) { - emr.em.detach(entity); + emr.entityManager.detach(entity); } } @Override public boolean contains(Object entity) { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.contains(entity); + return emr.entityManager.contains(entity); } } @@ -291,21 +295,21 @@ public boolean contains(Object entity) { public LockModeType getLockMode(Object entity) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getLockMode(entity); + return emr.entityManager.getLockMode(entity); } } @Override public void setProperty(String propertyName, Object value) { try (EntityManagerResult emr = getEntityManager()) { - emr.em.setProperty(propertyName, value); + emr.entityManager.setProperty(propertyName, value); } } @Override public Map<String, Object> getProperties() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getProperties(); + return emr.entityManager.getProperties(); } } @@ -314,7 +318,7 @@ public Query createQuery(String qlString) { checkBlocking(); //TODO: this needs some thought for how it works outside a tx try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createQuery(qlString); + return emr.entityManager.createQuery(qlString); } } @@ -322,7 +326,7 @@ public Query createQuery(String qlString) { public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createQuery(criteriaQuery); + return emr.entityManager.createQuery(criteriaQuery); } } @@ -330,7 +334,7 @@ public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery) { public Query createQuery(CriteriaUpdate updateQuery) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createQuery(updateQuery); + return emr.entityManager.createQuery(updateQuery); } } @@ -338,7 +342,7 @@ public Query createQuery(CriteriaUpdate updateQuery) { public Query createQuery(CriteriaDelete deleteQuery) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createQuery(deleteQuery); + return emr.entityManager.createQuery(deleteQuery); } } @@ -346,7 +350,7 @@ public Query createQuery(CriteriaDelete deleteQuery) { public <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createQuery(qlString, resultClass); + return emr.entityManager.createQuery(qlString, resultClass); } } @@ -354,7 +358,7 @@ public <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass) { public Query createNamedQuery(String name) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNamedQuery(name); + return emr.entityManager.createNamedQuery(name); } } @@ -362,7 +366,7 @@ public Query createNamedQuery(String name) { public <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNamedQuery(name, resultClass); + return emr.entityManager.createNamedQuery(name, resultClass); } } @@ -370,7 +374,7 @@ public <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass) { public Query createNativeQuery(String sqlString) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNativeQuery(sqlString); + return emr.entityManager.createNativeQuery(sqlString); } } @@ -378,7 +382,7 @@ public Query createNativeQuery(String sqlString) { public Query createNativeQuery(String sqlString, Class resultClass) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNativeQuery(sqlString, resultClass); + return emr.entityManager.createNativeQuery(sqlString, resultClass); } } @@ -386,7 +390,7 @@ public Query createNativeQuery(String sqlString, Class resultClass) { public Query createNativeQuery(String sqlString, String resultSetMapping) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNativeQuery(sqlString, resultSetMapping); + return emr.entityManager.createNativeQuery(sqlString, resultSetMapping); } } @@ -394,7 +398,7 @@ public Query createNativeQuery(String sqlString, String resultSetMapping) { public StoredProcedureQuery createNamedStoredProcedureQuery(String name) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createNamedStoredProcedureQuery(name); + return emr.entityManager.createNamedStoredProcedureQuery(name); } } @@ -402,7 +406,7 @@ public StoredProcedureQuery createNamedStoredProcedureQuery(String name) { public StoredProcedureQuery createStoredProcedureQuery(String procedureName) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createStoredProcedureQuery(procedureName); + return emr.entityManager.createStoredProcedureQuery(procedureName); } } @@ -410,7 +414,7 @@ public StoredProcedureQuery createStoredProcedureQuery(String procedureName) { public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createStoredProcedureQuery(procedureName, resultClasses); + return emr.entityManager.createStoredProcedureQuery(procedureName, resultClasses); } } @@ -418,21 +422,21 @@ public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Cla public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createStoredProcedureQuery(procedureName, resultSetMappings); + return emr.entityManager.createStoredProcedureQuery(procedureName, resultSetMappings); } } @Override public void joinTransaction() { try (EntityManagerResult emr = getEntityManager()) { - emr.em.joinTransaction(); + emr.entityManager.joinTransaction(); } } @Override public boolean isJoinedToTransaction() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.isJoinedToTransaction(); + return emr.entityManager.isJoinedToTransaction(); } } @@ -440,14 +444,14 @@ public boolean isJoinedToTransaction() { public <T> T unwrap(Class<T> cls) { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.unwrap(cls); + return emr.entityManager.unwrap(cls); } } @Override public Object getDelegate() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getDelegate(); + return emr.entityManager.getDelegate(); } } @@ -469,7 +473,7 @@ public EntityTransaction getTransaction() { @Override public EntityManagerFactory getEntityManagerFactory() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getEntityManagerFactory(); + return emr.entityManager.getEntityManagerFactory(); } } @@ -477,53 +481,53 @@ public EntityManagerFactory getEntityManagerFactory() { public CriteriaBuilder getCriteriaBuilder() { checkBlocking(); try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getCriteriaBuilder(); + return emr.entityManager.getCriteriaBuilder(); } } @Override public Metamodel getMetamodel() { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getMetamodel(); + return emr.entityManager.getMetamodel(); } } @Override public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createEntityGraph(rootType); + return emr.entityManager.createEntityGraph(rootType); } } @Override public EntityGraph<?> createEntityGraph(String graphName) { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.createEntityGraph(graphName); + return emr.entityManager.createEntityGraph(graphName); } } @Override public EntityGraph<?> getEntityGraph(String graphName) { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getEntityGraph(graphName); + return emr.entityManager.getEntityGraph(graphName); } } @Override public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) { try (EntityManagerResult emr = getEntityManager()) { - return emr.em.getEntityGraphs(entityClass); + return emr.entityManager.getEntityGraphs(entityClass); } } static class EntityManagerResult implements AutoCloseable { - final EntityManager em; + final EntityManager entityManager; final boolean closeOnEnd; final boolean allowModification; - EntityManagerResult(EntityManager em, boolean closeOnEnd, boolean allowModification) { - this.em = em; + EntityManagerResult(EntityManager entityManager, boolean closeOnEnd, boolean allowModification) { + this.entityManager = entityManager; this.closeOnEnd = closeOnEnd; this.allowModification = allowModification; } @@ -531,7 +535,7 @@ static class EntityManagerResult implements AutoCloseable { @Override public void close() { if (closeOnEnd) { - em.close(); + entityManager.close(); } } }
['extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceResourceInjectionUnitsTest.java', 'extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/entitymanager/TransactionScopedEntityManager.java']
{'.java': 2}
2
2
0
0
2
11,595,362
2,267,021
301,845
3,220
9,258
1,609
152
1
1,622
207
423
22
1
0
2020-10-20T10:41:28
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,924
quarkusio/quarkus/12805/12723
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12723
https://github.com/quarkusio/quarkus/pull/12805
https://github.com/quarkusio/quarkus/pull/12805
1
close
Quitting quarkus:dev with Ctrl+C doesn't allow @PreDestroy hooks to finish
**Describe the bug** When exiting `quarkus:dev` mode with Ctrl+C, `@PreDestroy` hooks rarely have enough time to complete. **Expected behavior** Other CDI containers I've used trap the Ctrl+C signal to finish completion of all `@PreDestroy` hooks before exiting the container. **Actual behavior** `@PreDestroy` appear to be called, but it looks like thread pools are terminated before they're done executing. I only rarely see the results of print statements I have in my `@PreDestroy` hooks. **To Reproduce** Set up a `@PreDestroy` hook with some print statements. Exit from an `mvn compile quarkus:dev` session, and see that the print statements infrequently execute.
6f4e3b39f7adeafd6ec89e81973c3351ec1ccfad
8e3d19aa9572642b407b0e86190b633775394676
https://github.com/quarkusio/quarkus/compare/6f4e3b39f7adeafd6ec89e81973c3351ec1ccfad...8e3d19aa9572642b407b0e86190b633775394676
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 7722c8e98de..ce34e442a0a 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -903,6 +903,11 @@ public void run() throws Exception { @Override public void run() { process.destroy(); + try { + process.waitFor(); + } catch (InterruptedException ignored) { + getLog().warn("Unable to properly wait for dev-mode end", ignored); + } } }, "Development Mode Shutdown Hook")); }
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
11,579,738
2,264,008
301,428
3,220
248
34
5
1
684
99
157
12
0
0
2020-10-19T18:39:32
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,925
quarkusio/quarkus/12787/12786
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12786
https://github.com/quarkusio/quarkus/pull/12787
https://github.com/quarkusio/quarkus/pull/12787
1
fixes
devtools/cli generates quarkus-cli-999-SNAPSHOT.jar.original as directory and BuildMojo code can't handle it
devtools/cli generates quarkus-cli-999-SNAPSHOT.jar.original as directory and BuildMojo code can't handle it To reproduce just call twice `mvn package -pl devtools/cli/ -DskipTests`. Important piece is that `clean` is not part of the command. mvn command ends with: ``` [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (default) on project quarkus-cli: Failed to build quarkus application: java.nio.file.DirectoryNotEmptyException: /Users/rsvoboda/tmp/ quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original -> [Help 1] ``` Details from `mvn -X ...` execution ``` Caused by: java.nio.file.DirectoryNotEmptyException: /Users/rsvoboda/tmp/quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original at sun.nio.fs.UnixFileSystemProvider.implDelete (UnixFileSystemProvider.java:247) at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists (AbstractFileSystemProvider.java:110) at java.nio.file.Files.deleteIfExists (Files.java:1180) at io.quarkus.maven.BuildMojo.doExecute (BuildMojo.java:100) at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:90) ... ``` Code in BuildMojo expects file, not directory like in devtools/cli case ``` $ find devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Clean.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/core devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/core/QuarkusVersion.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/core/BaseSubCommand.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/core/BuildsystemCommand.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/core/ExecuteUtil.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Remove.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Create$TargetLanguage.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/List$ExtensionFormat.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/QuarkusCli.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Add.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Dev.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/List.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Build.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/QuarkusCli$ExecutionStrategy.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Create.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/io/quarkus/cli/Create$TargetBuildTool.class devtools/cli/target/quarkus-cli-999-SNAPSHOT.jar.original/application.properties ``` Probably related to https://github.com/quarkusio/quarkus/pull/12725 changes, CI job started to fail 4 days ago
80ee6f04370c45115fcd421624807bebe011933c
e97aed758054066145c33e65f75da519300cf769
https://github.com/quarkusio/quarkus/compare/80ee6f04370c45115fcd421624807bebe011933c...e97aed758054066145c33e65f75da519300cf769
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java index 7dac05ea045..fade91e4779 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java @@ -20,6 +20,7 @@ import io.quarkus.bootstrap.app.AugmentAction; import io.quarkus.bootstrap.app.AugmentResult; import io.quarkus.bootstrap.app.CuratedApplication; +import io.quarkus.bootstrap.util.IoUtils; /** * Build the application. @@ -97,7 +98,7 @@ protected void doExecute() throws MojoExecutionException { final Path standardJar = curatedApplication.getAppModel().getAppArtifact().getPaths().getSinglePath(); if (Files.exists(standardJar)) { try { - Files.deleteIfExists(result.getJar().getOriginalArtifact()); + IoUtils.recursiveDelete(result.getJar().getOriginalArtifact()); Files.move(standardJar, result.getJar().getOriginalArtifact()); } catch (IOException e) { throw new UncheckedIOException(e);
['devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java']
{'.java': 1}
1
1
0
0
1
11,575,998
2,263,330
301,359
3,220
233
37
3
1
3,372
138
895
51
1
3
2020-10-19T10:41: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,926
quarkusio/quarkus/12781/12716
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12716
https://github.com/quarkusio/quarkus/pull/12781
https://github.com/quarkusio/quarkus/pull/12781
1
fixes
MongoHealthCheck doesn't work with ReactiveMongoClient
**Describe the bug** When app uses purely `ReactiveMongoClient` client then `MongoHealthCheck` doesn't recognize such client and readiness check returns UP even no connection to mongo. **Expected behavior** Should return DOWN **Actual behavior** calling /health/ready returns UP **To Reproduce** Inject in your app just `ReactiveMongoClient` and make sure that mongo is down. and call `/health/ready` Quarkus 1.8.3.Final https://github.com/quarkusio/quarkus/blob/1.8.3.Final/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java shows that only `MongoClient` is checked and no `ReactiveMongoClient` **Environment (please complete the following information):** - Output of `java -version`: 11 - Quarkus version 1.8.3.Final
6f4e3b39f7adeafd6ec89e81973c3351ec1ccfad
b5d954543b8a3c6f65acfede0bdec88639d151f4
https://github.com/quarkusio/quarkus/compare/6f4e3b39f7adeafd6ec89e81973c3351ec1ccfad...b5d954543b8a3c6f65acfede0bdec88639d151f4
diff --git a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java index 41aa9159daa..62ab766b8b4 100644 --- a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java +++ b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java @@ -2,10 +2,10 @@ import java.util.HashMap; import java.util.Map; -import java.util.Set; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Any; import javax.enterprise.inject.spi.Bean; import org.bson.Document; @@ -17,40 +17,69 @@ import com.mongodb.client.MongoClient; import io.quarkus.arc.Arc; +import io.quarkus.arc.InstanceHandle; +import io.quarkus.mongodb.MongoClientName; +import io.quarkus.mongodb.reactive.ReactiveMongoClient; @Readiness @ApplicationScoped public class MongoHealthCheck implements HealthCheck { - private static final String DEFAULT_CLIENT = "__default__"; + + public static final String CLIENT_DEFAULT = "<default>"; + public static final String CLIENT_DEFAULT_REACTIVE = "<default-reactive>"; + private Map<String, MongoClient> clients = new HashMap<>(); + private Map<String, ReactiveMongoClient> reactiveClients = new HashMap<>(); @PostConstruct protected void init() { - Set<Bean<?>> beans = Arc.container().beanManager().getBeans(MongoClient.class); - for (Bean<?> bean : beans) { - if (bean.getName() == null) { - // this is the default mongo client: retrieve it by type - MongoClient defaultClient = Arc.container().instance(MongoClient.class).get(); - clients.put(DEFAULT_CLIENT, defaultClient); - } else { - MongoClient client = (MongoClient) Arc.container().instance(bean.getName()).get(); - clients.put(bean.getName(), client); + for (InstanceHandle<MongoClient> handle : Arc.container().select(MongoClient.class, Any.Literal.INSTANCE).handles()) { + String clientName = getMongoClientName(handle.getBean()); + clients.put(clientName == null ? CLIENT_DEFAULT : clientName, handle.get()); + } + // reactive clients + for (InstanceHandle<ReactiveMongoClient> handle : Arc.container() + .select(ReactiveMongoClient.class, Any.Literal.INSTANCE).handles()) { + String clientName = getMongoClientName(handle.getBean()); + reactiveClients.put(clientName == null ? CLIENT_DEFAULT_REACTIVE : clientName, handle.get()); + } + } + + /** + * Get mongoClient name if defined. + * + * @param bean + * @return mongoClient name or null if not defined + * @see MongoClientName + */ + private String getMongoClientName(Bean bean) { + for (Object qualifier : bean.getQualifiers()) { + if (qualifier instanceof MongoClientName) { + return ((MongoClientName) qualifier).value(); } } + return null; } @Override public HealthCheckResponse call() { HealthCheckResponseBuilder builder = HealthCheckResponse.named("MongoDB connection health check").up(); + Document command = new Document("ping", 1); for (Map.Entry<String, MongoClient> client : clients.entrySet()) { - boolean isDefault = DEFAULT_CLIENT.equals(client.getKey()); - MongoClient mongoClient = client.getValue(); try { - Document document = mongoClient.getDatabase("admin").runCommand(new Document("ping", 1)); - String mongoClientName = isDefault ? "default" : client.getKey(); - builder.up().withData(mongoClientName, document.toJson()); + Document document = client.getValue().getDatabase("admin").runCommand(command); + builder.up().withData(client.getKey(), document.toJson()); + } catch (Exception e) { + return builder.down().withData("reason", "client [" + client.getKey() + "]: " + e.getMessage()).build(); + } + } + for (Map.Entry<String, ReactiveMongoClient> client : reactiveClients.entrySet()) { + try { + Document document = client.getValue().getDatabase("admin").runCommand(command).await().indefinitely(); + builder.up().withData(client.getKey(), document.toJson()); } catch (Exception e) { - return builder.down().withData("reason", e.getMessage()).build(); + return builder.down().withData("reason", "reactive client [" + client.getKey() + "]: " + e.getMessage()) + .build(); } } return builder.build(); diff --git a/integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/BookResourceTest.java b/integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/BookResourceTest.java index ba0497b7656..2b506aee0eb 100644 --- a/integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/BookResourceTest.java +++ b/integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/BookResourceTest.java @@ -2,6 +2,7 @@ import static io.restassured.RestAssured.get; import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; import java.util.Arrays; @@ -20,6 +21,7 @@ import io.quarkus.it.mongodb.discriminator.Car; import io.quarkus.it.mongodb.discriminator.Moto; import io.quarkus.it.mongodb.pojo.Pojo; +import io.quarkus.mongodb.health.MongoHealthCheck; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; @@ -123,6 +125,8 @@ public void testReactiveClients() { public void health() throws Exception { RestAssured.when().get("/health/ready").then() .body("status", is("UP"), + "checks.data", containsInAnyOrder(hasKey(MongoHealthCheck.CLIENT_DEFAULT)), + "checks.data", containsInAnyOrder(hasKey(MongoHealthCheck.CLIENT_DEFAULT_REACTIVE)), "checks.status", containsInAnyOrder("UP"), "checks.name", containsInAnyOrder("MongoDB connection health check")); }
['integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/BookResourceTest.java', 'extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/health/MongoHealthCheck.java']
{'.java': 2}
2
2
0
0
2
11,579,738
2,264,008
301,428
3,220
3,535
681
63
1
795
82
197
21
1
0
2020-10-19T09:03:35
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,927
quarkusio/quarkus/12710/12703
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12703
https://github.com/quarkusio/quarkus/pull/12710
https://github.com/quarkusio/quarkus/pull/12710
1
fixes
At create from command line are have wrong version dependency
If create quarkus project from command line like indicated on site for gradle: ```mvn io.quarkus:quarkus-maven-plugin:1.8.3.Final:create \\ -DprojectGroupId=com.test \\ -DprojectArtifactId=create-test-gradle \\ -DprojectVersion=my-version \\ -DclassName="org.my.group.MyResource" \\ -Dextensions="resteasy-jsonb" \\ -DbuildTool=gradle ``` for maven: ```mvn io.quarkus:quarkus-maven-plugin:1.8.3.Final:create \\ -DprojectGroupId=ru.aleksey \\ -DprojectArtifactId=create-test-maven \\ -DprojectVersion=my-version \\ -DclassName="org.my.group.MyResource" ``` we getting created by `gradle.properties` and `pom.xml` files with 1.9.0.CR1 version instead 1.8.3.Final
ecf8d24cd11b1921d0cf91f7b7ca762f7ac843c4
e24ce3c50bfc90ebb69b95c14d04fa1a5fb80afa
https://github.com/quarkusio/quarkus/compare/ecf8d24cd11b1921d0cf91f7b7ca762f7ac843c4...e24ce3c50bfc90ebb69b95c14d04fa1a5fb80afa
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java b/devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java index 495267a6a7d..e1d207ef041 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java @@ -85,7 +85,7 @@ static QuarkusPlatformDescriptor resolvePlatformDescriptor(final String bomGroup DefaultArtifactVersion pluginVersion = new DefaultArtifactVersion(baseVersion); int majorVer = pluginVersion.getMajorVersion(); int minorVer = pluginVersion.getMinorVersion(); - version = "[" + majorVer + "." + minorVer + "-alpha, " + majorVer + "." + (minorVer + 1) + ")"; + version = "[" + majorVer + "." + minorVer + "-alpha, " + majorVer + "." + (minorVer + 1) + "-alpha)"; } }
['devtools/maven/src/main/java/io/quarkus/maven/CreateUtils.java']
{'.java': 1}
1
1
0
0
1
11,520,258
2,251,538
299,856
3,194
231
67
2
1
707
54
211
18
0
2
2020-10-14T12:20: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,928
quarkusio/quarkus/12699/12694
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12694
https://github.com/quarkusio/quarkus/pull/12699
https://github.com/quarkusio/quarkus/pull/12699
1
resolves
native-image specific micrometer-mp-metrics test failure in io.quarkus.micrometer.runtime.registry.json.JsonExporter, java.lang.NumberFormatException
**Describe the bug** Micrometer test fails to parse output when run with native-image. It works just fine in JVM mode. **Expected behavior** The test passes for JVM mode and native-image alike. **Actual behavior** ### JVM mode :heavy_check_mark: ``` ./mvnw verify -f integration-tests/pom.xml --fail-at-end -pl 'micrometer-mp-metrics' -Dno-format [INFO] Results: [INFO] [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0 [INFO] ``` ### Native-image :x: See the whole log: https://gist.github.com/Karm/85b8a1cd46b3c0764ef2ef3f64adf439 Snippet: ``` 2020-10-13 22:02:33,434 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-7) HTTP Request to /metrics failed, error id: 55c54249-01ef-4623-8d73-a43ebb9ca0df-1: java.lang.NumberFormatException: Character N is neither a decimal digit number, decimal point, nor "e" notation exponential mark. at java.math.BigDecimal.<init>(BigDecimal.java:518) at java.math.BigDecimal.<init>(BigDecimal.java:401) at java.math.BigDecimal.<init>(BigDecimal.java:834) at java.math.BigDecimal.valueOf(BigDecimal.java:1304) at org.glassfish.json.JsonNumberImpl.getJsonNumber(JsonNumberImpl.java:46) at org.glassfish.json.JsonProviderImpl.createValue(JsonProviderImpl.java:244) at io.quarkus.micrometer.runtime.registry.json.JsonExporter.lambda$exportGauges$2(JsonExporter.java:91) at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:178) at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at io.quarkus.micrometer.runtime.registry.json.JsonExporter.exportGauges(JsonExporter.java:90) at io.quarkus.micrometer.runtime.registry.json.JsonExporter.exportEverything(JsonExporter.java:78) at io.quarkus.micrometer.runtime.registry.json.JsonMeterRegistry.scrape(JsonMeterRegistry.java:115) at io.quarkus.micrometer.runtime.export.handlers.JsonHandler.handle(JsonHandler.java:34) at io.quarkus.micrometer.runtime.export.handlers.JsonHandler.handle(JsonHandler.java:15) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:306) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:284) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.micrometer.runtime.binder.vertx.VertxMeterFilter.handle(VertxMeterFilter.java:28) at io.quarkus.micrometer.runtime.binder.vertx.VertxMeterFilter.handle(VertxMeterFilter.java:14) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:54) at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:36) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$9.handle(VertxHttpRecorder.java:396) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$9.handle(VertxHttpRecorder.java:393) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:137) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:126) at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:50) at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:32) at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:136) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43) at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:229) at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:163) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:101) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.vertx.core.http.impl.Http1xUpgradeToH2CHandler.channelRead(Http1xUpgradeToH2CHandler.java:109) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61) at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:834) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193) { "details": "Error id 55c54249-01ef-4623-8d73-a43ebb9ca0df-1", "stack": "" } ``` **To Reproduce** ``` git clone https://github.com/quarkusio/quarkus.git cd quarkus/ git fetch --tags git checkout 1.9.0.CR1 ./mvnw verify -f integration-tests/pom.xml --fail-at-end -pl 'micrometer-mp-metrics' -Dno-format -Ddocker -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=registry.redhat.io/quarkus/mandrel-20-rhel8:20.1-12 ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Centos 8, 4.18.0-193.19.1.el8_2.x86_64 - Output of `java -version`: OpenJDK 11.0.8+10 - GraalVM version (if different from Java): Mandrel 20.1.0.2.Final, builder image registry.redhat.io/quarkus/mandrel-20-rhel8:20.1-12 - Quarkus version or git rev: 1.9.0.CR1
151c461fd263065006075aef1b17b06408c677ee
e7c9d64c5591fb4d4e7c40b515a26c521d761382
https://github.com/quarkusio/quarkus/compare/151c461fd263065006075aef1b17b06408c677ee...e7c9d64c5591fb4d4e7c40b515a26c521d761382
diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/JVMInfoBinder.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/JVMInfoBinder.java index 4d193494bcc..5db62a0c9f6 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/JVMInfoBinder.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/JVMInfoBinder.java @@ -1,6 +1,6 @@ package io.quarkus.micrometer.runtime.binder; -import io.micrometer.core.instrument.Gauge; +import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.binder.MeterBinder; @@ -8,12 +8,12 @@ public class JVMInfoBinder implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { - Gauge.builder("jvm_info", () -> 1L) + Counter.builder("jvm_info") .description("JVM version info") .tags("version", System.getProperty("java.runtime.version", "unknown"), "vendor", System.getProperty("java.vm.vendor", "unknown"), "runtime", System.getProperty("java.runtime.name", "unknown")) - .strongReference(true) - .register(registry); + .register(registry) + .increment(); } }
['extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/JVMInfoBinder.java']
{'.java': 1}
1
1
0
0
1
11,515,307
2,250,449
299,717
3,192
319
63
8
1
10,025
360
2,303
133
2
3
2020-10-14T00:56: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,929
quarkusio/quarkus/12675/12667
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12667
https://github.com/quarkusio/quarkus/pull/12675
https://github.com/quarkusio/quarkus/pull/12675
1
resolves
Reduce error logging in vertx proxy address forwarding
I see a error log when an ipv6 address of the condensed format `2001:db8:85a3:8d3:1319:8a2e:370::` is used. (Basically ends in a ::) > Failed to parse a port from forwarded-type headers https://github.com/quarkusio/quarkus/blob/9d5f82255ee8a994bcffd16c0cbcc24edd6ab226/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java#L204 Would a change like https://github.com/bobbyphilip/quarkus/commit/98a52d8b1135470b5ee7bf582fa7316707453a6e, be acceptable to reduce the needless error log?
8070d9fe39324bc3c90e8b7af82bb71bb5443014
ebff17e281ec66b894029aada595cc7304c90d2a
https://github.com/quarkusio/quarkus/compare/8070d9fe39324bc3c90e8b7af82bb71bb5443014...ebff17e281ec66b894029aada595cc7304c90d2a
diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java index 995c72ca97c..66441f2e08f 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java @@ -202,12 +202,14 @@ private SocketAddress parseFor(String forToParse, int defaultPort) { } private int parsePort(String portToParse, int defaultPort) { - try { - return Integer.parseInt(portToParse); - } catch (NumberFormatException ignored) { - log.error("Failed to parse a port from \\"forwarded\\"-type headers."); - return defaultPort; + if (portToParse != null && portToParse.length() > 0) { + try { + return Integer.parseInt(portToParse); + } catch (NumberFormatException ignored) { + log.error("Failed to parse a port from \\"forwarded\\"-type headers."); + } } + return defaultPort; } private String appendPrefixToUri(String prefix, String uri) {
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java']
{'.java': 1}
1
1
0
0
1
11,496,429
2,246,571
299,230
3,186
556
105
12
1
532
44
175
6
2
0
2020-10-13T09:24:57
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,930
quarkusio/quarkus/12657/12528
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12528
https://github.com/quarkusio/quarkus/pull/12657
https://github.com/quarkusio/quarkus/pull/12657
1
fixes
NullPointerException in UnixPath.normalizeAndCheck()
Zulip thread: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/mvn.20quarkus.3Adev.20NPE ``` [INFO] --- quarkus-maven-plugin:1.7.0.Final:dev (default-cli) @ optaplanner-quarkus-school-timetabling-quickstart --- Listening for transport dt_socket at address: 5005 Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:150) at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:135) at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:85) at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:144) ... 1 more Caused by: java.lang.RuntimeException: java.lang.NullPointerException at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:374) at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:51) at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132) ... 3 more Caused by: java.lang.NullPointerException at java.base/sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:75) at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69) at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279) at java.base/java.nio.file.Path.of(Path.java:147) at java.base/java.nio.file.Paths.get(Paths.java:69) at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.checkForFileChange(RuntimeUpdatesProcessor.java:396) at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:346) ... 5 more ``` To reproduce ``` git clone [email protected]:kiegroup/optaplanner.git cd optaplanner git checkout 7.43.1.Final cd optaplanner-quickstarts/quarkus-school-timetabling-quickstart // Adjust pom.xml to use quarkus 1.8.1.Final mvn clean compile quarkus:dev ```
b34b54203c98ff3dca87461fd0571320d699d721
22f583f5c8f83fcdfd9bd84ed3b1ff2c671ccf1c
https://github.com/quarkusio/quarkus/compare/b34b54203c98ff3dca87461fd0571320d699d721...22f583f5c8f83fcdfd9bd84ed3b1ff2c671ccf1c
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 81aaf0341b2..7722c8e98de 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -520,7 +520,7 @@ private String getSourceEncoding() { return null; } - private void addProject(DevModeContext devModeContext, LocalProject localProject, boolean root) { + private void addProject(DevModeContext devModeContext, LocalProject localProject, boolean root) throws Exception { String projectDirectory = null; Set<String> sourcePaths = null; @@ -557,6 +557,11 @@ private void addProject(DevModeContext devModeContext, LocalProject localProject resourcePath = resourcesSourcesDir.toAbsolutePath().toString(); } + if (classesPath == null && (!sourcePaths.isEmpty() || resourcePath != null)) { + throw new MojoExecutionException("Hot reloadable dependency " + localProject.getAppArtifact() + + " has not been compiled yet (the classes directory " + classesDir + " does not exist)"); + } + Path targetDir = Paths.get(project.getBuild().getDirectory()); DevModeContext.ModuleInfo moduleInfo = new DevModeContext.ModuleInfo(localProject.getKey(),
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
11,489,965
2,245,278
299,062
3,183
542
108
7
1
2,240
103
583
39
1
2
2020-10-12T12:22: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,898
quarkusio/quarkus/13300/13276
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13276
https://github.com/quarkusio/quarkus/pull/13300
https://github.com/quarkusio/quarkus/pull/13300
1
fixes
Invalid warning on quarkus.vault.secret-config-kv-path."prefix" property
**Describe the bug** Using property `secret-config-kv-path."prefix"` works as expected, but prints an invalid warning at startup: ``` WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.vault.secret-config-kv-path.singer" was provided; it will be ignored; verify that the dependency extension for this configuration is set or you did not make a typo ``` **Expected behavior** There should be no warning **To Reproduce** Execute IT `VaultMultiPathConfigITCase` in the core project **Additional context** I am not sure if this is something that is specific to the vault configuration, because I don't see the same behavior on `ConfiguredBeanTest` that is using `ConfiguredBeanTest` with property `public Map<String, List<String>> stringListMap` with values: ``` # And list form quarkus.rt.all-values.string-list-map.key1=value1,value2,value3 quarkus.rt.all-values.string-list-map.key2=value4,value5 quarkus.rt.all-values.string-list-map.key3=value6 ```
8b8bba78a9e205d1244d185ba58c6bae17af4c43
30f62a133944ae8cf28a93dc02f4366aec875b0f
https://github.com/quarkusio/quarkus/compare/8b8bba78a9e205d1244d185ba58c6bae17af4c43...30f62a133944ae8cf28a93dc02f4366aec875b0f
diff --git a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSource.java b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSource.java index b79e35062b2..b82e6010fa9 100644 --- a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSource.java +++ b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSource.java @@ -16,6 +16,7 @@ import static java.lang.Integer.parseInt; import static java.util.Collections.emptyMap; import static java.util.Optional.empty; +import static java.util.regex.Pattern.compile; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; @@ -52,12 +53,13 @@ public class VaultConfigSource implements ConfigSource { private static final Logger log = Logger.getLogger(VaultConfigSource.class); - private static final String PROPERTY_PREFIX = "quarkus.vault."; - public static final Pattern CREDENTIALS_PATTERN = Pattern.compile("^quarkus\\\\.vault\\\\.credentials-provider\\\\.([^.]+)\\\\."); - public static final Pattern TRANSIT_KEY_PATTERN = Pattern.compile("^quarkus\\\\.vault\\\\.transit.key\\\\.([^.]+)\\\\."); - public static final Pattern SECRET_CONFIG_KV_PATH_PATTERN = Pattern - .compile("^quarkus\\\\.vault\\\\.secret-config-kv-path\\\\.(?:([^.]+)|(?:\\"([^\\"]+)\\"))$"); - public static final Pattern EXPANSION_PATTERN = Pattern.compile("\\\\$\\\\{([^}]+)\\\\}"); + static final String PROPERTY_PREFIX = "quarkus.vault."; + public static final Pattern CREDENTIALS_PATTERN = compile("^quarkus\\\\.vault\\\\.credentials-provider\\\\.([^.]+)\\\\."); + public static final Pattern TRANSIT_KEY_PATTERN = compile("^quarkus\\\\.vault\\\\.transit.key\\\\.([^.]+)\\\\."); + public static final String SECRET_CONFIG_KV_PREFIX_PATHS = "secret-config-kv-path"; + public static final Pattern SECRET_CONFIG_KV_PREFIX_PATH_PATTERN = compile( + "^quarkus\\\\.vault\\\\." + SECRET_CONFIG_KV_PREFIX_PATHS + "\\\\.(?:([^.]+)|(?:\\"([^\\"]+)\\"))$"); + public static final Pattern EXPANSION_PATTERN = compile("\\\\$\\\\{([^}]+)\\\\}"); private AtomicReference<VaultCacheEntry<Map<String, String>>> cache = new AtomicReference<>(null); private AtomicReference<VaultRuntimeConfig> serverConfig = new AtomicReference<>(null); @@ -117,13 +119,10 @@ private Map<String, String> getSecretConfig() { try { // default kv paths - if (serverConfig.secretConfigKvPath.isPresent()) { - fetchSecrets(serverConfig.secretConfigKvPath.get(), null, properties); - } + serverConfig.secretConfigKvPath.ifPresent(strings -> fetchSecrets(strings, null, properties)); // prefixed kv paths - serverConfig.secretConfigKvPrefixPath.entrySet() - .forEach(entry -> fetchSecrets(entry.getValue(), entry.getKey(), properties)); + serverConfig.secretConfigKvPathPrefix.forEach((key, value) -> fetchSecrets(value.paths, key, properties)); log.debug("loaded " + properties.size() + " properties from vault"); } catch (RuntimeException e) { @@ -252,7 +251,7 @@ private VaultRuntimeConfig loadRuntimeConfig() { serverConfig.credentialsProvider = createCredentialProviderConfigParser().getConfig(); serverConfig.transit.key = createTransitKeyConfigParser().getConfig(); - serverConfig.secretConfigKvPrefixPath = getSecretConfigKvPrefixPaths(); + serverConfig.secretConfigKvPathPrefix = getSecretConfigKvPrefixPaths(); return serverConfig; } @@ -362,7 +361,7 @@ protected String getBaseProperty(String propertyName, String defaultValue) { .orElse(defaultValue); } - private Map<String, List<String>> getSecretConfigKvPrefixPaths() { + private Map<String, VaultRuntimeConfig.KvPathConfig> getSecretConfigKvPrefixPaths() { return getConfigSourceStream() .flatMap(configSource -> configSource.getPropertyNames().stream()) @@ -370,7 +369,8 @@ private Map<String, List<String>> getSecretConfigKvPrefixPaths() { .filter(Objects::nonNull) .distinct() .map(this::createNameSecretConfigKvPrefixPathPair) - .collect(toMap(SimpleEntry::getKey, SimpleEntry::getValue)); + .collect(toMap(SimpleEntry::getKey, + kvStore -> new VaultRuntimeConfig.KvPathConfig(kvStore.getValue()))); } private Stream<ConfigSource> getConfigSourceStream() { @@ -394,12 +394,12 @@ private SimpleEntry<String, List<String>> createNameSecretConfigKvPrefixPathPair } private String getSecretConfigKvPrefixPathName(String propertyName) { - Matcher matcher = SECRET_CONFIG_KV_PATH_PATTERN.matcher(propertyName); + Matcher matcher = SECRET_CONFIG_KV_PREFIX_PATH_PATTERN.matcher(propertyName); return matcher.matches() ? (matcher.group(1) != null ? matcher.group(1) : matcher.group(2)) : null; } private List<String> getSecretConfigKvPrefixPath(String prefixName) { - return getOptionalListProperty("secret-config-kv-path." + prefixName).get(); + return getOptionalListProperty(SECRET_CONFIG_KV_PREFIX_PATHS + "." + prefixName).get(); } } diff --git a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java index 130d42b2527..f3d6015c2a1 100644 --- a/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java +++ b/extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java @@ -8,11 +8,14 @@ import java.net.URL; import java.time.Duration; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; +import io.quarkus.runtime.annotations.ConfigDocMapKey; import io.quarkus.runtime.annotations.ConfigDocSection; +import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; @@ -23,7 +26,6 @@ public class VaultRuntimeConfig { public static final String DEFAULT_KUBERNETES_JWT_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token"; public static final String DEFAULT_KV_SECRET_ENGINE_MOUNT_PATH = "secret"; - public static final String KV_SECRET_ENGINE_VERSION_V1 = "1"; public static final String KV_SECRET_ENGINE_VERSION_V2 = "2"; public static final String DEFAULT_RENEW_GRACE_PERIOD = "1H"; public static final String DEFAULT_SECRET_CONFIG_CACHE_PERIOD = "10M"; @@ -35,9 +37,9 @@ public class VaultRuntimeConfig { /** * Vault server url. - * <p> + * * Example: https://localhost:8200 - * <p> + * * See also the documentation for the `kv-secret-engine-mount-path` property for some insights on how * the full Vault url gets built. * @@ -55,7 +57,7 @@ public class VaultRuntimeConfig { /** * Renew grace period duration. - * <p> + * * This value if used to extend a lease before it expires its ttl, or recreate a new lease before the current * lease reaches its max_ttl. * By default Vault leaseDuration is equal to 7 days (ie: 168h or 604800s). @@ -75,7 +77,7 @@ public class VaultRuntimeConfig { /** * Vault config source cache period. - * <p> + * * Properties fetched from vault as MP config will be kept in a cache, and will not be fetched from vault * again until the expiration of that period. * This property is ignored if `secret-config-kv-path` is not set. @@ -89,20 +91,20 @@ public class VaultRuntimeConfig { /** * List of comma separated vault paths in kv store, * where all properties will be available as MP config properties **as-is**, with no prefix. - * <p> + * * For instance, if vault contains property `foo`, it will be made available to the * quarkus application as `@ConfigProperty(name = "foo") String foo;` - * <p> + * * If 2 paths contain the same property, the last path will win. - * <p> + * * For instance if - * <p> + * * * `secret/base-config` contains `foo=bar` and * * `secret/myapp/config` contains `foo=myappbar`, then - * <p> + * * `@ConfigProperty(name = "foo") String foo` will have value `myappbar` * with application properties `quarkus.vault.secret-config-kv-path=base-config,myapp/config` - * <p> + * * See also the documentation for the `kv-secret-engine-mount-path` property for some insights on how * the full Vault url gets built. * @@ -112,32 +114,17 @@ public class VaultRuntimeConfig { @ConfigItem public Optional<List<String>> secretConfigKvPath; - // @formatter:off /** - * List of comma separated vault paths in kv store, - * where all properties will be available as **prefixed** MP config properties. - * <p> - * For instance if the application properties contains - * `quarkus.vault.secret-config-kv-path.myprefix=config`, and - * vault path `secret/config` contains `foo=bar`, then `myprefix.foo` - * will be available in the MP config. - * <p> - * If the same property is available in 2 different paths for the same prefix, the last one - * will win. - * <p> - * See also the documentation for the `kv-secret-engine-mount-path` property for some insights on how - * the full Vault url gets built. - * - * @asciidoclet + * KV store paths configuration. */ - // @formatter:on - @ConfigItem(name = "secret-config-kv-path.\\"prefix\\"") - public Map<String, List<String>> secretConfigKvPrefixPath; + @ConfigItem(name = "secret-config-kv-path") + @ConfigDocMapKey("prefix") + public Map<String, KvPathConfig> secretConfigKvPathPrefix; /** * Used to hide confidential infos, for logging in particular. * Possible values are: - * <p> + * * * low: display all secrets. * * medium: display only usernames and lease ids (ie: passwords and tokens are masked). * * high: hide lease ids and dynamic credentials username. @@ -149,7 +136,7 @@ public class VaultRuntimeConfig { /** * Kv secret engine version. - * <p> + * * see https://www.vaultproject.io/docs/secrets/kv/index.html * * @asciidoclet @@ -159,24 +146,24 @@ public class VaultRuntimeConfig { /** * KV secret engine path. - * <p> + * * This value is used when building the url path in the KV secret engine programmatic access * (i.e. `VaultKVSecretEngine`) and the vault config source (i.e. fetching configuration properties from Vault). - * <p> + * * For a v2 KV secret engine (default - see `kv-secret-engine-version property`) * the full url is built from the expression `<url>/v1/</kv-secret-engine-mount-path>/data/...`. - * <p> + * * With property `quarkus.vault.url=https://localhost:8200`, the following call * `vaultKVSecretEngine.readSecret("foo/bar")` would lead eventually to a `GET` on Vault with the following * url: `https://localhost:8200/v1/secret/data/foo/bar`. - * <p> + * * With a KV secret engine v1, the url changes to: `<url>/v1/</kv-secret-engine-mount-path>/...`. - * <p> + * * The same logic is applied to the Vault config source. With `quarkus.vault.secret-config-kv-path=config/myapp` * The secret properties would be fetched from Vault using a `GET` on * `https://localhost:8200/v1/secret/data/config/myapp` for a KV secret engine v2 (or * `https://localhost:8200/v1/secret/config/myapp` for a KV secret engine v1). - * <p> + * * see https://www.vaultproject.io/docs/secrets/kv/index.html * * @asciidoclet @@ -205,10 +192,10 @@ public class VaultRuntimeConfig { /** * List of named credentials providers, such as: `quarkus.vault.credentials-provider.foo.kv-path=mypath` - * <p> + * * This defines a credentials provider `foo` returning key `password` from vault path `mypath`. * Once defined, this provider can be used in credentials consumers, such as the Agroal connection pool. - * <p> + * * Example: `quarkus.datasource.credentials-provider=foo` * * @asciidoclet @@ -271,4 +258,43 @@ public String toString() { '}'; } + @ConfigGroup + public static class KvPathConfig { + // @formatter:off + /** + * List of comma separated vault paths in kv store, + * where all properties will be available as **prefixed** MP config properties. + * + * For instance if the application properties contains + * `quarkus.vault.secret-config-kv-path.myprefix=config`, and + * vault path `secret/config` contains `foo=bar`, then `myprefix.foo` + * will be available in the MP config. + * + * If the same property is available in 2 different paths for the same prefix, the last one + * will win. + * + * See also the documentation for the `quarkus.vault.kv-secret-engine-mount-path` property for some insights on how + * the full Vault url gets built. + * + * @asciidoclet + */ + // @formatter:on + @ConfigItem(name = ConfigItem.PARENT) + List<String> paths; + + public KvPathConfig(List<String> paths) { + this.paths = paths; + } + + public KvPathConfig() { + paths = Collections.emptyList(); + } + + @Override + public String toString() { + return "SecretConfigKvPathConfig{" + + "paths=" + paths + + '}'; + } + } } diff --git a/extensions/vault/runtime/src/test/java/io/quarkus/vault/runtime/config/VaultConfigSourceTest.java b/extensions/vault/runtime/src/test/java/io/quarkus/vault/runtime/config/VaultConfigSourceTest.java index f4e8f5a2675..47ff8245c44 100644 --- a/extensions/vault/runtime/src/test/java/io/quarkus/vault/runtime/config/VaultConfigSourceTest.java +++ b/extensions/vault/runtime/src/test/java/io/quarkus/vault/runtime/config/VaultConfigSourceTest.java @@ -1,6 +1,8 @@ package io.quarkus.vault.runtime.config; -import static io.quarkus.vault.runtime.config.VaultConfigSource.SECRET_CONFIG_KV_PATH_PATTERN; +import static io.quarkus.vault.runtime.config.VaultConfigSource.PROPERTY_PREFIX; +import static io.quarkus.vault.runtime.config.VaultConfigSource.SECRET_CONFIG_KV_PREFIX_PATHS; +import static io.quarkus.vault.runtime.config.VaultConfigSource.SECRET_CONFIG_KV_PREFIX_PATH_PATTERN; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -10,16 +12,18 @@ public class VaultConfigSourceTest { + private static final String PROPERTY = PROPERTY_PREFIX + SECRET_CONFIG_KV_PREFIX_PATHS; + @Test void secretConfigKvPathPattern() { Matcher matcher; - matcher = SECRET_CONFIG_KV_PATH_PATTERN.matcher("quarkus.vault.secret-config-kv-path.hello"); + matcher = SECRET_CONFIG_KV_PREFIX_PATH_PATTERN.matcher(PROPERTY + ".hello"); assertTrue(matcher.matches()); assertEquals("hello", matcher.group(1)); - matcher = SECRET_CONFIG_KV_PATH_PATTERN.matcher("quarkus.vault.secret-config-kv-path.\\"mp.jwt.verify\\""); + matcher = SECRET_CONFIG_KV_PREFIX_PATH_PATTERN.matcher(PROPERTY + ".\\"mp.jwt.verify\\""); assertTrue(matcher.matches()); assertEquals("mp.jwt.verify", matcher.group(2)); }
['extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultRuntimeConfig.java', 'extensions/vault/runtime/src/test/java/io/quarkus/vault/runtime/config/VaultConfigSourceTest.java', 'extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/config/VaultConfigSource.java']
{'.java': 3}
3
3
0
0
3
13,484,449
2,633,890
350,998
3,705
5,773
1,330
138
2
991
111
235
21
0
2
2020-11-15T12:57:29
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,933
quarkusio/quarkus/12609/11524
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/11524
https://github.com/quarkusio/quarkus/pull/12609
https://github.com/quarkusio/quarkus/pull/12609
1
fixes
NullPointerException reading mongodb bson date (native image)
Hi, only native image of my application cause a NullPointerException parsing mongodb document with date field. The error occours both with quarkus 1.6.0.final and 1.7.0.final. Here the full staktrace: ``` 2020-08-21 15:12:12,711 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002020: Unhandled asynchronous exception, sending back 500: org.jboss.resteasy.spi.ApplicationException: java.lang.NullPointerException at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:180) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130) at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:638) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:504) at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:454) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:456) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:417) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:163) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:245) at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:132) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:37) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:94) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at java.lang.Thread.run(Thread.java:834) at org.jboss.threads.JBossThread.run(JBossThread.java:479) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193) Caused by: java.lang.NullPointerException at java.text.SimpleDateFormat.matchZoneString(SimpleDateFormat.java:1695) at java.text.SimpleDateFormat.subParseZoneString(SimpleDateFormat.java:1763) at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:2169) at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1541) at org.bson.json.JsonReader.visitISODateTimeConstructor(JsonReader.java:836) at org.bson.json.JsonReader.readBsonType(JsonReader.java:225) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:85) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:42) at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:104) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:87) at org.bson.BsonDocument.parse(BsonDocument.java:63) at io.quarkus.mongodb.panache.runtime.MongoOperations.executeUpdate(MongoOperations.java:619) at io.quarkus.mongodb.panache.runtime.MongoOperations.update(MongoOperations.java:614) at it.cineca.model.elaborato.HeartBeat.update(HeartBeat.java) at it.cineca.manager.HeartBeatManager.aggiornaBattito(HeartBeatManager.java:64) at it.cineca.manager.HeartBeatManager_ClientProxy.aggiornaBattito(HeartBeatManager_ClientProxy.zig:216) at it.cineca.web.BeatController.aggiornaBattito(BeatController.java:38) at java.lang.reflect.Method.invoke(Method.java:566) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) ... 29 more ``` I'm compiling native image using maven's quarkus standard configuration with these Resource Configuration File: ``` { "bundles": [ {"name":"sun.util.resources.TimeZoneNames"} ], "resources": [ { "pattern": "org/joda/time/tz/data/.*/.*$" }, { "pattern": "org/joda/time/tz/data/.*$" } ] } ``` Thank you Nicola
e4686a7d748572c9c05d5bafecb690db263f80ff
4758e9392effedff377ca56db849dfae9f6bab4e
https://github.com/quarkusio/quarkus/compare/e4686a7d748572c9c05d5bafecb690db263f80ff...4758e9392effedff377ca56db849dfae9f6bab4e
diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/binder/CommonQueryBinder.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/binder/CommonQueryBinder.java index b620616af2b..00c602ccea7 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/binder/CommonQueryBinder.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/binder/CommonQueryBinder.java @@ -1,15 +1,14 @@ package io.quarkus.mongodb.panache.binder; -import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.Collection; import java.util.Date; -import java.util.TimeZone; import java.util.UUID; import java.util.stream.Collectors; @@ -39,22 +38,20 @@ static String escape(Object value) { return value.toString(); } if (value instanceof Date) { - SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_DATE_PATTERN); - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - Date dateValue = (Date) value; - return "ISODate('" + dateFormat.format(dateValue) + "')"; + ZonedDateTime zonedDateTime = ((Date) value).toInstant().atZone(ZoneOffset.UTC); + return "{\\"$date\\": \\"" + ISO_DATE_FORMATTER.format(zonedDateTime) + "\\"} "; } if (value instanceof LocalDate) { - LocalDate dateValue = (LocalDate) value; - return "ISODate('" + DateTimeFormatter.ISO_LOCAL_DATE.format(dateValue) + "')"; + ZonedDateTime zonedDateTime = ((LocalDate) value).atStartOfDay(ZoneOffset.UTC); + return "{\\"$date\\": \\"" + ISO_DATE_FORMATTER.format(zonedDateTime) + "\\"} "; } if (value instanceof LocalDateTime) { - LocalDateTime dateValue = (LocalDateTime) value; - return "ISODate('" + ISO_DATE_FORMATTER.format(dateValue.atZone(ZoneOffset.UTC)) + "')"; + ZonedDateTime zonedDateTime = ((LocalDateTime) value).atZone(ZoneOffset.UTC); + return "{\\"$date\\": \\"" + ISO_DATE_FORMATTER.format(zonedDateTime) + "\\"} "; } if (value instanceof Instant) { - Instant dateValue = (Instant) value; - return "ISODate('" + ISO_DATE_FORMATTER.format(dateValue.atZone(ZoneOffset.UTC)) + "')"; + ZonedDateTime zonedDateTime = ((Instant) value).atZone(ZoneOffset.UTC); + return "{\\"$date\\": \\"" + ISO_DATE_FORMATTER.format(zonedDateTime) + "\\"} "; } if (value instanceof UUID) { UUID uuidValue = (UUID) value; diff --git a/extensions/panache/mongodb-panache/runtime/src/test/java/io/quarkus/mongodb/panache/runtime/MongoOperationsTest.java b/extensions/panache/mongodb-panache/runtime/src/test/java/io/quarkus/mongodb/panache/runtime/MongoOperationsTest.java index 2016dc4e05c..38e01aad928 100644 --- a/extensions/panache/mongodb-panache/runtime/src/test/java/io/quarkus/mongodb/panache/runtime/MongoOperationsTest.java +++ b/extensions/panache/mongodb-panache/runtime/src/test/java/io/quarkus/mongodb/panache/runtime/MongoOperationsTest.java @@ -50,18 +50,18 @@ public void testBindShorthandFilter() { assertEquals("{'field':true}", query); query = operations.bindFilter(Object.class, "field", new Object[] { LocalDate.of(2019, 3, 4) }); - assertEquals("{'field':ISODate('2019-03-04')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T00:00:00.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1).toInstant(ZoneOffset.UTC) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field", new Object[] { toDate(LocalDateTime.of(2019, 3, 4, 1, 1, 1)) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field", new Object[] { UUID.fromString("7f000101-7370-1f68-8173-70afa71b0000") }); @@ -90,19 +90,19 @@ public void testBindNativeFilterByIndex() { query = operations.bindFilter(Object.class, "{'field': ?1}", new Object[] { LocalDate.of(2019, 3, 4) }); - assertEquals("{'field': ISODate('2019-03-04')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T00:00:00.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': ?1}", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1) }); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': ?1}", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1).toInstant(ZoneOffset.UTC) }); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': ?1}", new Object[] { toDate(LocalDateTime.of(2019, 3, 4, 1, 1, 1)) }); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': ?1}", new Object[] { UUID.fromString("7f000101-7370-1f68-8173-70afa71b0000") }); @@ -148,19 +148,19 @@ public void testBindNativeFilterByName() { query = operations.bindFilter(Object.class, "{'field': :field}", Parameters.with("field", LocalDate.of(2019, 3, 4)).map()); - assertEquals("{'field': ISODate('2019-03-04')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T00:00:00.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': :field}", Parameters.with("field", LocalDateTime.of(2019, 3, 4, 1, 1, 1)).map()); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': :field}", Parameters.with("field", LocalDateTime.of(2019, 3, 4, 1, 1, 1).toInstant(ZoneOffset.UTC)).map()); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': :field}", Parameters.with("field", toDate(LocalDateTime.of(2019, 3, 4, 1, 1, 1))).map()); - assertEquals("{'field': ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field': {\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "{'field': :field}", Parameters.with("field", UUID.fromString("7f000101-7370-1f68-8173-70afa71b0000")).map()); @@ -209,18 +209,18 @@ public void testBindEnhancedFilterByIndex() { assertEquals("{'value':'a value'}", query); query = operations.bindFilter(Object.class, "field = ?1", new Object[] { LocalDate.of(2019, 3, 4) }); - assertEquals("{'field':ISODate('2019-03-04')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T00:00:00.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = ?1", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = ?1", new Object[] { LocalDateTime.of(2019, 3, 4, 1, 1, 1).toInstant(ZoneOffset.UTC) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = ?1", new Object[] { toDate(LocalDateTime.of(2019, 3, 4, 1, 1, 1)) }); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = ?1", new Object[] { UUID.fromString("7f000101-7370-1f68-8173-70afa71b0000") }); @@ -287,19 +287,19 @@ public void testBindEnhancedFilterByName() { query = operations.bindFilter(Object.class, "field = :field", Parameters.with("field", LocalDate.of(2019, 3, 4)).map()); - assertEquals("{'field':ISODate('2019-03-04')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T00:00:00.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = :field", Parameters.with("field", LocalDateTime.of(2019, 3, 4, 1, 1, 1)).map()); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = :field", Parameters.with("field", LocalDateTime.of(2019, 3, 4, 1, 1, 1).toInstant(ZoneOffset.UTC)).map()); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = :field", Parameters.with("field", toDate(LocalDateTime.of(2019, 3, 4, 1, 1, 1))).map()); - assertEquals("{'field':ISODate('2019-03-04T01:01:01.000Z')}", query); + assertEquals("{'field':{\\"$date\\": \\"2019-03-04T01:01:01.000Z\\"} }", query); query = operations.bindFilter(Object.class, "field = :field", Parameters.with("field", UUID.fromString("7f000101-7370-1f68-8173-70afa71b0000")).map());
['extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/binder/CommonQueryBinder.java', 'extensions/panache/mongodb-panache/runtime/src/test/java/io/quarkus/mongodb/panache/runtime/MongoOperationsTest.java']
{'.java': 2}
2
2
0
0
2
11,466,763
2,240,395
298,389
3,168
1,546
322
21
1
5,143
185
1,201
72
0
2
2020-10-08T18:37: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,934
quarkusio/quarkus/12580/12525
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12525
https://github.com/quarkusio/quarkus/pull/12580
https://github.com/quarkusio/quarkus/pull/12580
1
resolves
Quarkus REST Client extension is not enabling SSL native by default as documented
**Describe the bug** In the guide https://quarkus.io/guides/native-and-ssl there is a mention that quarkus-rest-client extension should automatically enable SSL in native but SSL doesn't work without explicit property `quarkus.ssl.native=true`/ **Expected behavior** SSL works by default as documented. **Actual behavior** SSL doesn't work without explicit property. **To Reproduce** https://github.com/xstefank/quarkus-rest-client-extension **Configuration** ```properties # Configuration file # key = value # uncomment to make SSL work in native #quarkus.ssl.native=true ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux Set-FI 5.8.9-200.fc32.x86_64 #1 SMP Mon Sep 14 18:28:45 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux - Output of `java -version`: openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03) OpenJDK 64-Bit Server VM GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03, mixed mode, sharing) - Quarkus version or git rev: 1.8.1.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/mstefank/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 1.8.0_265, vendor: AdoptOpenJDK, runtime: /opt/java/hotspot/jdk8u265-b01/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.8.9-200.fc32.x86_64", arch: "amd64", family: "unix" **Additional context** Maybe this can be related to the plain use of the RESTEasy JAX-RS client? However, I still think this should work.
56dd01ad4c9222b7a886bffe5693e9c448933350
c8c4423db674a0d23cf658f4c01165dccd6b30af
https://github.com/quarkusio/quarkus/compare/56dd01ad4c9222b7a886bffe5693e9c448933350...c8c4423db674a0d23cf658f4c01165dccd6b30af
diff --git a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java index 17e3f4ff952..db86b354fa5 100644 --- a/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java +++ b/extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java @@ -173,7 +173,6 @@ void processInterfaces( BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, BuildProducer<BeanRegistrarBuildItem> beanRegistrars, - BuildProducer<ExtensionSslNativeSupportBuildItem> extensionSslNativeSupport, BuildProducer<ServiceProviderBuildItem> serviceProvider, BuildProducer<RestClientBuildItem> restClient) { @@ -254,9 +253,11 @@ public void register(RegistrationContext registrationContext) { } } })); + } - // Indicates that this extension would like the SSL support to be enabled - extensionSslNativeSupport.produce(new ExtensionSslNativeSupportBuildItem(Feature.REST_CLIENT)); + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(Feature.REST_CLIENT); } // currently default methods on a rest-client interface
['extensions/rest-client/deployment/src/main/java/io/quarkus/restclient/deployment/RestClientProcessor.java']
{'.java': 1}
1
1
0
0
1
11,464,003
2,239,916
298,309
3,165
446
93
7
1
1,717
193
555
41
2
1
2020-10-07T12:37: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,935
quarkusio/quarkus/12567/12565
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12565
https://github.com/quarkusio/quarkus/pull/12567
https://github.com/quarkusio/quarkus/pull/12567
1
fixes
remote-dev is not taking into account HotDeploymentWatchedFileBuildItem
The paths configured with HotDeploymentWatchedFileBuildItem (including e.g. `application.properties`) aren't supported in remote-dev. Here's a quick hack to add support for picking up changes to the `application.properties`: ``` diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java index 630ffb6dc0..5b838a13db 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java @@ -131,6 +131,7 @@ public class IsolatedRemoteDevModeMain implements BiConsumer<CuratedApplication, copiedStaticResources.computeIfAbsent(moduleInfo, ss -> new HashSet<>()).add(s); } }); + processor.setWatchedFilePaths(Collections.singletonMap("application.properties", Boolean.TRUE)); ``` FYI @stuartwdouglas
026b1a1935e0088a3e00808d424f0615e9cc3ee7
b5aec9ca9c4d0008639297599a49dd66adb6fd28
https://github.com/quarkusio/quarkus/compare/026b1a1935e0088a3e00808d424f0615e9cc3ee7...b5aec9ca9c4d0008639297599a49dd66adb6fd28
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java index e227702fecd..73b555246a5 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java @@ -13,7 +13,7 @@ public class HotDeploymentConfigFileBuildStep { @BuildStep ServiceStartBuildItem setupConfigFileHotDeployment(List<HotDeploymentWatchedFileBuildItem> files) { // TODO: this should really be an output of the RuntimeRunner - RuntimeUpdatesProcessor processor = IsolatedDevModeMain.runtimeUpdatesProcessor; + RuntimeUpdatesProcessor processor = RuntimeUpdatesProcessor.INSTANCE; if (processor != null) { Map<String, Boolean> watchedFilePaths = files.stream() .collect(Collectors.toMap(HotDeploymentWatchedFileBuildItem::getLocation, diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java index 31215563d06..a25fb322bc8 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java @@ -58,7 +58,6 @@ public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<S private final List<HotReplacementSetup> hotReplacementSetups = new ArrayList<>(); private static volatile RunningQuarkusApplication runner; static volatile Throwable deploymentProblem; - static volatile RuntimeUpdatesProcessor runtimeUpdatesProcessor; private static volatile CuratedApplication curatedApplication; private static volatile AugmentAction augmentAction; private static volatile boolean restarting; @@ -95,8 +94,8 @@ public void accept(Integer integer) { System.in.read(); } System.out.println("Restarting..."); - runtimeUpdatesProcessor.checkForChangedClasses(); - restartApp(runtimeUpdatesProcessor.checkForFileChange()); + RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses(); + restartApp(RuntimeUpdatesProcessor.INSTANCE.checkForFileChange()); } catch (Exception e) { log.error("Failed to restart", e); } @@ -117,7 +116,7 @@ public void accept(Integer integer) { //we need to set this here, while we still have the correct TCCL //this is so the config is still valid, and we can read HTTP config from application.properties log.info("Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure"); - if (runtimeUpdatesProcessor != null) { + if (RuntimeUpdatesProcessor.INSTANCE != null) { Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader()); try { @@ -126,7 +125,7 @@ public void accept(Integer integer) { .loadClass(LoggingSetupRecorder.class.getName()); cl.getMethod("handleFailedStart").invoke(null); } - runtimeUpdatesProcessor.startupFailed(); + RuntimeUpdatesProcessor.INSTANCE.startupFailed(); } catch (Exception e) { close(); log.error("Failed to recover after failed start", e); @@ -253,7 +252,7 @@ public void close() { } finally { try { try { - runtimeUpdatesProcessor.close(); + RuntimeUpdatesProcessor.INSTANCE.close(); } catch (IOException e) { log.error("Failed to close compiler", e); } @@ -340,19 +339,20 @@ public boolean test(String s) { sourcePath -> module.addSourcePaths(singleton(sourcePath.toAbsolutePath().toString())))); } } - runtimeUpdatesProcessor = setupRuntimeCompilation(context, (Path) params.get(APP_ROOT), + RuntimeUpdatesProcessor.INSTANCE = setupRuntimeCompilation(context, (Path) params.get(APP_ROOT), (DevModeType) params.get(DevModeType.class.getName())); - if (runtimeUpdatesProcessor != null) { - runtimeUpdatesProcessor.checkForFileChange(); - runtimeUpdatesProcessor.checkForChangedClasses(); + if (RuntimeUpdatesProcessor.INSTANCE != null) { + RuntimeUpdatesProcessor.INSTANCE.checkForFileChange(); + RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses(); } firstStart(deploymentClassLoader, codeGens); // doStart(false, Collections.emptySet()); - if (deploymentProblem != null || runtimeUpdatesProcessor.getCompileProblem() != null) { + if (deploymentProblem != null || RuntimeUpdatesProcessor.INSTANCE.getCompileProblem() != null) { if (context.isAbortOnFailedStart()) { throw new RuntimeException( - deploymentProblem == null ? runtimeUpdatesProcessor.getCompileProblem() : deploymentProblem); + deploymentProblem == null ? RuntimeUpdatesProcessor.INSTANCE.getCompileProblem() + : deploymentProblem); } } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java index 630ffb6dc03..150fc33a6c5 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java @@ -56,7 +56,6 @@ public class IsolatedRemoteDevModeMain implements BiConsumer<CuratedApplication, private final List<HotReplacementSetup> hotReplacementSetups = new ArrayList<>(); static volatile Throwable deploymentProblem; - static volatile RuntimeUpdatesProcessor runtimeUpdatesProcessor; static volatile RemoteDevClient remoteDevClient; static volatile Closeable remoteDevClientSession; private static volatile CuratedApplication curatedApplication; @@ -150,7 +149,7 @@ void regenerateApplication(Set<String> ignore) { public void close() { try { try { - runtimeUpdatesProcessor.close(); + RuntimeUpdatesProcessor.INSTANCE.close(); } catch (IOException e) { log.error("Failed to close compiler", e); } @@ -190,11 +189,11 @@ public void accept(CuratedApplication o, Map<String, Object> o2) { } augmentAction = new AugmentActionImpl(curatedApplication); - runtimeUpdatesProcessor = setupRuntimeCompilation(context, appRoot); + RuntimeUpdatesProcessor.INSTANCE = setupRuntimeCompilation(context, appRoot); - if (runtimeUpdatesProcessor != null) { - runtimeUpdatesProcessor.checkForFileChange(); - runtimeUpdatesProcessor.checkForChangedClasses(); + if (RuntimeUpdatesProcessor.INSTANCE != null) { + RuntimeUpdatesProcessor.INSTANCE.checkForFileChange(); + RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses(); } JarResult result = generateApplication(); @@ -254,7 +253,7 @@ private RemoteDevClient.SyncResult runSync() { Set<String> removed = new HashSet<>(); Map<String, byte[]> changed = new HashMap<>(); try { - boolean scanResult = runtimeUpdatesProcessor.doScan(true); + boolean scanResult = RuntimeUpdatesProcessor.INSTANCE.doScan(true); if (!scanResult && !copiedStaticResources.isEmpty()) { scanResult = true; regenerateApplication(Collections.emptySet()); @@ -291,7 +290,7 @@ public Set<String> getRemovedFiles() { @Override public Throwable getProblem() { - return runtimeUpdatesProcessor.getDeploymentProblem(); + return RuntimeUpdatesProcessor.INSTANCE.getDeploymentProblem(); } }; diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java index ff9c291504e..35d68bca123 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java @@ -43,6 +43,7 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable private static final Logger log = Logger.getLogger(RuntimeUpdatesProcessor.class); private static final String CLASS_EXTENSION = ".class"; + static volatile RuntimeUpdatesProcessor INSTANCE; private final Path applicationRoot; private final DevModeContext context;
['core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/HotDeploymentConfigFileBuildStep.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedDevModeMain.java', 'core/deployment/src/main/java/io/quarkus/deployment/dev/IsolatedRemoteDevModeMain.java']
{'.java': 4}
4
4
0
0
4
11,461,895
2,239,534
298,254
3,165
3,221
461
42
4
1,052
60
240
15
0
1
2020-10-07T00:51: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,938
quarkusio/quarkus/12453/12435
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12435
https://github.com/quarkusio/quarkus/pull/12453
https://github.com/quarkusio/quarkus/pull/12453
1
resolves
quarkus-micrometer does not work with quarkus-kafka-streams
**Describe the bug** Micrometer extension does not work with quarks-kafka-streams extension. **Expected behavior** Micrometer extension works with Kafka streams **Actual behavior** `./gradlew quarkusDev` fails with a `java.lang.LinkageError`: ``` > Task :quarkusDev Caching disabled for task ':quarkusDev' because: Build cache is disabled Task ':quarkusDev' is not up-to-date because: Task has not declared any outputs despite executing actions. Starting process 'command '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java''. Working directory: /Users/mccaig/Downloads/reproducer/build/classes/java/main Command: /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java -Xdebug -Xrunjdwp:transport=dt_socket,address=0.0.0.0:5005,server=y,suspend=n -XX:TieredStopAtLevel=1 -Xverify:none -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus-internal.serialized-app-model.path=/Users/mccaig/Downloads/reproducer/build/tmp/quarkusDev/quarkus-app-model.dat -jar /Users/mccaig/Downloads/reproducer/build/code-with-quarkus-1.0.0-SNAPSHOT-dev.jar Successfully started process 'command '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java'' Listening for transport dt_socket at address: 5005 2020-09-30 16:30:12,629 INFO [org.jbo.threads] (main) JBoss Threads version 3.1.1.Final 2020-09-30 16:30:13,195 INFO [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure 2020-09-30 16:30:13,195 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: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$3.run(StartupActionImpl.java:134) at java.base/java.lang.Thread.run(Thread.java:834) 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:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at java.base/java.lang.Class.newInstance(Class.java:584) at io.quarkus.runtime.Quarkus.run(Quarkus.java:60) at io.quarkus.runtime.Quarkus.run(Quarkus.java:38) at io.quarkus.runtime.Quarkus.run(Quarkus.java:106) at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) ... 6 more Caused by: java.lang.RuntimeException: Failed to start quarkus at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:233) ... 15 more Caused by: java.lang.LinkageError: loader constraint violation: loader 'app' wants to load class io.quarkus.runtime.RuntimeValue. A different class with the same name was previously loaded by io.quarkus.bootstrap.classloading.QuarkusClassLoader @5bd03f44. (io.quarkus.runtime.RuntimeValue is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @5bd03f44, parent loader 'platform') at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at io.quarkus.resteasy.common.runtime.ResteasyInjectorFactoryRecorder.setup(ResteasyInjectorFactoryRecorder.java:27) at io.quarkus.deployment.steps.ResteasyCommonProcessor$setupResteasyInjection-1799175235.deploy_0(ResteasyCommonProcessor$setupResteasyInjection-1799175235.zig:124) at io.quarkus.deployment.steps.ResteasyCommonProcessor$setupResteasyInjection-1799175235.deploy(ResteasyCommonProcessor$setupResteasyInjection-1799175235.zig:40) at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:213) ... 15 more ``` **To Reproduce** Steps to reproduce the behavior: 1. Extract [reproducer.zip](https://github.com/quarkusio/quarkus/files/5308730/reproducer.zip) 2. Run `./gradlew quarkusDev` 3. Observe error **Environment (please complete the following information):** - Output of `uname -a` or `ver`: `Darwin mccaig-macOS 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64` - Output of `java -version`: ``` openjdk version "11.0.8" 2020-07-14 LTS OpenJDK Runtime Environment Zulu11.41+23-CA (build 11.0.8+10-LTS) OpenJDK 64-Bit Server VM Zulu11.41+23-CA (build 11.0.8+10-LTS, mixed mode) ``` - GraalVM version (if different from Java): N/A - Quarkus version or git rev: `1.8.1.Final` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): `Gradle 6.4.1`
109af54f7c3e91cd521848499673d59e428456c3
457995cd1267506523a56e0309f024e241b6b141
https://github.com/quarkusio/quarkus/compare/109af54f7c3e91cd521848499673d59e428456c3...457995cd1267506523a56e0309f024e241b6b141
diff --git a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/VertxBinderProcessor.java b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/VertxBinderProcessor.java index 002039e97b6..8c4ebd90ee5 100644 --- a/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/VertxBinderProcessor.java +++ b/extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/VertxBinderProcessor.java @@ -34,6 +34,9 @@ public boolean getAsBoolean() { } } + // avoid imports due to related deps not being there + static final String VERTX_CONTAINER_FILTER_CLASS_NAME = "io.quarkus.micrometer.runtime.binder.vertx.VertxMeterBinderContainerFilter"; + @BuildStep(onlyIf = { VertxBinderEnabled.class }) ResteasyJaxrsProviderBuildItem enableResteasySupport(Capabilities capabilities, BuildProducer<AdditionalBeanBuildItem> additionalBeans) { @@ -45,7 +48,7 @@ ResteasyJaxrsProviderBuildItem enableResteasySupport(Capabilities capabilities, .addBeanClass(VertxMeterBinderContainerFilter.class) .setUnremovable().build()); - return new ResteasyJaxrsProviderBuildItem(VertxMeterBinderContainerFilter.class.getName()); + return new ResteasyJaxrsProviderBuildItem(VERTX_CONTAINER_FILTER_CLASS_NAME); } @BuildStep(onlyIf = VertxBinderEnabled.class)
['extensions/micrometer/deployment/src/main/java/io/quarkus/micrometer/deployment/binder/VertxBinderProcessor.java']
{'.java': 1}
1
1
0
0
1
11,415,858
2,230,358
297,052
3,150
386
84
5
1
5,902
342
1,526
77
1
2
2020-10-01T15:03: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,939
quarkusio/quarkus/12451/12463
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12463
https://github.com/quarkusio/quarkus/pull/12451
https://github.com/quarkusio/quarkus/pull/12451
1
fixes
Hibernate ORM extension boot is not holding the @Startup event
**Describe the bug** There is no guarantee that an event listening for `@Startup` runs strictly after the Hibernate ORM bootstrap. Clearly the intent should be that all such frameworks have completed initialization, and this gets noticeable if the application code expects - for example - the database schema to have been generated. As reported on Zulip by @famod
70b7d8119e4166dc56b5c22dfd42b3c70e4920d9
cce324813fccffff7576c4bf2bc9696006f4bd8b
https://github.com/quarkusio/quarkus/compare/70b7d8119e4166dc56b5c22dfd42b3c70e4920d9...cce324813fccffff7576c4bf2bc9696006f4bd8b
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java index d17262f18cb..27833a72c03 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java @@ -95,6 +95,7 @@ import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem; import io.quarkus.deployment.builditem.LaunchModeBuildItem; import io.quarkus.deployment.builditem.LogCategoryBuildItem; +import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.builditem.SystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; @@ -506,16 +507,17 @@ public void build(HibernateOrmRecorder recorder, HibernateOrmConfig hibernateOrm @BuildStep @Record(RUNTIME_INIT) - public void startPersistenceUnits(HibernateOrmRecorder recorder, BeanContainerBuildItem beanContainer, + public ServiceStartBuildItem startPersistenceUnits(HibernateOrmRecorder recorder, BeanContainerBuildItem beanContainer, List<JdbcDataSourceBuildItem> dataSourcesConfigured, JpaEntitiesBuildItem jpaEntities, List<NonJpaModelBuildItem> nonJpaModels, List<HibernateOrmIntegrationRuntimeConfiguredBuildItem> integrationsRuntimeConfigured, List<JdbcDataSourceSchemaReadyBuildItem> schemaReadyBuildItem) throws Exception { - if (!hasEntities(jpaEntities, nonJpaModels)) { - return; + if (hasEntities(jpaEntities, nonJpaModels)) { + recorder.startAllPersistenceUnits(beanContainer.getValue()); } - recorder.startAllPersistenceUnits(beanContainer.getValue()); + return new ServiceStartBuildItem("Hibernate ORM"); + } @BuildStep
['extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java']
{'.java': 1}
1
1
0
0
1
11,410,600
2,229,324
296,917
3,149
633
119
10
1
371
58
72
6
0
0
2020-10-01T14:40:35
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,940
quarkusio/quarkus/12450/12441
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12441
https://github.com/quarkusio/quarkus/pull/12450
https://github.com/quarkusio/quarkus/pull/12450
1
fixes
Form based authentication cookie will soon be rejected
**Describe the bug** I register it as a bug because soon it won't work anymore. Using the Form Based Authentication, a cookie is created, with default name "quarkus-credential". Doing so, Firefox warns: `Cookie “quarkus-credential” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite` I followed the tutorial: http://fxapps.blogspot.com/2019/12/quarkus-application-with-form.html **Expected behavior** We should be able to customize the cookie attributes, at least "SameSite" and "Secure". **Actual behavior** We can only customize the cookie name using "quarkus.http.auth.form.cookie-name". **Configuration** ```properties quarkus.http.auth.form.enabled=true quarkus.security.jdbc.enabled=true quarkus.security.jdbc.principal-query.datasource=auth quarkus.security.jdbc.principal-query.sql=SELECT password FROM users u WHERE u.login=? quarkus.security.jdbc.principal-query.bcrypt-password-mapper.enabled=true quarkus.security.jdbc.principal-query.bcrypt-password-mapper.password-index=1 quarkus.security.jdbc.principal-query.bcrypt-password-mapper.iteration-count-index=-1 quarkus.security.jdbc.principal-query.bcrypt-password-mapper.salt-index=-1 quarkus.security.jdbc.principal-query.roles.sql=select r.name as role_name from roles r, (select m.role_id from assigned_role m join user u on m.user_id = u.id and u.login = ?) a where r.id >= a.role_id quarkus.security.jdbc.principal-query.roles.datasource=auth quarkus.security.jdbc.principal-query.roles.attribute-mappings.0.index=1 quarkus.security.jdbc.principal-query.roles.attribute-mappings.0.to=groups quarkus.http.auth.permission.permit1.paths=/secured/* quarkus.http.auth.permission.permit1.policy=authenticated ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux netwave-lolo 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linu - Output of `java -version`: openjdk version "1.8.0_252" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode) - GraalVM version (if different from Java): - - Quarkus version or git rev: 1.8.1 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
2ba1dc64907da85640e70e7b3d27b9eff57f4d2d
a6e0d6e62a8122a91f0083a724b3f0598001f704
https://github.com/quarkusio/quarkus/compare/2ba1dc64907da85640e70e7b3d27b9eff57f4d2d...a6e0d6e62a8122a91f0083a724b3f0598001f704
diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java index b61dd75a9f8..c8985925854 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java @@ -18,6 +18,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; import io.restassured.filter.cookie.CookieFilter; +import io.restassured.matcher.RestAssuredMatchers; public class FormAuthTestCase { @@ -60,7 +61,8 @@ public void testFormBasedAuthSuccess() { .assertThat() .statusCode(302) .header("location", containsString("/login")) - .cookie("quarkus-redirect-location", containsString("/admin")); + .cookie("quarkus-redirect-location", + RestAssuredMatchers.detailedCookie().value(containsString("/admin")).secured(false)); RestAssured .given() @@ -74,7 +76,8 @@ public void testFormBasedAuthSuccess() { .assertThat() .statusCode(302) .header("location", containsString("/admin")) - .cookie("quarkus-credential", notNullValue()); + .cookie("quarkus-credential", + RestAssuredMatchers.detailedCookie().value(notNullValue()).secured(false)); RestAssured .given() diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java index 74d6962fb87..062965097f7 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java @@ -75,7 +75,7 @@ public void handle(Void event) { @Override public void accept(SecurityIdentity identity) { try { - loginManager.save(identity, exchange, null); + loginManager.save(identity, exchange, null, exchange.request().isSSL()); if (redirectAfterLogin || exchange.getCookie(locationCookie) != null) { handleRedirectBack(exchange); //we have authenticated, but we want to just redirect back to the original page @@ -111,6 +111,7 @@ protected void handleRedirectBack(final RoutingContext exchange) { Cookie redirect = exchange.getCookie(locationCookie); String location; if (redirect != null) { + redirect.setSecure(exchange.request().isSSL()); location = redirect.getValue(); exchange.response().addCookie(redirect.setMaxAge(0)); } else { @@ -122,7 +123,8 @@ protected void handleRedirectBack(final RoutingContext exchange) { } protected void storeInitialLocation(final RoutingContext exchange) { - exchange.response().addCookie(Cookie.cookie(locationCookie, exchange.request().absoluteURI()).setPath("/")); + exchange.response().addCookie(Cookie.cookie(locationCookie, exchange.request().absoluteURI()) + .setPath("/").setSecure(exchange.request().isSSL())); } protected void servePage(final RoutingContext exchange, final String location) { @@ -152,7 +154,7 @@ public Uni<SecurityIdentity> authenticate(RoutingContext context, return ret.onItem().invoke(new Consumer<SecurityIdentity>() { @Override public void accept(SecurityIdentity securityIdentity) { - loginManager.save(securityIdentity, context, result); + loginManager.save(securityIdentity, context, result, context.request().isSSL()); } }); } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/PersistentLoginManager.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/PersistentLoginManager.java index f6da62631fb..580e771af0a 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/PersistentLoginManager.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/PersistentLoginManager.java @@ -37,10 +37,10 @@ public class PersistentLoginManager { private final long newCookieIntervalMillis; public PersistentLoginManager(String encryptionKey, String cookieName, long timeoutMillis, long newCookieIntervalMillis) { + this.cookieName = cookieName; + this.newCookieIntervalMillis = newCookieIntervalMillis; + this.timeoutMillis = timeoutMillis; try { - this.cookieName = cookieName; - this.newCookieIntervalMillis = newCookieIntervalMillis; - this.timeoutMillis = timeoutMillis; if (encryptionKey == null) { this.secretKey = KeyGenerator.getInstance("AES").generateKey(); } else if (encryptionKey.length() < 16) { @@ -99,7 +99,7 @@ public RestoreResult restore(RoutingContext context) { } } - public void save(SecurityIdentity identity, RoutingContext context, RestoreResult restoreResult) { + public void save(SecurityIdentity identity, RoutingContext context, RestoreResult restoreResult, boolean secureCookie) { if (restoreResult != null) { if (!restoreResult.newCookieNeeded) { return; @@ -122,7 +122,7 @@ public void save(SecurityIdentity identity, RoutingContext context, RestoreResul message.put(iv); message.put(encrypted); String cookieValue = Base64.getEncoder().encodeToString(message.array()); - context.addCookie(Cookie.cookie(cookieName, cookieValue).setPath("/")); + context.addCookie(Cookie.cookie(cookieName, cookieValue).setPath("/").setSecure(secureCookie)); } catch (Exception e) { throw new RuntimeException(e); }
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/PersistentLoginManager.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/FormAuthTestCase.java']
{'.java': 3}
3
3
0
0
3
11,410,600
2,229,324
296,917
3,149
1,478
260
18
2
2,535
225
675
41
2
1
2020-10-01T14:12:29
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,941
quarkusio/quarkus/12421/12420
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12420
https://github.com/quarkusio/quarkus/pull/12421
https://github.com/quarkusio/quarkus/pull/12421
1
fixes
SmallRye GraphQL extension's metrics are broken
The producer of vendor `MetricRegistry` is detected as unused (unless an application injects it directly, which makes no sense), but it is needed at runtime. This appears at application boot: ``` CDI: programmatic lookup problem detected ----------------------------------------- At least one bean matched the required type and qualifiers but was marked as unused and removed during build Removed beans: - PRODUCER_METHOD bean io.smallrye.metrics.MetricRegistries#getVendorRegistry() [types=[class org.eclipse.microprofile.metrics.MetricRegistry], qualifiers=[@org.eclipse.microprofile.metrics.annotation.RegistryType(type=VENDOR)]] Required type: class org.eclipse.microprofile.metrics.MetricRegistry Required qualifiers: [@org.eclipse.microprofile.metrics.annotation.RegistryType(type=VENDOR)] Solutions: - Application developers can eliminate false positives via the @Unremovable annotation - Extensions can eliminate false positives via build items, e.g. using the UnremovableBeanBuildItem - See also https://quarkus.io/guides/cdi-reference#remove_unused_beans ``` Unfortunately, `io.quarkus.smallrye.graphql.deployment.MetricsTest` is unable to catch this error, because the test itself injects the vendor registry, therefore it's not unused and everything works....
67fdafe15bc1ca343611d62ecede35a250b4c380
7e0ae82f55367ad33191435d47b785bef45973a9
https://github.com/quarkusio/quarkus/compare/67fdafe15bc1ca343611d62ecede35a250b4c380...7e0ae82f55367ad33191435d47b785bef45973a9
diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index 4a10723fefc..2b1bf82f786 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -26,6 +26,7 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; import io.quarkus.arc.deployment.BeanDefiningAnnotationBuildItem; +import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.bootstrap.model.AppArtifact; import io.quarkus.bootstrap.model.AppDependency; import io.quarkus.deployment.Capabilities; @@ -54,6 +55,7 @@ import io.quarkus.deployment.util.IoUtil; import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.runtime.LaunchMode; +import io.quarkus.runtime.metrics.MetricsFactory; import io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLRecorder; import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem; import io.quarkus.vertx.http.deployment.RequireBodyHandlerBuildItem; @@ -168,9 +170,13 @@ void buildExecutionService( void activateMetrics(Capabilities capabilities, Optional<MetricsCapabilityBuildItem> metricsCapability, SmallRyeGraphQLConfig smallRyeGraphQLConfig, - BuildProducer<SystemPropertyBuildItem> systemProperties) { + BuildProducer<SystemPropertyBuildItem> systemProperties, + BuildProducer<UnremovableBeanBuildItem> unremovableBeans) { if (smallRyeGraphQLConfig.metricsEnabled) { if (metricsCapability.isPresent()) { + if (metricsCapability.get().metricsSupported(MetricsFactory.MP_METRICS)) { + unremovableBeans.produce(UnremovableBeanBuildItem.beanClassNames("io.smallrye.metrics.MetricRegistries")); + } systemProperties.produce(new SystemPropertyBuildItem("smallrye.graphql.metrics.enabled", "true")); } else { LOG.info("The quarkus.smallrye-graphql.metrics.enabled property is true, but a metrics " + diff --git a/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/MetricsTest.java b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/MetricsTest.java index fd535769cc1..8afcdbb3138 100644 --- a/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/MetricsTest.java +++ b/extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/MetricsTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import javax.inject.Inject; import javax.json.Json; import javax.json.JsonObject; @@ -11,7 +10,6 @@ import org.eclipse.microprofile.metrics.MetricRegistry; import org.eclipse.microprofile.metrics.SimpleTimer; import org.eclipse.microprofile.metrics.Tag; -import org.eclipse.microprofile.metrics.annotation.RegistryType; import org.hamcrest.CoreMatchers; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; @@ -22,6 +20,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; +import io.smallrye.metrics.MetricRegistries; public class MetricsTest { @@ -32,13 +31,10 @@ public class MetricsTest { .addAsResource(new StringAsset("quarkus.smallrye-graphql.metrics.enabled=true"), "application.properties") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); - @Inject - @RegistryType(type = MetricRegistry.Type.VENDOR) - MetricRegistry metricRegistry; - // Run a Query and check that its corresponding metric is updated @Test public void testQuery() { + MetricRegistry metricRegistry = MetricRegistries.get(MetricRegistry.Type.VENDOR); SimpleTimer metric = metricRegistry.getSimpleTimers() .get(new MetricID("mp_graphql", new Tag("type", "Query"), new Tag("name", "ping"))); assertNotNull(metric, "Metrics should be registered eagerly");
['extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java', 'extensions/smallrye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/MetricsTest.java']
{'.java': 2}
2
2
0
0
2
11,397,065
2,226,607
296,536
3,147
564
114
8
1
1,295
125
269
18
1
1
2020-09-30T12:02:00
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,921
quarkusio/quarkus/12843/12842
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12842
https://github.com/quarkusio/quarkus/pull/12843
https://github.com/quarkusio/quarkus/pull/12843
1
fixes
Amazon S3 Extension: Interceptors Configuration Fails to AWS Shipped Interceptors
**Describe the bug** `quarkus.s3.interceptors=com.amazonaws.xray.interceptors.TracingInterceptor` results in a failure to configure the s3 client. **Expected behavior** AWS shipped S3 interceptors, like the XRay Tracing Interceptors, work with extension configuration model. **Actual behavior** (Describe the actual behavior clearly and concisely.) ``` Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.amazon.common.deployment.AmazonServicesClientsProcessor#setup threw an exception: io.quarkus.deployment.configuration.ConfigurationError: quarkus.s3.interceptors (Optional[[class com.amazonaws.xray.interceptors.TracingInterceptor]]) - must list only existing implementations of software.amazon.awssdk.core.interceptor.ExecutionInterceptor at io.quarkus.amazon.common.deployment.AmazonServicesClientsProcessor.lambda$setup$2(AmazonServicesClientsProcessor.java:73) ``` **To Reproduce** Don't have a reproducer easily available. Should be able to generate a project with `quarkus-amazon-lambda-xray`, `quarkus-amazon-lambda` and `quarkus-amazon-s3` extensions, add the configuration below, and create a junit where you inject an S3 client. Run the unit test. Possible that you could also tweak https://github.com/quarkusio/quarkus/blob/master/integration-tests/amazon-services/src/main/resources/application.properties#L9-L15 and using the existing integration tests? **Configuration** ```properties quarkus.s3.interceptors=com.amazonaws.xray.interceptors.TracingInterceptor ``` **Screenshots** (If applicable, add screenshots to help explain your problem.) **Environment (please complete the following information):** - Output of `uname -a` or `ver`: - Output of `java -version`: - GraalVM version (if different from Java): 20.1.0-java8 - Quarkus version or git rev: 1.8.3.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): 3.6.3 **Additional context** cc @marcinczeczko @gsmet @oztimpower This was precisely the sort of concern I had when I wrote https://github.com/quarkusio/quarkus/pull/4968#issuecomment-611186155. It's possible there is no xray extension yet, and this is the problem? Happy to test patches if that is helpful resolving this issue, but writing a new extension is probably more than I can commit. For now, I'll continue configuring the AWS SDK without the quarkus extensions.
1374511dc819390a2f24e354e287ad9dd19e75af
f4b371b30925c405913871e15db4b63d9e464b74
https://github.com/quarkusio/quarkus/compare/1374511dc819390a2f24e354e287ad9dd19e75af...f4b371b30925c405913871e15db4b63d9e464b74
diff --git a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java index 92253de931b..cda8f72528e 100644 --- a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java +++ b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java @@ -27,6 +27,7 @@ public class AmazonServicesClientsProcessor { public static final String AWS_SDK_APPLICATION_ARCHIVE_MARKERS = "software/amazon/awssdk"; + public static final String AWS_SDK_XRAY_ARCHIVE_MARKER = "com/amazonaws/xray"; private static final String APACHE_HTTP_SERVICE = "software.amazon.awssdk.http.apache.ApacheSdkHttpService"; private static final String NETTY_HTTP_SERVICE = "software.amazon.awssdk.http.nio.netty.NettySdkAsyncHttpService"; @@ -41,8 +42,9 @@ void globalInterceptors(BuildProducer<AmazonClientInterceptorsPathBuildItem> pro } @BuildStep - AdditionalApplicationArchiveMarkerBuildItem awsAppArchiveMarkers() { - return new AdditionalApplicationArchiveMarkerBuildItem(AWS_SDK_APPLICATION_ARCHIVE_MARKERS); + void awsAppArchiveMarkers(BuildProducer<AdditionalApplicationArchiveMarkerBuildItem> archiveMarker) { + archiveMarker.produce(new AdditionalApplicationArchiveMarkerBuildItem(AWS_SDK_APPLICATION_ARCHIVE_MARKERS)); + archiveMarker.produce(new AdditionalApplicationArchiveMarkerBuildItem(AWS_SDK_XRAY_ARCHIVE_MARKER)); } @BuildStep
['extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java']
{'.java': 1}
1
1
0
0
1
11,597,979
2,267,272
301,844
3,218
594
110
6
1
2,464
249
586
39
2
2
2020-10-21T07:56: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,920
quarkusio/quarkus/12879/12819
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12819
https://github.com/quarkusio/quarkus/pull/12879
https://github.com/quarkusio/quarkus/pull/12879
1
close
gradle quarkus:dev task should be more lenient when analysing project dependencies
**Describe the bug** It's a gradle multi module project with two projects * application - kotlin jvm * ui - kotlin js The ui module produces a jar file with a `META-INF/resources` directory containing the web application (html, js, ..) and is linked as project dependency to the application. Gradle mentions that the ["preferred way"](https://docs.gradle.org/current/userguide/cross_project_publications.html) of sharing artifacts would be a custom configuration. ``` // application plugins { id ("io.quarkus") kotlin ("jvm") } dependencies { implementation (project (":ui", configuration = "webpackjar")) } -------------------------------------------------------------------------------------------- // ui plugins { kotlin ("js") } val webpackjar by configurations.creating { isCanBeConsumed = true isCanBeResolved = false attributes { attribute(Category.CATEGORY_ATTRIBUTE, namedAttribute(Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, namedAttribute(Bundling.EXTERNAL)) attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JavaVersion.current().majorVersion.toInt()) attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, namedAttribute(LibraryElements.JAR)) attribute(Usage.USAGE_ATTRIBUTE, namedAttribute(Usage.JAVA_RUNTIME)) attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm) } } artifacts { add("webpackjar", jar) } ``` It seems that the java convention plugin is somehow active in the ui module, which leads to an exception that is shown below. The build succeeds otherwise, e.g `quarkus:build` Extending the guard `if (javaConvention != null) {` with an additional check would solve this issue. **Expected behavior** `quarkus:dev` task should not abort if the main sourceset can't be resolved from the java convention plugin **Actual behavior** ``` Caused by: org.gradle.api.UnknownDomainObjectException: SourceSet with name 'main' not found. at org.gradle.api.internal.DefaultNamedDomainObjectCollection.createNotFoundException(DefaultNamedDomainObjectCollection.java:504) at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333) at io.quarkus.gradle.builder.QuarkusModelBuilder.addDevModePaths(QuarkusModelBuilder.java:297) at io.quarkus.gradle.builder.QuarkusModelBuilder.collectDependencies(QuarkusModelBuilder.java:254) at io.quarkus.gradle.builder.QuarkusModelBuilder.buildAll(QuarkusModelBuilder.java:94) at io.quarkus.gradle.QuarkusPluginExtension.create(QuarkusPluginExtension.java:185) at io.quarkus.gradle.QuarkusPluginExtension.getQuarkusModel(QuarkusPluginExtension.java:178) at io.quarkus.gradle.QuarkusPluginExtension.getAppModelResolver(QuarkusPluginExtension.java:170) at io.quarkus.gradle.tasks.QuarkusDev.startDev(QuarkusDev.java:285) ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: windows - Output of `java -version`: openjdk version "11.0.6" 2020-01-14 - GraalVM version (if different from Java): --- - Quarkus version or git rev: 1.8.3 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Gradle 6.6.1
5ddb3d4e616763c81db5f1230c897d2c8f0d8556
588e0b3b9d399f48988e480d79d85ac8032f448d
https://github.com/quarkusio/quarkus/compare/5ddb3d4e616763c81db5f1230c897d2c8f0d8556...588e0b3b9d399f48988e480d79d85ac8032f448d
diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java index f20810505e4..8252e293e55 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java @@ -296,25 +296,29 @@ private void collectDependencies(ResolvedConfiguration configuration, private void addDevModePaths(final DependencyImpl dep, ResolvedArtifact a, Project project) { final JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class); - if (javaConvention != null) { - SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); - final File classesDir = new File(QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir(), false)); - if (classesDir.exists()) { - dep.addPath(classesDir); - } - for (File resourcesDir : mainSourceSet.getResources().getSourceDirectories()) { - if (resourcesDir.exists()) { - dep.addPath(resourcesDir); + if (javaConvention == null) { + dep.addPath(a.getFile()); + } else { + SourceSet mainSourceSet = javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME); + if (mainSourceSet != null) { + final File classesDir = new File(QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir(), false)); + if (classesDir.exists()) { + dep.addPath(classesDir); } - } - for (File outputDir : project.getTasks().findByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME) - .getOutputs().getFiles()) { - if (outputDir.exists()) { - dep.addPath(outputDir); + for (File resourcesDir : mainSourceSet.getResources().getSourceDirectories()) { + if (resourcesDir.exists()) { + dep.addPath(resourcesDir); + } } + for (File outputDir : project.getTasks().findByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME) + .getOutputs().getFiles()) { + if (outputDir.exists()) { + dep.addPath(outputDir); + } + } + } else { + dep.addPath(a.getFile()); } - } else { - dep.addPath(a.getFile()); } } diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index 7aedaa6b806..501b8f7dc92 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -420,7 +420,10 @@ private void addLocalProject(Project project, DevModeContext context, Set<AppArt } SourceSetContainer sourceSets = javaConvention.getSourceSets(); - SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); + SourceSet mainSourceSet = sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME); + if (mainSourceSet == null) { + return; + } Set<String> sourcePaths = new HashSet<>(); Set<String> sourceParentPaths = new HashSet<>();
['devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java', 'devtools/gradle/src/main/java/io/quarkus/gradle/builder/QuarkusModelBuilder.java']
{'.java': 2}
2
2
0
0
2
11,600,463
2,267,795
301,913
3,219
2,182
406
41
2
3,288
269
744
82
1
2
2020-10-22T12:20: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,919
quarkusio/quarkus/12888/12754
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12754
https://github.com/quarkusio/quarkus/pull/12888
https://github.com/quarkusio/quarkus/pull/12888
1
fixes
oidc use Programmatically Resolving Tenants Configuration BUT hangs
Hi @sberyozkin @pedroigor regarding to this: https://quarkus.io/guides/security-openid-connect-multitenancy#programmatically-resolving-tenants-configuration if i used configuration ways, it works fine and can redirect to keycloak, BUT when uses programmatically way it hangs there and keep waiting. ////////////////////////// I use intellj debug mode and dive into the source code, I found the issue is in this part, in DefaultTenantConfigResolver.java if (tenantContext == null) { if (create) { synchronized (dynamicTenantsConfig) { tenantContext = dynamicTenantsConfig.computeIfAbsent(tenantId, clientId -> tenantConfigBean.getTenantConfigContextFactory().apply(tenantConfig)); } } else { tenantContext = new TenantConfigContext(null, tenantConfig); } } =======>>>>> synchronized (dynamicTenantsConfig) { tenantContext = dynamicTenantsConfig.computeIfAbsent(tenantId, clientId -> tenantConfigBean.getTenantConfigContextFactory().apply(tenantConfig)); } this one looks the root issue cause, when reach this line, it terminated. can you please have a look? BTW here is show that I used the programmtical way this is my application code level: @ApplicationScoped public class CustomTenantConfigResolver implements TenantConfigResolver { @Override public OidcTenantConfig resolve(RoutingContext context) { String path = context.request().path(); String[] parts = path.split("/"); if (parts.length == 0) { // resolve to default tenant configuration return null; } if ("tenant-a".equals(parts[1])) { OidcTenantConfig config = new OidcTenantConfig(); config.setTenantId("tenant-a"); config.setAuthServerUrl("http://localhost:8180/auth/realms/tenant-a"); config.setClientId("multi-tenant-client"); config.applicationType = OidcTenantConfig.ApplicationType.WEB_APP; return config; } // resolve to default tenant configuration return null; } } can you please have a look, thanks!
99dda5bf3affca33ed0d66157c7af5d6b11f1d99
dd321fe6bd2197075423f262fa7b69da5b2147de
https://github.com/quarkusio/quarkus/compare/99dda5bf3affca33ed0d66157c7af5d6b11f1d99...dd321fe6bd2197075423f262fa7b69da5b2147de
diff --git a/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java b/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java index 13481c193a6..97efb735350 100644 --- a/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java +++ b/extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java @@ -12,8 +12,9 @@ public class KeycloakPolicyEnforcerRecorder { public void setup(OidcConfig oidcConfig, KeycloakPolicyEnforcerConfig config, BeanContainer beanContainer, HttpConfiguration httpConfiguration) { - if (oidcConfig.defaultTenant.applicationType == OidcTenantConfig.ApplicationType.WEB_APP) { - throw new OIDCException("Application type [" + oidcConfig.defaultTenant.applicationType + "] is not supported"); + if (oidcConfig.defaultTenant.getApplicationType() == OidcTenantConfig.ApplicationType.WEB_APP) { + throw new OIDCException( + "Application type [" + oidcConfig.defaultTenant.getApplicationType() + "] is not supported"); } beanContainer.instance(KeycloakPolicyEnforcerAuthorizer.class).init(oidcConfig, config, httpConfiguration); } diff --git a/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTenantConfigResolver.java b/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTenantConfigResolver.java index 35a6d8d85c6..4d654d95b75 100644 --- a/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTenantConfigResolver.java +++ b/extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTenantConfigResolver.java @@ -16,7 +16,7 @@ public OidcTenantConfig resolve(RoutingContext context) { config.setTenantId("tenant-config-resolver"); config.setAuthServerUrl(getIssuerUrl() + "/realms/devmode"); config.setClientId("client-dev-mode"); - config.applicationType = ApplicationType.WEB_APP; + config.setApplicationType(ApplicationType.WEB_APP); return config; } return null; 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 42a2040e671..bee328b75df 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 @@ -187,8 +187,8 @@ public enum Verification { * Certificate validation and hostname verification, which can be one of the following values from enum * {@link Verification}. Default is required. */ - @ConfigItem(defaultValue = "REQUIRED") - public Verification verification; + @ConfigItem(defaultValue = "required") + public Verification verification = Verification.REQUIRED; public Verification getVerification() { return verification; @@ -257,7 +257,7 @@ public enum Strategy { * Default TokenStateManager strategy. */ @ConfigItem(defaultValue = "keep_all_tokens") - public Strategy strategy; + public Strategy strategy = Strategy.KEEP_ALL_TOKENS; /** * Default TokenStateManager keeps all tokens (ID, access and refresh) @@ -437,6 +437,14 @@ public Logout getLogout() { return logout; } + public ApplicationType getApplicationType() { + return applicationType; + } + + public void setApplicationType(ApplicationType applicationType) { + this.applicationType = applicationType; + } + @ConfigGroup public static class Credentials { diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java index 635d42b9224..344180afdf0 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java @@ -99,8 +99,7 @@ private TenantConfigContext getTenantConfigFromTenantResolver(RoutingContext con boolean isBlocking(RoutingContext context) { TenantConfigContext resolver = resolve(context, false); return resolver != null - && (resolver.auth == null || resolver.oidcConfig.token.refreshExpired - || resolver.oidcConfig.authentication.userInfoRequired); + && (resolver.oidcConfig.token.refreshExpired || resolver.oidcConfig.authentication.userInfoRequired); } boolean isSecurityEventObserved() { diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java index 80c4dd9b548..c0567851b92 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java @@ -64,10 +64,10 @@ private TenantConfigContext resolve(RoutingContext context) { } private boolean isWebApp(RoutingContext context, TenantConfigContext tenantContext) { - if (OidcTenantConfig.ApplicationType.HYBRID == tenantContext.oidcConfig.applicationType) { + if (OidcTenantConfig.ApplicationType.HYBRID == tenantContext.oidcConfig.getApplicationType()) { return context.request().getHeader("Authorization") == null; } - return OidcTenantConfig.ApplicationType.WEB_APP == tenantContext.oidcConfig.applicationType; + return OidcTenantConfig.ApplicationType.WEB_APP == tenantContext.oidcConfig.getApplicationType(); } @Override diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java index c753e191a9d..f383c4fffc0 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java @@ -48,6 +48,8 @@ public Uni<SecurityIdentity> authenticate(TokenAuthenticationRequest request, OidcTokenCredential credential = (OidcTokenCredential) request.getToken(); RoutingContext vertxContext = credential.getRoutingContext(); vertxContext.put(AuthenticationRequestContext.class.getName(), context); + TenantConfigContext resolvedContext = tenantResolver.resolve(vertxContext, true); + return Uni.createFrom().deferred(new Supplier<Uni<? extends SecurityIdentity>>() { @Override public Uni<SecurityIdentity> get() { @@ -55,20 +57,19 @@ public Uni<SecurityIdentity> get() { return context.runBlocking(new Supplier<SecurityIdentity>() { @Override public SecurityIdentity get() { - return authenticate(request, vertxContext).await().indefinitely(); + return authenticate(request, vertxContext, resolvedContext).await().indefinitely(); } }); } - return authenticate(request, vertxContext); + return authenticate(request, vertxContext, resolvedContext); } }); } private Uni<SecurityIdentity> authenticate(TokenAuthenticationRequest request, - RoutingContext vertxContext) { - TenantConfigContext resolvedContext = tenantResolver.resolve(vertxContext, true); + RoutingContext vertxContext, TenantConfigContext resolvedContext) { if (resolvedContext.oidcConfig.publicKey.isPresent()) { return validateTokenWithoutOidcServer(request, resolvedContext); 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 4dcf16ea122..dc380cdeda6 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 @@ -18,6 +18,7 @@ import io.quarkus.oidc.OidcTenantConfig.Credentials.Secret; import io.quarkus.oidc.OidcTenantConfig.Roles.Source; import io.quarkus.oidc.OidcTenantConfig.Tls.Verification; +import io.quarkus.runtime.ExecutorRecorder; import io.quarkus.runtime.annotations.Recorder; import io.quarkus.runtime.configuration.ConfigurationException; import io.smallrye.mutiny.Uni; @@ -62,9 +63,22 @@ public TenantConfigBean get() { new Function<OidcTenantConfig, TenantConfigContext>() { @Override public TenantConfigContext apply(OidcTenantConfig config) { - // OidcTenantConfig resolved by TenantConfigResolver must have its optional tenantId - // initialized which is also enforced by DefaultTenantConfigResolver - return createTenantContext(vertxValue, config, config.getTenantId().get()); + return Uni.createFrom().emitter(new Consumer<UniEmitter<? super TenantConfigContext>>() { + @Override + public void accept(UniEmitter<? super TenantConfigContext> uniEmitter) { + ExecutorRecorder.getCurrent().execute(new Runnable() { + @Override + public void run() { + try { + uniEmitter.complete(createTenantContext(vertxValue, config, + config.getTenantId().get())); + } catch (Throwable t) { + uniEmitter.fail(t); + } + } + }); + } + }).await().indefinitely(); } }); } @@ -120,7 +134,7 @@ private TenantConfigContext createTenantContext(Vertx vertx, OidcTenantConfig oi options.setSite(authServerUrl); if (!oidcConfig.discoveryEnabled) { - if (oidcConfig.applicationType != ApplicationType.SERVICE) { + if (oidcConfig.getApplicationType() != ApplicationType.SERVICE) { if (!oidcConfig.authorizationPath.isPresent() || !oidcConfig.tokenPath.isPresent()) { throw new OIDCException("'web-app' applications must have 'authorization-path' and 'token-path' properties " + "set when the discovery is disabled."); @@ -165,7 +179,7 @@ private TenantConfigContext createTenantContext(Vertx vertx, OidcTenantConfig oi "Use only 'credentials.secret' or 'credentials.client-secret' or 'credentials.jwt.secret' property"); } - if (ApplicationType.SERVICE.equals(oidcConfig.applicationType)) { + if (ApplicationType.SERVICE.equals(oidcConfig.getApplicationType())) { if (oidcConfig.token.refreshExpired) { throw new RuntimeException( "The 'token.refresh-expired' property can only be enabled for " + ApplicationType.WEB_APP @@ -299,7 +313,7 @@ public void accept(UniEmitter<? super OAuth2Auth> uniEmitter) { @SuppressWarnings("deprecation") private static TenantConfigContext createdTenantContextFromPublicKey(OAuth2ClientOptions options, OidcTenantConfig oidcConfig) { - if (oidcConfig.applicationType != ApplicationType.SERVICE) { + if (oidcConfig.getApplicationType() != ApplicationType.SERVICE) { throw new ConfigurationException("'public-key' property can only be used with the 'service' applications"); } LOG.debug("'public-key' property for the local token verification is set," diff --git a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomTenantConfigResolver.java b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomTenantConfigResolver.java index 41231a0009c..fc93034bd4c 100644 --- a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomTenantConfigResolver.java +++ b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomTenantConfigResolver.java @@ -3,6 +3,8 @@ import javax.enterprise.context.ApplicationScoped; import io.quarkus.oidc.OidcTenantConfig; +import io.quarkus.oidc.OidcTenantConfig.ApplicationType; +import io.quarkus.oidc.OidcTenantConfig.Roles.Source; import io.quarkus.oidc.TenantConfigResolver; import io.vertx.ext.web.RoutingContext; @@ -41,6 +43,16 @@ public OidcTenantConfig resolve(RoutingContext context) { config.setJwksPath("jwks"); config.setClientId("client"); return config; + } else if ("tenant-web-app-dynamic".equals(tenantId)) { + OidcTenantConfig config = new OidcTenantConfig(); + config.setTenantId("tenant-web-app-dynamic"); + config.setAuthServerUrl(getIssuerUrl() + "/realms/quarkus-webapp"); + config.setClientId("quarkus-app-webapp"); + config.getCredentials().setSecret("secret"); + config.getAuthentication().setUserInfoRequired(true); + config.getRoles().setSource(Source.userinfo); + config.setApplicationType(ApplicationType.WEB_APP); + return config; } return null; } diff --git a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/TenantResource.java b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/TenantResource.java index 02d70053039..86ba9be712b 100644 --- a/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/TenantResource.java +++ b/integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/TenantResource.java @@ -56,7 +56,8 @@ public String userNameServiceNoDiscovery(@PathParam("tenant") String tenant) { @Path("webapp") @RolesAllowed("user") public String userNameWebApp(@PathParam("tenant") String tenant) { - if (!tenant.equals("tenant-web-app") && !tenant.equals("tenant-web-app-no-discovery")) { + if (!tenant.equals("tenant-web-app") + && !tenant.equals("tenant-web-app-dynamic") && !tenant.equals("tenant-web-app-no-discovery")) { throw new OIDCException("Wrong tenant"); } UserInfo userInfo = getUserInfo(); diff --git a/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java b/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java index 123bc0e811e..1fde80f8868 100644 --- a/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java +++ b/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java @@ -53,12 +53,29 @@ public void testResolveTenantIdentifierWebApp() throws IOException { } } + @Test + public void testResolveTenantIdentifierWebAppDynamic() throws IOException { + try (final WebClient webClient = createWebClient()) { + HtmlPage page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app-dynamic/api/user/webapp"); + // State cookie is available but there must be no saved path parameter + // as the tenant-web-app-dynamic configuration does not set a redirect-path property + assertNull(getStateCookieSavedPath(webClient, "tenant-web-app-dynamic")); + assertEquals("Log in to quarkus-webapp", page.getTitleText()); + HtmlForm loginForm = page.getForms().get(0); + loginForm.getInputByName("username").setValueAttribute("alice"); + loginForm.getInputByName("password").setValueAttribute("alice"); + page = loginForm.getInputByName("login").click(); + assertEquals("tenant-web-app-dynamic:alice", page.getBody().asText()); + webClient.getCookieManager().clearCookies(); + } + } + @Test public void testResolveTenantIdentifierWebApp2() throws IOException { try (final WebClient webClient = createWebClient()) { HtmlPage page = webClient.getPage("http://localhost:8081/tenant/tenant-web-app2/api/user/webapp2"); // State cookie is available but there must be no saved path parameter - // as the tenant-web-app configuration does not set a redirect-path property + // as the tenant-web-app2 configuration does not set a redirect-path property assertNull(getStateCookieSavedPath(webClient, "tenant-web-app2")); assertEquals("Log in to quarkus-webapp2", page.getTitleText()); HtmlForm loginForm = page.getForms().get(0); diff --git a/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java b/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java index 6cd30e10faf..e61fee5586e 100644 --- a/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java +++ b/integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java @@ -80,6 +80,8 @@ private static RealmRepresentation createRealm(String name) { realm.getRoles().getRealm().add(new RoleRepresentation("admin", null, false)); realm.getRoles().getRealm().add(new RoleRepresentation("confidential", null, false)); + realm.setAccessTokenLifespan(10); + return realm; }
['integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/CustomTenantConfigResolver.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcTenantConfig.java', 'extensions/keycloak-authorization/runtime/src/main/java/io/quarkus/keycloak/pep/runtime/KeycloakPolicyEnforcerRecorder.java', 'integration-tests/oidc-tenancy/src/main/java/io/quarkus/it/keycloak/TenantResource.java', 'integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java', 'integration-tests/oidc-tenancy/src/test/java/io/quarkus/it/keycloak/KeycloakRealmResourceManager.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcAuthenticationMechanism.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java', 'extensions/oidc/deployment/src/test/java/io/quarkus/oidc/test/CustomTenantConfigResolver.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java']
{'.java': 11}
11
11
0
0
11
11,683,790
2,284,152
304,320
3,240
4,334
716
61
6
2,057
196
452
71
2
0
2020-10-22T18:26: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,918
quarkusio/quarkus/12940/12939
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12939
https://github.com/quarkusio/quarkus/pull/12940
https://github.com/quarkusio/quarkus/pull/12940
1
fixes
Wrong host forwarded after enabling proxy address forwarding
**Describe the bug** quarkus.http.proxy.proxy-address-forwarding=true When an ip like 2001:db8:85a3:8d3:1319:8a2e:370:ac is used, the parsing in vertx.http ForwardedParser breaks as it considers ac to be the port **Expected behavior** The obtained remote host address should be2001:db8:85a3:8d3:1319:8a2e:370:ac **Actual behavior** We get something like 2001:db8:85a3:8d3:1319:8a2e:370:37678 **Configuration** ```properties # Add your application.properties here, if applicable. quarkus.http.proxy.proxy-address-forwarding=true ```
c9741eafa7ee6b2f8b2919ba1869fcae2383a60c
a984bcdac1ee364472c539bed75e23a96220bba6
https://github.com/quarkusio/quarkus/compare/c9741eafa7ee6b2f8b2919ba1869fcae2383a60c...a984bcdac1ee364472c539bed75e23a96220bba6
diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/ForwardedForHeaderTest.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/ForwardedForHeaderTest.java index a58c803fd01..d06e24b4066 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/ForwardedForHeaderTest.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/ForwardedForHeaderTest.java @@ -16,23 +16,93 @@ public class ForwardedForHeaderTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() - .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addClasses(ForwardedHandlerInitializer.class) - .addAsResource(new StringAsset("quarkus.http.proxy.proxy-address-forwarding=true\\n" + - "quarkus.http.proxy.enable-forwarded-host=true\\n"), - "application.properties")); + .setArchiveProducer( + () -> ShrinkWrap.create(JavaArchive.class).addClasses(ForwardedHandlerInitializer.class) + .addAsResource( + new StringAsset("quarkus.http.proxy.proxy-address-forwarding=true\\n" + + "quarkus.http.proxy.enable-forwarded-host=true\\n"), + "application.properties")); @Test public void test() { assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); - RestAssured.given() - .header("X-Forwarded-Proto", "https") - .header("X-Forwarded-For", "backend:4444") - .header("X-Forwarded-Host", "somehost") - .get("/forward") - .then() + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "backend:4444") + .header("X-Forwarded-Host", "somehost").get("/forward").then() .body(Matchers.equalTo("https|somehost|backend:4444")); } + @Test + public void testIPV4WithPort() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "192.168.42.123:4444") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.equalTo("https|somehost|192.168.42.123:4444")); + } + + @Test + public void testIPV4NoPort() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "192.168.42.123") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.containsString("192.168.42.123")); + } + + @Test + public void testIPV6() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https") + .header("X-Forwarded-For", "2001:db8:85a3:8d3:1319:8a2e:370:12").header("X-Forwarded-Host", "somehost") + .get("/forward").then().body(Matchers.containsString("2001:db8:85a3:8d3:1319:8a2e:370:12")); + } + + @Test + public void testIPV6HexEnding() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https") + .header("X-Forwarded-For", "2001:db8:85a3:8d3:1319:8a2e:370:ac").header("X-Forwarded-Host", "somehost") + .get("/forward").then().body(Matchers.containsString("2001:db8:85a3:8d3:1319:8a2e:370:ac")); + } + + @Test + public void testIPV6Compressed() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "2001:db8:85a3::12") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.containsString("2001:db8:85a3::12")); + } + + @Test + public void testIPV6AnotherCompressed() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "2001:db8:85a3::") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.containsString("2001:db8:85a3::")); + } + + @Test + public void testIPV6WithPort() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https") + .header("X-Forwarded-For", "[2001:db8:85a3:8d3:1319:8a2e:370:ac]:101") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.containsString("[2001:db8:85a3:8d3:1319:8a2e:370:ac]:101")); + } + + @Test + public void testIPV6CompressedWithPort() { + assertThat(RestAssured.get("/forward").asString()).startsWith("http|"); + + RestAssured.given().header("X-Forwarded-Proto", "https").header("X-Forwarded-For", "[2001:db8:85a3:8d3::]:101") + .header("X-Forwarded-Host", "somehost").get("/forward").then() + .body(Matchers.containsString("[2001:db8:85a3:8d3::]:101")); + } + } diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java index 66441f2e08f..6866c013bc5 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java @@ -178,29 +178,41 @@ private void calculate() { } private void setHostAndPort(String hostToParse, int defaultPort) { - int portSeparatorIdx = hostToParse.lastIndexOf(':'); - if (portSeparatorIdx > hostToParse.lastIndexOf(']')) { - host = hostToParse.substring(0, portSeparatorIdx); - delegate.headers().set(HttpHeaders.HOST, host); - port = parsePort(hostToParse.substring(portSeparatorIdx + 1), defaultPort); - } else { - host = hostToParse; - port = -1; - } + String[] hostAndPort = parseHostAndPort(hostToParse); + host = hostAndPort[0]; + delegate.headers().set(HttpHeaders.HOST, host); + port = parsePort(hostAndPort[1], defaultPort); } private SocketAddress parseFor(String forToParse, int defaultPort) { - String host = forToParse; - int port = defaultPort; - int portSeparatorIdx = forToParse.lastIndexOf(':'); - if (portSeparatorIdx > forToParse.lastIndexOf(']')) { - host = forToParse.substring(0, portSeparatorIdx); - port = parsePort(forToParse.substring(portSeparatorIdx + 1), defaultPort); - } - + String[] hostAndPort = parseHostAndPort(forToParse); + String host = hostAndPort[0]; + int port = parsePort(hostAndPort[1], defaultPort); return new SocketAddressImpl(port, host); } + /** + * Returns a String[] of 2 elements, with the first being the host and the second the port + */ + private String[] parseHostAndPort(String hostToParse) { + String[] hostAndPort = { hostToParse, "" }; + int portSeparatorIdx = hostToParse.lastIndexOf(':'); + int squareBracketIdx = hostToParse.lastIndexOf(']'); + if ((squareBracketIdx > -1 && portSeparatorIdx > squareBracketIdx)) { + // ipv6 with port + hostAndPort[0] = hostToParse.substring(0, portSeparatorIdx); + hostAndPort[1] = hostToParse.substring(portSeparatorIdx + 1); + } else { + long numberOfColons = hostToParse.chars().filter(ch -> ch == ':').count(); + if (numberOfColons == 1 && !hostToParse.endsWith(":")) { + // ipv4 with port + hostAndPort[0] = hostToParse.substring(0, portSeparatorIdx); + hostAndPort[1] = hostToParse.substring(portSeparatorIdx + 1); + } + } + return hostAndPort; + } + private int parsePort(String portToParse, int defaultPort) { if (portToParse != null && portToParse.length() > 0) { try {
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ForwardedParser.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/ForwardedForHeaderTest.java']
{'.java': 2}
2
2
0
0
2
11,650,698
2,278,065
303,536
3,230
2,193
502
46
1
558
52
172
19
0
1
2020-10-26T10:19:09
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,901
quarkusio/quarkus/13257/13249
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13249
https://github.com/quarkusio/quarkus/pull/13257
https://github.com/quarkusio/quarkus/pull/13257
1
fixes
OIDC 1.10.0.CR1 - event loop thread blocked
**Describe the bug** Upgraded an existing app from 1.9.2.Final to 1.10.0.CR and I am getting below error ```java 2020-11-12 01:14:14,178 INFO [io.quarkus] (main) Installed features: [amazon-s3, cache, cdi, kubernetes, logging-gelf, mutiny, oidc, rest-client, resteasy, resteasy-jsonb, resteasy-mutiny, security, smallrye-context-propagation] 2020-11-12 01:17:13,262 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-0) HTTP Request to /s3/s3.html?state=ea63119a-310d-4c65-9c16-5aded25683ec&session_state=9616cbb2-8869-42e1-ad81-1964a72ee7ff&code=69ad933f-9481-45f6-b731-28960124e1f5.9616cbb2-8869-42e1-ad81-1964a72ee7ff.91b23959-4d87-4fbe-a790-69b838fbe4a0 failed, error id: 479eb3ed-e9db-49e0-a817-28a3d16c0eb0-1: java.lang.IllegalStateException: The current thread cannot be blocked: vert.x-eventloop-thread-0 at io.smallrye.mutiny.operators.UniBlockingAwait.await(UniBlockingAwait.java:29) at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:61) at io.smallrye.mutiny.groups.UniAwait.indefinitely(UniAwait.java:42) at io.quarkus.oidc.runtime.OidcIdentityProvider.verifyCodeFlowAccessToken(OidcIdentityProvider.java:243) at io.quarkus.oidc.runtime.OidcIdentityProvider.validateTokenWithOidcServer(OidcIdentityProvider.java:96) at io.quarkus.oidc.runtime.OidcIdentityProvider.authenticate(OidcIdentityProvider.java:84) at io.quarkus.oidc.runtime.OidcIdentityProvider.access$100(OidcIdentityProvider.java:37) at io.quarkus.oidc.runtime.OidcIdentityProvider$1$1.get(OidcIdentityProvider.java:71) at io.quarkus.oidc.runtime.OidcIdentityProvider$1$1.get(OidcIdentityProvider.java:59) at io.smallrye.mutiny.operators.UniCreateFromDeferredSupplier.subscribing(UniCreateFromDeferredSupplier.java:24) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:30) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$2.lambda$subscribing$0(ContextPropagationUniInterceptor.java:48) at io.smallrye.context.SmallRyeThreadContext.lambda$withContext$1(SmallRyeThreadContext.java:530) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$2.subscribing(ContextPropagationUniInterceptor.java:48) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:54) at io.smallrye.mutiny.operators.UniSerializedSubscriber.subscribe(UniSerializedSubscriber.java:49) at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:30) at io.smallrye.mutiny.operators.UniOnItemTransformToUni.handleInnerSubscription(UniOnItemTransformToUni.java:57) at io.smallrye.mutiny.operators.UniOnItemTransformToUni.invokeAndSubstitute(UniOnItemTransformToUni.java:43) at io.smallrye.mutiny.operators.UniOnItemTransformToUni$2.onItem(UniOnItemTransformToUni.java:74) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$1.lambda$onItem$1(ContextPropagationUniInterceptor.java:32) at io.smallrye.context.SmallRyeThreadContext.lambda$withContext$1(SmallRyeThreadContext.java:530) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$1.onItem(ContextPropagationUniInterceptor.java:32) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$1.lambda$onItem$1(ContextPropagationUniInterceptor.java:32) at io.smallrye.context.SmallRyeThreadContext.lambda$withContext$1(SmallRyeThreadContext.java:530) at io.smallrye.mutiny.context.ContextPropagationUniInterceptor$1.onItem(ContextPropagationUniInterceptor.java:32) at io.smallrye.mutiny.operators.UniSerializedSubscriber.onItem(UniSerializedSubscriber.java:86) ``` **Expected behavior** OIDC hybrid auth should work **Actual behavior** Getting the above stacktrace **Configuration** ```properties quarkus.oidc.auth-server-url=http://keycloak.com quarkus.oidc.client-id=backend quarkus.oidc.credentials.secret=71234b quarkus.oidc.application-type=hybrid quarkus.oidc.roles.source=accesstoken quarkus.oidc.roles.role-claim-path=scope quarkus.http.auth.permission.authenticated.paths=/* quarkus.http.auth.permission.authenticated.policy=authenticated ``` **Environment (please complete the following information):** - Output of `uname -a` or `ver`: mac os & Linux - Output of `java -version`: Java 11 - GraalVM version (if different from Java): NA - Quarkus version or git rev: 1.10.0.CR1 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): mvnw **Additional context** @sberyozkin Let me know if you need any additional details
c7695bd2222e22c39ed6773205e7dc4d3710f67b
4a2afc076575abaac486c5d23b698b2e6d8594ef
https://github.com/quarkusio/quarkus/compare/c7695bd2222e22c39ed6773205e7dc4d3710f67b...4a2afc076575abaac486c5d23b698b2e6d8594ef
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java index b146aadb1f3..a0a8a361268 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java @@ -1,5 +1,7 @@ package io.quarkus.oidc.runtime; +import java.util.concurrent.Executor; + import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Event; @@ -160,4 +162,8 @@ private Uni<TenantConfigContext> getDynamicTenantContext(RoutingContext context) boolean isEnableHttpForwardedPrefix() { return enableHttpForwardedPrefix; } + + public Executor getBlockingExecutor() { + return tenantConfigBean.getBlockingExecutor(); + } } diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java index 7112becb340..07fa6ff9bf0 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java @@ -15,6 +15,7 @@ import io.quarkus.oidc.OidcTenantConfig; import io.quarkus.oidc.OidcTenantConfig.Roles.Source; import io.quarkus.oidc.OidcTokenCredential; +import io.quarkus.runtime.BlockingOperationControl; import io.quarkus.security.AuthenticationFailedException; import io.quarkus.security.credential.TokenCredential; import io.quarkus.security.identity.AuthenticationRequestContext; @@ -35,6 +36,12 @@ @ApplicationScoped public class OidcIdentityProvider implements IdentityProvider<TokenAuthenticationRequest> { + + @SuppressWarnings("deprecation") + private static final Uni<AccessToken> NULL_CODE_ACCESS_TOKEN_UNI = Uni.createFrom().nullItem(); + private static final Uni<JsonObject> NULL_USER_INFO_UNI = Uni.createFrom().nullItem(); + private static final String CODE_ACCESS_TOKEN_RESULT = "code_flow_access_token_result"; + @Inject DefaultTenantConfigResolver tenantResolver; @@ -81,101 +88,153 @@ private Uni<SecurityIdentity> authenticate(TokenAuthenticationRequest request, if (resolvedContext.oidcConfig.publicKey.isPresent()) { return validateTokenWithoutOidcServer(request, resolvedContext); } else { - return validateTokenWithOidcServer(vertxContext, request, resolvedContext); + return validateAllTokensWithOidcServer(vertxContext, request, resolvedContext); } } @SuppressWarnings("deprecation") - private Uni<SecurityIdentity> validateTokenWithOidcServer(RoutingContext vertxContext, TokenAuthenticationRequest request, + private Uni<SecurityIdentity> validateAllTokensWithOidcServer(RoutingContext vertxContext, + TokenAuthenticationRequest request, TenantConfigContext resolvedContext) { - if (request.getToken() instanceof IdTokenCredential - && (resolvedContext.oidcConfig.authentication.verifyAccessToken - || resolvedContext.oidcConfig.roles.source.orElse(null) == Source.accesstoken)) { - vertxContext.put("code_flow_access_token_result", - verifyCodeFlowAccessToken(vertxContext, request, resolvedContext)); - } + Uni<AccessToken> codeAccessTokenUni = verifyCodeFlowAccessTokenUni(vertxContext, request, resolvedContext); - final JsonObject userInfo = resolvedContext.oidcConfig.authentication.isUserInfoRequired() - ? getUserInfo(vertxContext, request, resolvedContext) - : null; + return codeAccessTokenUni.onItem().transformToUni( + new Function<AccessToken, Uni<? extends SecurityIdentity>>() { + @Override + public Uni<SecurityIdentity> apply(AccessToken codeAccessToken) { + return validateTokenWithOidcServer(vertxContext, request, resolvedContext, codeAccessToken); + } + }); + } - return Uni.createFrom().emitter(new Consumer<UniEmitter<? super SecurityIdentity>>() { - @Override - public void accept(UniEmitter<? super SecurityIdentity> uniEmitter) { + @SuppressWarnings("deprecation") + private Uni<SecurityIdentity> validateTokenWithOidcServer(RoutingContext vertxContext, TokenAuthenticationRequest request, + TenantConfigContext resolvedContext, AccessToken codeAccessToken) { - resolvedContext.auth.decodeToken(request.getToken().getToken(), - new Handler<AsyncResult<AccessToken>>() { - @Override - public void handle(AsyncResult<AccessToken> event) { - if (event.failed()) { - uniEmitter.fail(new AuthenticationFailedException(event.cause())); - return; - } + if (codeAccessToken != null) { + vertxContext.put(CODE_ACCESS_TOKEN_RESULT, codeAccessToken); + } - // Token has been verified, as a JWT or an opaque token, possibly involving - // an introspection request. - final TokenCredential tokenCred = request.getToken(); + Uni<JsonObject> userInfo = getUserInfoUni(vertxContext, request, resolvedContext); - JsonObject tokenJson = event.result().accessToken(); + return userInfo.onItem().transformToUni( + new Function<JsonObject, Uni<? extends SecurityIdentity>>() { + @Override + public Uni<SecurityIdentity> apply(JsonObject userInfo) { + return createSecurityIdentityWithOidcServerUni(vertxContext, request, resolvedContext, userInfo); + } + }); + } - if (tokenJson == null) { - // JSON token representation may be null not only if it is an opaque access token - // but also if it is JWT and no JWK with a matching kid is available, asynchronous - // JWK refresh has not finished yet, but the fallback introspection request has succeeded. - tokenJson = OidcUtils.decodeJwtContent(tokenCred.getToken()); - } - if (tokenJson != null) { - OidcUtils.validatePrimaryJwtTokenType(resolvedContext.oidcConfig.token, tokenJson); - JsonObject rolesJson = getRolesJson(vertxContext, resolvedContext, tokenCred, tokenJson, - userInfo); - try { - SecurityIdentity securityIdentity = validateAndCreateIdentity(vertxContext, tokenCred, - resolvedContext.oidcConfig, - tokenJson, rolesJson, userInfo); - if (tokenAutoRefreshPrepared(tokenJson, vertxContext, resolvedContext.oidcConfig)) { - throw new TokenAutoRefreshException(securityIdentity); - } else { - uniEmitter.complete(securityIdentity); - } - } catch (Throwable ex) { - uniEmitter.fail(ex); + private Uni<SecurityIdentity> createSecurityIdentityWithOidcServerUni(RoutingContext vertxContext, + TokenAuthenticationRequest request, TenantConfigContext resolvedContext, final JsonObject userInfo) { + + final TokenCredential tokenCred = request.getToken(); + if (tokenCred instanceof AccessTokenCredential && ((AccessTokenCredential) tokenCred).isOpaque()) { + // remote introspection is required, a blocking call + return Uni.createFrom().emitter( + new Consumer<UniEmitter<? super SecurityIdentity>>() { + @Override + public void accept(UniEmitter<? super SecurityIdentity> uniEmitter) { + if (BlockingOperationControl.isBlockingAllowed()) { + createSecurityIdentityWithOidcServer(uniEmitter, vertxContext, request, resolvedContext, + userInfo); + } else { + tenantResolver.getBlockingExecutor().execute(new Runnable() { + @Override + public void run() { + createSecurityIdentityWithOidcServer(uniEmitter, vertxContext, request, resolvedContext, + userInfo); } - } else if (tokenCred instanceof IdTokenCredential - || tokenCred instanceof AccessTokenCredential - && !((AccessTokenCredential) tokenCred).isOpaque()) { - uniEmitter - .fail(new AuthenticationFailedException("JWT token can not be converted to JSON")); + }); + } + } + }); + } else { + return Uni.createFrom().emitter(new Consumer<UniEmitter<? super SecurityIdentity>>() { + @Override + public void accept(UniEmitter<? super SecurityIdentity> uniEmitter) { + createSecurityIdentityWithOidcServer(uniEmitter, vertxContext, request, resolvedContext, userInfo); + } + }); + } + } + + @SuppressWarnings("deprecation") + private void createSecurityIdentityWithOidcServer(UniEmitter<? super SecurityIdentity> uniEmitter, + RoutingContext vertxContext, + TokenAuthenticationRequest request, TenantConfigContext resolvedContext, final JsonObject userInfo) { + resolvedContext.auth.decodeToken(request.getToken().getToken(), + new Handler<AsyncResult<AccessToken>>() { + @Override + public void handle(AsyncResult<AccessToken> event) { + if (event.failed()) { + uniEmitter.fail(new AuthenticationFailedException(event.cause())); + return; + } + + // Token has been verified, as a JWT or an opaque token, possibly involving + // an introspection request. + final TokenCredential tokenCred = request.getToken(); + + JsonObject tokenJson = event.result().accessToken(); + + if (tokenJson == null) { + // JSON token representation may be null not only if it is an opaque access token + // but also if it is JWT and no JWK with a matching kid is available, asynchronous + // JWK refresh has not finished yet, but the fallback introspection request has succeeded. + tokenJson = OidcUtils.decodeJwtContent(tokenCred.getToken()); + } + if (tokenJson != null) { + OidcUtils.validatePrimaryJwtTokenType(resolvedContext.oidcConfig.token, tokenJson); + JsonObject rolesJson = getRolesJson(vertxContext, resolvedContext, tokenCred, tokenJson, + userInfo); + try { + SecurityIdentity securityIdentity = validateAndCreateIdentity(vertxContext, tokenCred, + resolvedContext.oidcConfig, + tokenJson, rolesJson, userInfo); + if (tokenAutoRefreshPrepared(tokenJson, vertxContext, resolvedContext.oidcConfig)) { + uniEmitter.fail(new TokenAutoRefreshException(securityIdentity)); } else { - // Opaque Bearer Access Token - QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(); - builder.addCredential(tokenCred); - OidcUtils.setSecurityIdentityUserInfo(builder, userInfo); - if (event.result().principal().containsKey("username")) { - final String userName = event.result().principal().getString("username"); - builder.setPrincipal(new Principal() { - @Override - public String getName() { - return userName; - } - }); - } - if (event.result().principal().containsKey("scope")) { - for (String role : event.result().principal().getString("scope").split(" ")) { - builder.addRole(role.trim()); - } - } - if (userInfo != null) { - OidcUtils.setSecurityIdentityRoles(builder, resolvedContext.oidcConfig, userInfo); + uniEmitter.complete(securityIdentity); + } + } catch (Throwable ex) { + uniEmitter.fail(ex); + } + } else if (tokenCred instanceof IdTokenCredential + || tokenCred instanceof AccessTokenCredential + && !((AccessTokenCredential) tokenCred).isOpaque()) { + uniEmitter + .fail(new AuthenticationFailedException("JWT token can not be converted to JSON")); + } else { + // Opaque Bearer Access Token + QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(); + builder.addCredential(tokenCred); + OidcUtils.setSecurityIdentityUserInfo(builder, userInfo); + if (event.result().principal().containsKey("username")) { + final String userName = event.result().principal().getString("username"); + builder.setPrincipal(new Principal() { + @Override + public String getName() { + return userName; } - OidcUtils.setBlockinApiAttribute(builder, vertxContext); - OidcUtils.setTenantIdAttribute(builder, resolvedContext.oidcConfig); - uniEmitter.complete(builder.build()); + }); + } + if (event.result().principal().containsKey("scope")) { + for (String role : event.result().principal().getString("scope").split(" ")) { + builder.addRole(role.trim()); } } - }); - } - }); + if (userInfo != null) { + OidcUtils.setSecurityIdentityRoles(builder, resolvedContext.oidcConfig, userInfo); + } + OidcUtils.setBlockinApiAttribute(builder, vertxContext); + OidcUtils.setTenantIdAttribute(builder, resolvedContext.oidcConfig); + uniEmitter.complete(builder.build()); + } + } + }); } private static boolean tokenAutoRefreshPrepared(JsonObject tokenJson, RoutingContext vertxContext, @@ -206,8 +265,8 @@ private static JsonObject getRolesJson(RoutingContext vertxContext, TenantConfig rolesJson = userInfo; } else if (tokenCred instanceof IdTokenCredential && resolvedContext.oidcConfig.roles.source.get() == Source.accesstoken) { - AccessToken result = (AccessToken) vertxContext.get("code_flow_access_token_result"); - rolesJson = result.accessToken(); + AccessToken result = (AccessToken) vertxContext.get(CODE_ACCESS_TOKEN_RESULT); + rolesJson = result != null ? result.accessToken() : null; if (rolesJson == null) { // JSON token representation may be null not only if it is an opaque access token // but also if it is JWT and no JWK with a matching kid is available, asynchronous @@ -224,23 +283,56 @@ private static JsonObject getRolesJson(RoutingContext vertxContext, TenantConfig } @SuppressWarnings("deprecation") - private static AccessToken verifyCodeFlowAccessToken(RoutingContext vertxContext, TokenAuthenticationRequest request, + private Uni<AccessToken> verifyCodeFlowAccessTokenUni(RoutingContext vertxContext, TokenAuthenticationRequest request, TenantConfigContext resolvedContext) { - return Uni.createFrom().emitter(new Consumer<UniEmitter<? super AccessToken>>() { - @Override - public void accept(UniEmitter<? super AccessToken> uniEmitter) { - resolvedContext.auth.decodeToken((String) vertxContext.get("access_token"), - new Handler<AsyncResult<AccessToken>>() { + if (request.getToken() instanceof IdTokenCredential + && (resolvedContext.oidcConfig.authentication.verifyAccessToken + || resolvedContext.oidcConfig.roles.source.orElse(null) == Source.accesstoken)) { + final String codeAccessToken = (String) vertxContext.get("access_token"); + if (OidcUtils.isOpaqueToken(codeAccessToken)) { + // remote introspection is required, a blocking call + return Uni.createFrom().emitter( + new Consumer<UniEmitter<? super AccessToken>>() { @Override - public void handle(AsyncResult<AccessToken> event) { - if (event.failed()) { - uniEmitter.fail(new AuthenticationFailedException(event.cause())); + public void accept(UniEmitter<? super AccessToken> uniEmitter) { + if (BlockingOperationControl.isBlockingAllowed()) { + verifyCodeFlowAccessToken(uniEmitter, resolvedContext, codeAccessToken); + } else { + tenantResolver.getBlockingExecutor().execute(new Runnable() { + @Override + public void run() { + verifyCodeFlowAccessToken(uniEmitter, resolvedContext, codeAccessToken); + } + }); } - uniEmitter.complete(event.result()); } }); + } else { + return Uni.createFrom().emitter(new Consumer<UniEmitter<? super AccessToken>>() { + @Override + public void accept(UniEmitter<? super AccessToken> uniEmitter) { + verifyCodeFlowAccessToken(uniEmitter, resolvedContext, codeAccessToken); + } + }); } - }).await().indefinitely(); + } else { + return NULL_CODE_ACCESS_TOKEN_UNI; + } + } + + @SuppressWarnings("deprecation") + private void verifyCodeFlowAccessToken(UniEmitter<? super AccessToken> uniEmitter, + TenantConfigContext resolvedContext, String codeAccessToken) { + resolvedContext.auth.decodeToken(codeAccessToken, + new Handler<AsyncResult<AccessToken>>() { + @Override + public void handle(AsyncResult<AccessToken> event) { + if (event.failed()) { + uniEmitter.fail(new AuthenticationFailedException(event.cause())); + } + uniEmitter.complete(event.result()); + } + }); } private static Uni<SecurityIdentity> validateTokenWithoutOidcServer(TokenAuthenticationRequest request, @@ -266,33 +358,51 @@ private static Uni<SecurityIdentity> validateTokenWithoutOidcServer(TokenAuthent } } - private static JsonObject getUserInfo(RoutingContext vertxContext, TokenAuthenticationRequest request, + private Uni<JsonObject> getUserInfoUni(RoutingContext vertxContext, TokenAuthenticationRequest request, TenantConfigContext resolvedContext) { + if (resolvedContext.oidcConfig.authentication.isUserInfoRequired()) { + return Uni.createFrom().emitter( + new Consumer<UniEmitter<? super JsonObject>>() { + @Override + public void accept(UniEmitter<? super JsonObject> uniEmitter) { + if (BlockingOperationControl.isBlockingAllowed()) { + createUserInfoToken(uniEmitter, vertxContext, request, resolvedContext); + } else { + tenantResolver.getBlockingExecutor().execute(new Runnable() { + @Override + public void run() { + createUserInfoToken(uniEmitter, vertxContext, request, resolvedContext); + } + }); + } + } + }); + } else { + return NULL_USER_INFO_UNI; + } + } + + private void createUserInfoToken(UniEmitter<? super JsonObject> uniEmitter, RoutingContext vertxContext, + TokenAuthenticationRequest request, TenantConfigContext resolvedContext) { OAuth2TokenImpl tokenImpl = new OAuth2TokenImpl(resolvedContext.auth, new JsonObject()); String accessToken = vertxContext.get("access_token"); if (accessToken == null) { accessToken = request.getToken().getToken(); } tokenImpl.principal().put("access_token", accessToken); - return Uni.createFrom().emitter( - new Consumer<UniEmitter<? super JsonObject>>() { - @Override - public void accept(UniEmitter<? super JsonObject> uniEmitter) { - tokenImpl.userInfo(new Handler<AsyncResult<JsonObject>>() { - @Override - public void handle(AsyncResult<JsonObject> event) { - if (event.failed()) { - uniEmitter.fail(new AuthenticationFailedException(event.cause())); - } else { - uniEmitter.complete(event.result()); - } - } - }); - } - }).await().indefinitely(); + tokenImpl.userInfo(new Handler<AsyncResult<JsonObject>>() { + @Override + public void handle(AsyncResult<JsonObject> event) { + if (event.failed()) { + uniEmitter.fail(new AuthenticationFailedException(event.cause())); + } else { + uniEmitter.complete(event.result()); + } + } + }); } private static boolean isTenantBlocking(TenantConfigContext resolvedContext) { - return resolvedContext.oidcConfig.token.refreshExpired || resolvedContext.oidcConfig.authentication.userInfoRequired; + return resolvedContext.oidcConfig.token.refreshExpired; } } 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 c9939db7ae1..23c4c2c6a56 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 @@ -68,42 +68,42 @@ public TenantConfigBean get() { new Function<OidcTenantConfig, Uni<TenantConfigContext>>() { @Override public Uni<TenantConfigContext> apply(OidcTenantConfig config) { - if (BlockingOperationControl.isBlockingAllowed()) { - try { - return Uni.createFrom().item(createDynamicTenantContext(vertxValue, config, - config.getTenantId().get())); - } catch (Throwable t) { - return Uni.createFrom().failure(t); - } - } else { - return Uni.createFrom().emitter(new Consumer<UniEmitter<? super TenantConfigContext>>() { - @Override - public void accept(UniEmitter<? super TenantConfigContext> uniEmitter) { + + return Uni.createFrom().emitter(new Consumer<UniEmitter<? super TenantConfigContext>>() { + @Override + public void accept(UniEmitter<? super TenantConfigContext> uniEmitter) { + if (BlockingOperationControl.isBlockingAllowed()) { + createDynamicTenantContext(uniEmitter, vertxValue, config, + config.getTenantId().get()); + } else { ExecutorRecorder.getCurrent().execute(new Runnable() { @Override public void run() { - try { - uniEmitter.complete(createDynamicTenantContext(vertxValue, config, - config.getTenantId().get())); - } catch (Throwable t) { - uniEmitter.fail(t); - } + createDynamicTenantContext(uniEmitter, vertxValue, config, + config.getTenantId().get()); } }); } - }); - } + } + }); + } - }); + }, + ExecutorRecorder.getCurrent()); } }; } - private TenantConfigContext createDynamicTenantContext(Vertx vertx, OidcTenantConfig oidcConfig, String tenantId) { - if (!dynamicTenantsConfig.containsKey(tenantId)) { - dynamicTenantsConfig.putIfAbsent(tenantId, createTenantContext(vertx, oidcConfig, tenantId)); + private void createDynamicTenantContext(UniEmitter<? super TenantConfigContext> uniEmitter, Vertx vertx, + OidcTenantConfig oidcConfig, String tenantId) { + try { + if (!dynamicTenantsConfig.containsKey(tenantId)) { + dynamicTenantsConfig.putIfAbsent(tenantId, createTenantContext(vertx, oidcConfig, tenantId)); + } + uniEmitter.complete(dynamicTenantsConfig.get(tenantId)); + } catch (Throwable t) { + uniEmitter.fail(t); } - return dynamicTenantsConfig.get(tenantId); } private TenantConfigContext createTenantContext(Vertx vertx, OidcTenantConfig oidcConfig, String tenantId) { diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/TenantConfigBean.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/TenantConfigBean.java index 47f83de514e..b3a5973c0cb 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/TenantConfigBean.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/TenantConfigBean.java @@ -1,6 +1,7 @@ package io.quarkus.oidc.runtime; import java.util.Map; +import java.util.concurrent.Executor; import java.util.function.Function; import io.quarkus.oidc.OidcTenantConfig; @@ -12,16 +13,19 @@ public class TenantConfigBean { private final Map<String, TenantConfigContext> dynamicTenantsConfig; private final TenantConfigContext defaultTenant; private final Function<OidcTenantConfig, Uni<TenantConfigContext>> tenantConfigContextFactory; + private final Executor blockingExecutor; public TenantConfigBean( Map<String, TenantConfigContext> staticTenantsConfig, Map<String, TenantConfigContext> dynamicTenantsConfig, TenantConfigContext defaultTenant, - Function<OidcTenantConfig, Uni<TenantConfigContext>> tenantConfigContextFactory) { + Function<OidcTenantConfig, Uni<TenantConfigContext>> tenantConfigContextFactory, + Executor blockingExecutor) { this.staticTenantsConfig = staticTenantsConfig; this.dynamicTenantsConfig = dynamicTenantsConfig; this.defaultTenant = defaultTenant; this.tenantConfigContextFactory = tenantConfigContextFactory; + this.blockingExecutor = blockingExecutor; } public Map<String, TenantConfigContext> getStaticTenantsConfig() { @@ -39,4 +43,8 @@ public Function<OidcTenantConfig, Uni<TenantConfigContext>> getTenantConfigConte public Map<String, TenantConfigContext> getDynamicTenantsConfig() { return dynamicTenantsConfig; } + + public Executor getBlockingExecutor() { + return blockingExecutor; + } }
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/TenantConfigBean.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/DefaultTenantConfigResolver.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcRecorder.java']
{'.java': 4}
4
4
0
0
4
11,818,658
2,310,132
307,392
3,278
25,244
3,744
392
4
4,790
207
1,355
68
1
2
2020-11-12T13:39:15
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,902
quarkusio/quarkus/13245/13236
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13236
https://github.com/quarkusio/quarkus/pull/13245
https://github.com/quarkusio/quarkus/pull/13245
1
fixes
wrong initialisation order of mongo codec providers
**Describe the bug** It is impossible to override standard coders, `MongoClients.createMongoConfiguration()` uses `defaultCodecRegistry` before custom `CodecProvider`: ```java CodecRegistry registry = CodecRegistries.fromRegistries(defaultCodecRegistry, CodecRegistries.fromProviders(providers)); settings.codecRegistry(registry); ``` **Expected behavior** Custom providers should be used at the first place: ```java CodecRegistry registry = CodecRegistries.fromRegistries(CodecRegistries.fromProviders(providers), defaultCodecRegistry); ``` this is also recommended by mongodb-team [Codec and CodecRegistry](https://mongodb.github.io/mongo-java-driver/3.6/bson/codecs/): ```java CodecRegistry defaultCodecRegistry = ... DocumentCodecProvider documentCodecProvider = ... Codec<Instant> instantCodec = ... codecRegistry = CodecRegistries.fromRegistries(CodecRegistries.fromCodecs(instantCodec), CodecRegistries.fromProviders(documentCodecProvider), defaultCodecRegistry); ``` **Actual behavior** codecs registry is initialized with default codes at the first place and this will not allow to override them. reading of the `BigDecimal` value will not use a custom `Codec` and will fail with the message: ``` Caused by: org.bson.BsonInvalidOperationException: readDecimal can only be called when CurrentBSONType is DECIMAL128, not when CurrentBSONType is STRING. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:690) at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:722) at org.bson.AbstractBsonReader.readDecimal128(AbstractBsonReader.java:380) at org.bson.codecs.BigDecimalCodec.decode(BigDecimalCodec.java:39) at org.bson.codecs.BigDecimalCodec.decode(BigDecimalCodec.java:30) at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:96) at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:219) ... 106 more ``` **To Reproduce** Please check this repository [quarkus-mongo-bug](https://github.com/oxelad/quarkus-mongo-bug.git) Steps to reproduce the behavior: run tests: `mvn clean verify` ; integration tests will fail. **Environment (please complete the following information):** - Output of `uname -a` or `ver`: `Darwin Kernel Version 19.6.0` - Output of `java -version`: `java version "11.0.9" 2020-10-20 LTS` - Build tool (ie. output of `mvnw --version` or `gradlew --version`): `Apache Maven 3.6.3`
78a5e302c9cc6f2cbdd817ed5ed7e91de9cd9fa2
566aae929c7ceb309f2f67f6b11c2cc2f8243ea3
https://github.com/quarkusio/quarkus/compare/78a5e302c9cc6f2cbdd817ed5ed7e91de9cd9fa2...566aae929c7ceb309f2f67f6b11c2cc2f8243ea3
diff --git a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java index 68b720924a6..a1f7f7a396d 100644 --- a/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java +++ b/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java @@ -4,6 +4,8 @@ import static com.mongodb.AuthenticationMechanism.MONGODB_X509; import static com.mongodb.AuthenticationMechanism.PLAIN; import static com.mongodb.AuthenticationMechanism.SCRAM_SHA_1; +import static org.bson.codecs.configuration.CodecRegistries.fromProviders; +import static org.bson.codecs.configuration.CodecRegistries.fromRegistries; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -21,7 +23,6 @@ import javax.inject.Singleton; import org.bson.codecs.configuration.CodecProvider; -import org.bson.codecs.configuration.CodecRegistries; import org.bson.codecs.configuration.CodecRegistry; import org.bson.codecs.pojo.ClassModel; import org.bson.codecs.pojo.Conventions; @@ -226,35 +227,7 @@ private MongoClientSettings createMongoConfiguration(MongoClientConfig config) { settings.applyConnectionString(connectionString); } - List<CodecProvider> providers = new ArrayList<>(); - if (!mongoClientSupport.getCodecProviders().isEmpty()) { - providers.addAll(getCodecProviders(mongoClientSupport.getCodecProviders())); - } - // add pojo codec provider with automatic capabilities - // it always needs to be the last codec provided - PojoCodecProvider.Builder pojoCodecProviderBuilder = PojoCodecProvider.builder() - .automatic(true) - .conventions(Conventions.DEFAULT_CONVENTIONS); - // register bson discriminators - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - for (String bsonDiscriminator : mongoClientSupport.getBsonDiscriminators()) { - try { - pojoCodecProviderBuilder - .register(ClassModel.builder(Class.forName(bsonDiscriminator, true, classLoader)) - .enableDiscriminator(true).build()); - } catch (ClassNotFoundException e) { - // Ignore - } - } - // register property codec provider - if (!mongoClientSupport.getPropertyCodecProviders().isEmpty()) { - pojoCodecProviderBuilder.register(getPropertyCodecProviders(mongoClientSupport.getPropertyCodecProviders()) - .toArray(new PropertyCodecProvider[0])); - } - providers.add(pojoCodecProviderBuilder.build()); - CodecRegistry registry = CodecRegistries.fromRegistries(defaultCodecRegistry, - CodecRegistries.fromProviders(providers)); - settings.codecRegistry(registry); + configureCodecRegistry(defaultCodecRegistry, settings); settings.commandListenerList(getCommandListeners(mongoClientSupport.getCommandListeners())); @@ -299,6 +272,38 @@ private MongoClientSettings createMongoConfiguration(MongoClientConfig config) { return settings.build(); } + private void configureCodecRegistry(CodecRegistry defaultCodecRegistry, MongoClientSettings.Builder settings) { + List<CodecProvider> providers = new ArrayList<>(); + if (!mongoClientSupport.getCodecProviders().isEmpty()) { + providers.addAll(getCodecProviders(mongoClientSupport.getCodecProviders())); + } + // add pojo codec provider with automatic capabilities + // it always needs to be the last codec provided + PojoCodecProvider.Builder pojoCodecProviderBuilder = PojoCodecProvider.builder() + .automatic(true) + .conventions(Conventions.DEFAULT_CONVENTIONS); + // register bson discriminators + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + for (String bsonDiscriminator : mongoClientSupport.getBsonDiscriminators()) { + try { + pojoCodecProviderBuilder + .register(ClassModel.builder(Class.forName(bsonDiscriminator, true, classLoader)) + .enableDiscriminator(true).build()); + } catch (ClassNotFoundException e) { + // Ignore + } + } + // register property codec provider + if (!mongoClientSupport.getPropertyCodecProviders().isEmpty()) { + pojoCodecProviderBuilder.register(getPropertyCodecProviders(mongoClientSupport.getPropertyCodecProviders()) + .toArray(new PropertyCodecProvider[0])); + } + CodecRegistry registry = !providers.isEmpty() ? fromRegistries(fromProviders(providers), defaultCodecRegistry, + fromProviders(pojoCodecProviderBuilder.build())) + : fromRegistries(defaultCodecRegistry, fromProviders(pojoCodecProviderBuilder.build())); + settings.codecRegistry(registry); + } + private static List<ServerAddress> parseHosts(List<String> addresses) { if (addresses.isEmpty()) { return Collections.singletonList(new ServerAddress(ServerAddress.defaultHost(), ServerAddress.defaultPort()));
['extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/MongoClients.java']
{'.java': 1}
1
1
0
0
1
11,864,301
2,319,394
308,548
3,280
3,785
661
65
1
2,600
207
596
48
2
4
2020-11-11T21:17: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,904
quarkusio/quarkus/13226/13186
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13186
https://github.com/quarkusio/quarkus/pull/13226
https://github.com/quarkusio/quarkus/pull/13226
1
fixes
Qute: type-safe expressions - fix the template extension method matching algorithm
For example, if there is an expression `{item.discountedPrice}` a template extension method like this: ```java @TemplateExtension static BigDecimal discountedPrice(Item item, int discount) { ... } ``` matches the expression even if the number of parameters does not match. The expected behavior: build fails. It does not match the expression `{item.discountedPrice()}` though (the correct behavior).
2613770eeca81350a238188af165116baac3588a
a4d1fe9f13637cd46eec5029f631984742aaa4f5
https://github.com/quarkusio/quarkus/compare/2613770eeca81350a238188af165116baac3588a...a4d1fe9f13637cd46eec5029f631984742aaa4f5
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 3ee1e50f8c0..b0ff69992ad 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 @@ -1141,11 +1141,15 @@ private static AnnotationTarget findTemplateExtensionMethod(Info info, ClassInfo // Name does not match continue; } + List<Type> parameters = extensionMethod.getMethod().parameters(); + if (parameters.size() > 1 && !info.isVirtualMethod()) { + // If method accepts additional params the info must be a virtual method + continue; + } if (info.isVirtualMethod()) { // For virtual method validate the number of params and attempt to validate the parameter types if available VirtualMethodPart virtualMethod = info.part.asVirtualMethod(); boolean isVarArgs = ValueResolverGenerator.isVarArgs(extensionMethod.getMethod()); - List<Type> parameters = extensionMethod.getMethod().parameters(); int lastParamIdx = parameters.size() - 1; int realParamSize = parameters.size() - (TemplateExtension.ANY.equals(extensionMethod.getMatchName()) ? 2 : 1); diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java index 9aa457b5a19..df3911f9018 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java @@ -32,7 +32,9 @@ public class ValidationFailuresTest { + "{movie.findServices(age,name)}" // Name and number of params ok for extension method; the parameter type does not match + "{movie.toNumber(age)}" - + "{#each movie.mainCharacters}{it.boom(1)}{/}"), + + "{#each movie.mainCharacters}{it.boom(1)}{/}" + // Template extension method must accept one param + + "{movie.toNumber}"), "templates/movie.html")) .assertException(t -> { Throwable e = t; @@ -45,7 +47,7 @@ public class ValidationFailuresTest { e = e.getCause(); } assertNotNull(te); - assertTrue(te.getMessage().contains("Found template problems (7)"), te.getMessage()); + assertTrue(te.getMessage().contains("Found template problems (8)"), te.getMessage()); assertTrue(te.getMessage().contains("movie.foo"), te.getMessage()); assertTrue(te.getMessage().contains("movie.getName('foo')"), te.getMessage()); assertTrue(te.getMessage().contains("movie.findService(age)"), te.getMessage()); @@ -53,6 +55,7 @@ public class ValidationFailuresTest { assertTrue(te.getMessage().contains("movie.findServices(age,name)"), te.getMessage()); assertTrue(te.getMessage().contains("movie.toNumber(age)"), te.getMessage()); assertTrue(te.getMessage().contains("it.boom(1)"), te.getMessage()); + assertTrue(te.getMessage().contains("movie.toNumber"), te.getMessage()); }); @Test
['extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/typesafe/ValidationFailuresTest.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java']
{'.java': 2}
2
2
0
0
2
11,856,897
2,317,857
308,406
3,280
362
61
6
1
408
54
83
8
0
1
2020-11-11T08:49: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,905
quarkusio/quarkus/13207/12896
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12896
https://github.com/quarkusio/quarkus/pull/13207
https://github.com/quarkusio/quarkus/pull/13207
1
fixes
CDI: programmatic lookup problem detected - Nayarana - 1.9.0.Final
**Describe the bug** A warning message is printed when using `@Transactional` in 1.9.0.Final **Expected behavior** No warning message should show up. **Actual behavior** This message on startup is shown: ``` CDI: programmatic lookup problem detected ----------------------------------------- At least one bean matched the required type and qualifiers but was marked as unused and removed during build Removed beans: - PRODUCER_METHOD bean io.quarkus.narayana.jta.runtime.NarayanaJtaProducers#userTransaction() [types=[interface javax.transaction.UserTransaction], qualifiers=[@javax.enterprise.inject.Default(), @javax.enterprise.inject.Any()]] Required type: interface javax.transaction.UserTransaction Required qualifiers: [@javax.enterprise.inject.Default()] ``` **To Reproduce** Create any project using `@Transactional` annotation in some bean. Then just package and startup application. **Configuration** **Screenshots** **Environment (please complete the following information):** - Output of `uname -a` or `ver`: - Output of `java -version`: JDK 11 - GraalVM version (if different from Java): - Quarkus version or git rev: 1.9.0.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): **Additional context** Related to https://github.com/quarkusio/quarkus/issues/12420
53a87840a6065a6d43c97c63cd26e6e404e75118
cc04d50b733af3d077d47d062c699d3bdaf28793
https://github.com/quarkusio/quarkus/compare/53a87840a6065a6d43c97c63cd26e6e404e75118...cc04d50b733af3d077d47d062c699d3bdaf28793
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 b51588818b6..c8d8f5e6701 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 @@ -43,8 +43,6 @@ import com.cronutils.model.definition.CronDefinitionBuilder; import com.cronutils.parser.CronParser; -import io.quarkus.arc.Arc; -import io.quarkus.arc.InstanceHandle; import io.quarkus.runtime.StartupEvent; import io.quarkus.scheduler.Scheduled; import io.quarkus.scheduler.Scheduled.ConcurrentExecution; @@ -79,7 +77,8 @@ org.quartz.Scheduler produceQuartzScheduler() { } public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Config config, - SchedulerRuntimeConfig schedulerRuntimeConfig, Event<SkippedExecution> skippedExecutionEvent, Instance<Job> jobs) { + SchedulerRuntimeConfig schedulerRuntimeConfig, Event<SkippedExecution> skippedExecutionEvent, Instance<Job> jobs, + Instance<UserTransaction> userTransation) { enabled = schedulerRuntimeConfig.enabled; if (!enabled) { LOGGER.info("Quartz scheduler is disabled by config property and will not be started"); @@ -92,10 +91,10 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Co Map<String, ScheduledInvoker> invokers = new HashMap<>(); UserTransaction transaction = null; - try (InstanceHandle<UserTransaction> handle = Arc.container().instance(UserTransaction.class)) { + try { boolean manageTx = quartzSupport.getBuildTimeConfig().storeType.isNonManagedTxJobStore(); - if (manageTx && handle.isAvailable()) { - transaction = handle.get(); + if (manageTx && userTransation.isResolvable()) { + transaction = userTransation.get(); } Properties props = getSchedulerConfigurationProperties(quartzSupport);
['extensions/quartz/runtime/src/main/java/io/quarkus/quartz/runtime/QuartzScheduler.java']
{'.java': 1}
1
1
0
0
1
11,849,629
2,316,148
308,188
3,275
737
138
11
1
1,352
142
305
37
1
1
2020-11-10T08:24:23
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,906
quarkusio/quarkus/13170/13169
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13169
https://github.com/quarkusio/quarkus/pull/13170
https://github.com/quarkusio/quarkus/pull/13170
1
fixes
java.nio.file.NoSuchFileException when quarkus.native.debug.enabled
**Describe the bug** With `quarkus.native.debug.enabled=true`, building a native image fails with ``` [ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Unable to copy from C:\\Users\\moritz\\.m2\\repository\\org\\jboss\\resteasy\\resteasy-core\\4.5.8.Final\\resteasy-core-4.5.8.Final-sources.jar to C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\postgresql-test-app-native-image-source-jar\\lib\\org.jboss.resteasy.resteasy-core-4.5.8.Final-sources.jar [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:420) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:93) [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$2.execute(ExtensionLoader.java:936) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) [ERROR] at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479) [ERROR] Caused by: java.nio.file.NoSuchFileException: C:\\Users\\moritz\\.m2\\repository\\org\\jboss\\resteasy\\resteasy-core\\4.5.8.Final\\resteasy-core-4.5.8.Final-sources.jar -> C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\postgresql-test-app-native-image-source-jar\\lib\\org.jboss.resteasy.resteasy-core-4.5.8.Final-sources.jar [ERROR] at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) [ERROR] at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) [ERROR] at java.base/sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:202) [ERROR] at java.base/sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:279) [ERROR] at java.base/java.nio.file.Files.copy(Files.java:1294) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copyJarSourcesToLib(NativeImageBuildStep.java:418) [ERROR] ... 13 more ``` The reason is that the `lib` directory inside `postgresql-test-app-native-image-source-jar` is not created by the quarkus-maven-plugin. Once this is fixed, the next problem is ``` [ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.io.UncheckedIOException: Unable to walk path C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\..\\src\\main\\java [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copySourcesToSourceCache(NativeImageBuildStep.java:476) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:94) [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$2.execute(ExtensionLoader.java:936) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) [ERROR] at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479) [ERROR] Caused by: java.nio.file.NoSuchFileException: C:\\Users\\moritz\\GitHub\\blaze-persistence\\examples\\quarkus\\testsuite\\native\\postgresql\\target\\..\\src\\main\\java [ERROR] at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) [ERROR] at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) [ERROR] at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) [ERROR] at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53) [ERROR] at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38) [ERROR] at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:194) [ERROR] at java.base/java.nio.file.Files.readAttributes(Files.java:1763) [ERROR] at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219) [ERROR] at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276) [ERROR] at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322) [ERROR] at java.base/java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71) [ERROR] at java.base/java.nio.file.Files.walk(Files.java:3820) [ERROR] at java.base/java.nio.file.Files.walk(Files.java:3874) [ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.copySourcesToSourceCache(NativeImageBuildStep.java:466) [ERROR] ... 13 more ``` if `src/main/java` does not exist. **Expected behavior** The build does not fail with above exceptions. **Actual behavior** The build fails. **Configuration** ```properties quarkus.native.debug.enabled=true ``` **Environment (please complete the following information):** - Quarkus version or git rev: 1.9.2.Final
cb11c777cb6b1304cd20440b962d460730a9535a
137a026b0dedea252eebade580115875a7b9c1f7
https://github.com/quarkusio/quarkus/compare/cb11c777cb6b1304cd20440b962d460730a9535a...137a026b0dedea252eebade580115875a7b9c1f7
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index 0715da4104e..6b1b33f3eba 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -503,18 +503,20 @@ private static void copySourcesToSourceCache(OutputTargetBuildItem outputTargetB final Path javaSourcesPath = outputTargetBuildItem.getOutputDirectory().resolve( Paths.get("..", "src", "main", "java")); - try (Stream<Path> paths = Files.walk(javaSourcesPath)) { - paths.forEach(path -> { - Path targetPath = Paths.get(targetSrc.toString(), - path.toString().substring(javaSourcesPath.toString().length())); - try { - Files.copy(path, targetPath, StandardCopyOption.REPLACE_EXISTING); - } catch (IOException e) { - throw new UncheckedIOException("Unable to copy from " + path + " to " + targetPath, e); - } - }); - } catch (IOException e) { - throw new UncheckedIOException("Unable to walk path " + javaSourcesPath, e); + if (Files.exists(javaSourcesPath)) { + try (Stream<Path> paths = Files.walk(javaSourcesPath)) { + paths.forEach(path -> { + Path targetPath = Paths.get(targetSrc.toString(), + path.toString().substring(javaSourcesPath.toString().length())); + try { + Files.copy(path, targetPath, StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + throw new UncheckedIOException("Unable to copy from " + path + " to " + targetPath, e); + } + }); + } catch (IOException e) { + throw new UncheckedIOException("Unable to walk path " + javaSourcesPath, e); + } } }
['core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java']
{'.java': 1}
1
1
0
0
1
14,512,667
2,830,486
377,063
4,001
1,476
264
26
1
6,831
271
1,690
84
0
3
2020-11-08T02:50: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,907
quarkusio/quarkus/13142/13030
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13030
https://github.com/quarkusio/quarkus/pull/13142
https://github.com/quarkusio/quarkus/pull/13142
1
fixes
invalid warning in ResteasyCommonProcessor when using rest-client
**Describe the bug** I created a QuarkusMain application that only uses the rest-client with rest client jackson support. the application works as expected, except it prints this warning: ``` [WARNING] [io.quarkus.resteasy.common.deployment.ResteasyCommonProcessor] Quarkus detected the need of REST JSON support but you have not provided the necessary JSON extension for this. You can visit https://quarkus.io/guides/rest-json for more information on how to set one. ``` **Expected behavior** there should be no warning because this is a valid situation. if the warning was valid, (because we are lacking json support), then the link should be `https://quarkus.io/guides/rest-client ` **Actual behavior** it prints a warning, plus the link is incorrect for rest-clients **To Reproduce** create an application such as https://quarkus.io/guides/rest-client migrate it to be `QuarkusMain` application, and replace the extensions by `rest-client` and the `rest-client-jackson`. build and execute.
d26b9d1466b930a2e83b3ffcdda666813eb6863c
7f692fc940c6a2dc91d1b3f4236cf4b636b9b53c
https://github.com/quarkusio/quarkus/compare/d26b9d1466b930a2e83b3ffcdda666813eb6863c...7f692fc940c6a2dc91d1b3f4236cf4b636b9b53c
diff --git a/extensions/rest-client-jackson/deployment/src/main/java/io/quarkus/restclient/jackson/deployment/RestClientJacksonProcessor.java b/extensions/rest-client-jackson/deployment/src/main/java/io/quarkus/restclient/jackson/deployment/RestClientJacksonProcessor.java index c29b19c7b92..f35102a8bb1 100644 --- a/extensions/rest-client-jackson/deployment/src/main/java/io/quarkus/restclient/jackson/deployment/RestClientJacksonProcessor.java +++ b/extensions/rest-client-jackson/deployment/src/main/java/io/quarkus/restclient/jackson/deployment/RestClientJacksonProcessor.java @@ -15,5 +15,6 @@ void build(BuildProducer<FeatureBuildItem> feature, feature.produce(new FeatureBuildItem(Feature.REST_CLIENT_JACKSON)); capability.produce(new CapabilityBuildItem(Capability.REST_JACKSON)); + capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JSON)); } } diff --git a/extensions/rest-client-jsonb/deployment/src/main/java/io/quarkus/restclient/jsonb/deployment/RestClientJsonbProcessor.java b/extensions/rest-client-jsonb/deployment/src/main/java/io/quarkus/restclient/jsonb/deployment/RestClientJsonbProcessor.java index 6cbcf14e3ea..3e0a885e37a 100755 --- a/extensions/rest-client-jsonb/deployment/src/main/java/io/quarkus/restclient/jsonb/deployment/RestClientJsonbProcessor.java +++ b/extensions/rest-client-jsonb/deployment/src/main/java/io/quarkus/restclient/jsonb/deployment/RestClientJsonbProcessor.java @@ -15,5 +15,6 @@ void build(BuildProducer<FeatureBuildItem> feature, feature.produce(new FeatureBuildItem(Feature.REST_CLIENT_JSONB)); capability.produce(new CapabilityBuildItem(Capability.REST_JSONB)); + capability.produce(new CapabilityBuildItem(Capability.RESTEASY_JSON)); } }
['extensions/rest-client-jsonb/deployment/src/main/java/io/quarkus/restclient/jsonb/deployment/RestClientJsonbProcessor.java', 'extensions/rest-client-jackson/deployment/src/main/java/io/quarkus/restclient/jackson/deployment/RestClientJacksonProcessor.java']
{'.java': 2}
2
2
0
0
2
11,792,345
2,305,374
306,954
3,271
158
32
2
2
1,015
133
232
19
3
1
2020-11-05T14:38: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,909
quarkusio/quarkus/13135/13104
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13104
https://github.com/quarkusio/quarkus/pull/13135
https://github.com/quarkusio/quarkus/pull/13135
1
fixes
QuarkusBootstrap can't resolve quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT when running integration-tests
QuarkusBootstrap can't resolve quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT when running integration-tests. I do `mvn deploy` of Quarkus master into the Artifactory instance to avoid building Quarkus master in every job I need to run against Quarkus master. I do run some DB tests from integration-tests module and they fail with the error `Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null` and `Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to resolve artifact io.quarkus:quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT` Local reproducer: first install Quarkus bits into your local .m2/repository and then use custom settings xml pointing to it ++ custom maven.repo.local when running integration-tests/jpa-postgresql test. @aloubyansky you are probably the best person to look at this issue as you introduced quarkus-bom-quarkus-platform-properties stuff ```sh git clone [email protected]:quarkusio/quarkus.git cd quarkus mvn clean install -Dquickly code my-settings.xml ## see below mvn -f integration-tests/jpa-postgresql/pom.xml clean verify -Denforcer.skip=true -Ddocker -Dtest-postgresql -Dpostgresql.image=postgres:12.3 -s my-settings.xml -Dmaven.repo.local=/Users/rsvoboda/Downloads/my-maven-repository ``` Note: replace `/Users/rsvoboda` with your path my-settings.xml ```xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository/> <profiles> <profile> <id>local</id> <repositories> <repository> <id>local</id> <name>local</name> <url>file:///Users/rsvoboda/.m2/repository</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>local</id> <name>local</name> <url>file:///Users/rsvoboda/.m2/repository</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>local</activeProfile> </activeProfiles> </settings> ``` stacktrace: ``` [INFO] Running io.quarkus.it.jpa.postgresql.JPAFunctionalityTest [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.713 s <<< FAILURE! - in io.quarkus.it.jpa.postgresql.JPAFunctionalityTest [ERROR] io.quarkus.it.jpa.postgresql.JPAFunctionalityTest.testJPAFunctionalityFromServlet Time elapsed: 0.005 s <<< ERROR! java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:549) at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:616) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.api.extension.InvocationInterceptor.interceptTestClassConstructor(InvocationInterceptor.java:72) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:77) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestClassConstructor(ClassBasedTestDescriptor.java:342) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:289) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:79) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:267) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:259) at java.base/java.util.Optional.orElseGet(Optional.java:369) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:258) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:101) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:100) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162) at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548) Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:316) at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:158) at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:206) at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:527) at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:560) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$8(ClassBasedTestDescriptor.java:368) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:368) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:192) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136) ... 34 more Caused by: io.quarkus.bootstrap.resolver.maven.BootstrapMavenException: Failed to resolve artifact io.quarkus:quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolveInternal(MavenArtifactResolver.java:169) at io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver.resolve(MavenArtifactResolver.java:154) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolve(BootstrapAppModelResolver.java:101) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.collectPlatformProperties(BootstrapAppModelResolver.java:310) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.doResolveModel(BootstrapAppModelResolver.java:229) at io.quarkus.bootstrap.resolver.BootstrapAppModelResolver.resolveManagedModel(BootstrapAppModelResolver.java:152) at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:302) ... 44 more Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact io.quarkus:quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424) 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) ... 50 more Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact io.quarkus:quarkus-bom-quarkus-platform-properties:properties:999-SNAPSHOT at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:414) ... 54 more ``` quarkus-bom-quarkus-platform-properties-999-SNAPSHOT.properties is available: ``` ls -l ~/.m2/repository/io/quarkus/quarkus-bom-quarkus-platform-properties/999-SNAPSHOT/ total 32 -rw-r--r-- 1 rsvoboda staff 265 Nov 4 11:29 _remote.repositories -rw-r--r-- 1 rsvoboda staff 736 Nov 4 11:29 maven-metadata-local.xml -rw-r--r-- 1 rsvoboda staff 1999 Nov 4 08:29 quarkus-bom-quarkus-platform-properties-999-SNAPSHOT.pom -rw-r--r-- 1 rsvoboda staff 92 Nov 4 11:29 quarkus-bom-quarkus-platform-properties-999-SNAPSHOT.properties ```
d26b9d1466b930a2e83b3ffcdda666813eb6863c
d800c92da9e57d0abea8619e5391427fa2b04f48
https://github.com/quarkusio/quarkus/compare/d26b9d1466b930a2e83b3ffcdda666813eb6863c...d800c92da9e57d0abea8619e5391427fa2b04f48
diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java index ad23e609e01..afbbd0242a1 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java @@ -242,9 +242,9 @@ public CurationResult resolveAppModel() throws BootstrapException { return createAppModelForJar(projectRoot); } + AppArtifact appArtifact = this.appArtifact; try { LocalProject localProject = null; - AppArtifact appArtifact = this.appArtifact; if (appArtifact == null) { if (projectRoot == null) { throw new IllegalArgumentException( diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalWorkspace.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalWorkspace.java index d8c718c4dfe..53c35fe8b54 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalWorkspace.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalWorkspace.java @@ -18,6 +18,7 @@ import org.apache.maven.model.resolution.UnresolvableModelException; import org.apache.maven.model.resolution.WorkspaceModelResolver; import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.repository.WorkspaceReader; import org.eclipse.aether.repository.WorkspaceRepository; @@ -70,12 +71,10 @@ public int getId() { @Override public Model resolveRawModel(String groupId, String artifactId, String versionConstraint) throws UnresolvableModelException { - final LocalProject project = getProject(groupId, artifactId); - return project != null - && (versionConstraint == null - || versionConstraint.equals(ModelUtils.getVersion(project.getRawModel()))) - ? project.getRawModel() - : null; + if (findArtifact(new DefaultArtifact(groupId, artifactId, null, "pom", versionConstraint)) != null) { + return getProject(groupId, artifactId).getRawModel(); + } + return null; } @Override @@ -116,40 +115,30 @@ public File findArtifact(Artifact artifact) { } final String type = artifact.getExtension(); if (type.equals(AppArtifactCoords.TYPE_JAR)) { - final Path classesDir = lp.getClassesDir(); - if (Files.exists(classesDir)) { - return classesDir.toFile(); + Path path = lp.getClassesDir(); + if (Files.exists(path)) { + return path.toFile(); } // it could be a project with no sources/resources, in which case Maven will create an empty JAR // if it has previously been packaged we can return it - final Path path = lp.getOutputDir().resolve(getFileName(artifact)); + path = lp.getOutputDir().resolve(getFileName(artifact)); if (Files.exists(path)) { return path.toFile(); } - // If the project has neither sources nor resources directories then it is an empty JAR. - // If this method returns null then the Maven resolver will attempt to resolve the artifact from a repository - // which may fail if the artifact hasn't been installed yet. - // Here we are checking whether the artifact exists in the local repo first (Quarkus CI creates a Maven repo cache - // first and then runs tests using '-pl' in the clean project). If the artifact exists in the local repo we return null, - // so the Maven resolver will succeed resolving it from the repo. - // If the artifact does not exist in the local repo, we are creating an empty classes directory in the target directory. - if (!Files.exists(lp.getSourcesSourcesDir()) - && !Files.exists(lp.getResourcesSourcesDir()) - && !isFoundInLocalRepo(artifact)) { - try { - Files.createDirectories(classesDir); - return classesDir.toFile(); - } catch (IOException e) { - // ignore and return null - } + path = emptyJarOutput(lp, artifact); + if (path != null) { + return path.toFile(); } // otherwise, this project hasn't been built yet } else if (type.equals(AppArtifactCoords.TYPE_POM)) { final File pom = lp.getRawModel().getPomFile(); - if (pom.exists()) { + // if the pom exists we should also check whether the main artifact can also be resolved from the workspace + if (pom.exists() && ("pom".equals(lp.getRawModel().getPackaging()) + || Files.exists(lp.getOutputDir()) + || emptyJarOutput(lp, artifact) != null)) { return pom; } } else { @@ -162,6 +151,28 @@ public File findArtifact(Artifact artifact) { return null; } + private Path emptyJarOutput(LocalProject lp, Artifact artifact) { + // If the project has neither sources nor resources directories then it is an empty JAR. + // If this method returns null then the Maven resolver will attempt to resolve the artifact from a repository + // which may fail if the artifact hasn't been installed yet. + // Here we are checking whether the artifact exists in the local repo first (Quarkus CI creates a Maven repo cache + // first and then runs tests using '-pl' in the clean project). If the artifact exists in the local repo we return null, + // so the Maven resolver will succeed resolving it from the repo. + // If the artifact does not exist in the local repo, we are creating an empty classes directory in the target directory. + if (!Files.exists(lp.getSourcesSourcesDir()) + && !Files.exists(lp.getResourcesSourcesDir()) + && !isFoundInLocalRepo(artifact)) { + try { + final Path classesDir = lp.getClassesDir(); + Files.createDirectories(classesDir); + return classesDir; + } catch (IOException e) { + // ignore and return null + } + } + return null; + } + private boolean isFoundInLocalRepo(Artifact artifact) { final String localRepo = getLocalRepo(); if (localRepo == null) { @@ -199,17 +210,15 @@ private String getLocalRepo() { @Override public List<String> findVersions(Artifact artifact) { - if (lastFindVersionsKey != null && artifact.getVersion().equals(lastFindVersions.get(0)) - && lastFindVersionsKey.getArtifactId().equals(artifact.getArtifactId()) + if (lastFindVersionsKey != null && lastFindVersionsKey.getArtifactId().equals(artifact.getArtifactId()) + && artifact.getVersion().equals(lastFindVersions.get(0)) && lastFindVersionsKey.getGroupId().equals(artifact.getGroupId())) { return lastFindVersions; } - lastFindVersionsKey = new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId()); - final LocalProject lp = getProject(lastFindVersionsKey); - if (lp == null || !lp.getVersion().equals(artifact.getVersion())) { - lastFindVersionsKey = null; + if (findArtifact(artifact) == null) { return Collections.emptyList(); } + lastFindVersionsKey = new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId()); return lastFindVersions = Collections.singletonList(artifact.getVersion()); } diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/BasicPomReposEffectivePomTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/BasicPomReposEffectivePomTest.java index 6344d8e0216..fdd6334caad 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/BasicPomReposEffectivePomTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/BasicPomReposEffectivePomTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import java.nio.file.Files; import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -11,6 +12,7 @@ public class BasicPomReposEffectivePomTest extends BootstrapMavenContextTestBase @Test public void basicPomRepos() throws Exception { final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/basic-pom-repos"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); assertEquals( Arrays.asList( newRepo("central", "https://pom.central"), diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/CentralRepoOverridesEffectivePomTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/CentralRepoOverridesEffectivePomTest.java index c19d24aec33..13a575e5799 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/CentralRepoOverridesEffectivePomTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/CentralRepoOverridesEffectivePomTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import java.nio.file.Files; import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -11,6 +12,7 @@ public class CentralRepoOverridesEffectivePomTest extends BootstrapMavenContextT @Test public void basicPomRepos() throws Exception { final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/central-repo-overrides"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); assertEquals( Arrays.asList( newRepo("central", "https://settings.central"), diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomProfileReposEffectivePomTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomProfileReposEffectivePomTest.java index 84dda9f40d2..ae42d9b071b 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomProfileReposEffectivePomTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomProfileReposEffectivePomTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import java.nio.file.Files; import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -12,6 +13,7 @@ public class PomProfileReposEffectivePomTest extends BootstrapMavenContextTestBa public void basicPomRepos() throws Exception { setSystemProp("another-profile", "yes"); final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/pom-profile-repos"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); assertEquals( Arrays.asList( newRepo("another-profile-repo", "https://another-profile.repo"), diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomReposMirroredTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomReposMirroredTest.java index 0f1d5a92b4e..24d05bb7f83 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomReposMirroredTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomReposMirroredTest.java @@ -7,6 +7,7 @@ import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContextConfig; +import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.List; @@ -37,6 +38,7 @@ protected BootstrapMavenContextConfig<?> initBootstrapMavenContextConfig() throw @Test public void basicPomRepos() throws Exception { final BootstrapMavenContext mvn = bootstrapMavenContextWithSettings("custom-settings/pom-repos-mirrored"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); final List<RemoteRepository> repos = mvn.getRemoteRepositories(); assertEquals(1, repos.size()); diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SettingsProfileReposAndPomReposEffectivePomTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SettingsProfileReposAndPomReposEffectivePomTest.java index 6482e87e8db..7ba2d65514f 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SettingsProfileReposAndPomReposEffectivePomTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SettingsProfileReposAndPomReposEffectivePomTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import java.nio.file.Files; import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -11,6 +12,7 @@ public class SettingsProfileReposAndPomReposEffectivePomTest extends BootstrapMa @Test public void settingsProfileReposAndPomRepos() throws Exception { final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/settings-profile-and-pom-repos"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); assertEquals( Arrays.asList( newRepo("settings-central", "https://settings.central"), diff --git a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SubmodulePomReposEffectivePomTest.java b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SubmodulePomReposEffectivePomTest.java index ea843b3e270..4e9e8493436 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SubmodulePomReposEffectivePomTest.java +++ b/independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SubmodulePomReposEffectivePomTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; +import java.nio.file.Files; import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -11,6 +12,7 @@ public class SubmodulePomReposEffectivePomTest extends BootstrapMavenContextTest @Test public void basicPomRepos() throws Exception { final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/submodule-repos/module"); + Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target")); assertEquals( Arrays.asList( newRepo("module-pom-repo", "https://module-pom.repo"),
['independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomProfileReposEffectivePomTest.java', 'independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SubmodulePomReposEffectivePomTest.java', 'independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/PomReposMirroredTest.java', 'independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/BasicPomReposEffectivePomTest.java', 'independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/SettingsProfileReposAndPomReposEffectivePomTest.java', 'independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/BootstrapAppModelFactory.java', 'independent-projects/bootstrap/maven-resolver/src/test/java/io/quarkus/bootstrap/resolver/maven/test/CentralRepoOverridesEffectivePomTest.java', 'independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/LocalWorkspace.java']
{'.java': 8}
8
8
0
0
8
11,792,345
2,305,374
306,954
3,271
4,914
927
77
2
14,233
507
3,125
175
4
4
2020-11-05T12:33:31
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,910
quarkusio/quarkus/13132/13095
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13095
https://github.com/quarkusio/quarkus/pull/13132
https://github.com/quarkusio/quarkus/pull/13132
1
fixes
Regression/Change of behavior for root path when using quarkus-funqy-http on master
**Describe the bug** When using `quarkus-funqy-http`, index.html is not displayed anymore when using the root path. If this is expected, please make this a configuration parameter. This is blocking for codestarts because as soon as funqy is added, then the index.html is not accessible anymore from the root path. **Expected behavior** By default, the root should point to the index.html and not the funqy function, make it a configuration parameter if this is expected. **To Reproduce** Generate an application with "funqy http" and "resteasy" using code.quarkus.io, run it, browse http://0.0.0.0:8080, you get the index because it uses `1.9.1.Final`, swith to `999-SNAPSHOT` in the pom.xml: ```xml <quarkus.platform.version>1.9.1.Final</quarkus.platform.version> <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> <quarkus-plugin.version>1.9.1.Final</quarkus-plugin.version> ``` browse http://0.0.0.0:8080, you get the funqy function result. CC @matejvasek I see you have a recent PR that could be related https://github.com/quarkusio/quarkus/pull/12863
244d9a113ce210e14303e69f28fafb25c29cccdf
3a927921ec2784b031f6febfa84134cc74d7b2da
https://github.com/quarkusio/quarkus/compare/244d9a113ce210e14303e69f28fafb25c29cccdf...3a927921ec2784b031f6febfa84134cc74d7b2da
diff --git a/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java b/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java index 319a34d3cce..23357901917 100644 --- a/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java +++ b/extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java @@ -20,7 +20,6 @@ import io.quarkus.deployment.builditem.ShutdownContextBuildItem; import io.quarkus.funqy.deployment.FunctionBuildItem; import io.quarkus.funqy.deployment.FunctionInitializedBuildItem; -import io.quarkus.funqy.runtime.FunqyConfig; import io.quarkus.funqy.runtime.bindings.http.FunqyHttpBindingRecorder; import io.quarkus.jackson.ObjectMapperProducer; import io.quarkus.vertx.core.deployment.CoreVertxBuildItem; @@ -58,7 +57,6 @@ public void staticInit(FunqyHttpBindingRecorder binding, @BuildStep @Record(RUNTIME_INIT) public void boot(ShutdownContextBuildItem shutdown, - FunqyConfig funqyConfig, FunqyHttpBindingRecorder binding, BuildProducer<FeatureBuildItem> feature, BuildProducer<RouteBuildItem> routes, @@ -74,22 +72,19 @@ public void boot(ShutdownContextBuildItem shutdown, feature.produce(new FeatureBuildItem(FUNQY_HTTP_FEATURE)); String rootPath = httpConfig.rootPath; - if (rootPath == null) { - rootPath = "/"; - } else if (!rootPath.endsWith("/")) { - rootPath += "/"; - } - Handler<RoutingContext> handler = binding.start(rootPath, - funqyConfig, vertx.getVertx(), shutdown, beanContainer.getValue(), executorBuildItem.getExecutorProxy()); - routes.produce(new RouteBuildItem("/", handler, false)); for (FunctionBuildItem function : functions) { + if (rootPath == null) + rootPath = "/"; + else if (!rootPath.endsWith("/")) + rootPath += "/"; String name = function.getFunctionName() == null ? function.getMethodName() : function.getFunctionName(); + //String path = rootPath + name; String path = "/" + name; routes.produce(new RouteBuildItem(path, handler, false)); } diff --git a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/RootPathTest.java b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/RootPathTest.java index 6cc79e8b669..b53589de173 100644 --- a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/RootPathTest.java +++ b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/RootPathTest.java @@ -13,8 +13,7 @@ public class RootPathTest { private static final String APP_PROPS = "" + - "quarkus.http.root-path=/api\\n" + - "quarkus.funqy.export=get\\n"; + "quarkus.http.root-path=/api\\n"; @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() @@ -30,10 +29,6 @@ public void testGetOrPost() throws Exception { .then().statusCode(200).body(equalTo("\\"get\\"")); RestAssured.given().post("/get") .then().statusCode(200).body(equalTo("\\"get\\"")); - RestAssured.given().get("/") - .then().statusCode(200).body(equalTo("\\"get\\"")); - RestAssured.given().post("/") - .then().statusCode(200).body(equalTo("\\"get\\"")); } } diff --git a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java index 34db8528013..2476d5f9b80 100644 --- a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java +++ b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java @@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.equalTo; import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -18,13 +17,9 @@ import io.restassured.RestAssured; public class SimpleTest { - private static final String APP_PROPS = "" + - "quarkus.funqy.export=toLowerCase\\n"; - @RegisterExtension static QuarkusUnitTest test = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addAsResource(new StringAsset(APP_PROPS), "application.properties") .addClasses(PrimitiveFunctions.class, GreetingFunctions.class, Greeting.class, GreetingService.class, GreetingTemplate.class)); @@ -35,12 +30,6 @@ public void testString(String path) { .then().statusCode(200).body(equalTo("\\"hello\\"")); } - @Test - public void testRoot() { - RestAssured.given().contentType("application/json").body("\\"Hello\\"").post("/") - .then().statusCode(200).body(equalTo("\\"hello\\"")); - } - @ParameterizedTest @ValueSource(strings = { "/doubleIt", "/doubleItAsync" }) public void testInt(String path) { diff --git a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunction.java b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunction.java deleted file mode 100644 index 39c8097cd3d..00000000000 --- a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunction.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.quarkus.funqy.test; - -import io.quarkus.funqy.Funq; - -public class SingleFunction { - - @Funq - public String echo(String msg) { - return msg; - } -} diff --git a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunctionTest.java b/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunctionTest.java deleted file mode 100644 index 2f0157a4a43..00000000000 --- a/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunctionTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.quarkus.funqy.test; - -import static org.hamcrest.Matchers.equalTo; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.quarkus.test.QuarkusUnitTest; -import io.restassured.RestAssured; - -public class SingleFunctionTest { - @RegisterExtension - static QuarkusUnitTest test = new QuarkusUnitTest() - .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addClasses(SingleFunction.class)); - - @Test - public void testRoot() { - // When single function is registered by @Funq, the function is mapped also to "/" - RestAssured.given().contentType("application/json").body("\\"Some string.\\"").post("/") - .then().statusCode(200).body(equalTo("\\"Some string.\\"")); - } -} diff --git a/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/FunqyHttpBindingRecorder.java b/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/FunqyHttpBindingRecorder.java index 0b8cb341029..8ef53255364 100644 --- a/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/FunqyHttpBindingRecorder.java +++ b/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/FunqyHttpBindingRecorder.java @@ -15,7 +15,6 @@ import io.quarkus.funqy.runtime.FunctionConstructor; import io.quarkus.funqy.runtime.FunctionInvoker; import io.quarkus.funqy.runtime.FunctionRecorder; -import io.quarkus.funqy.runtime.FunqyConfig; import io.quarkus.funqy.runtime.query.QueryObjectMapper; import io.quarkus.funqy.runtime.query.QueryReader; import io.quarkus.runtime.ShutdownContext; @@ -60,7 +59,6 @@ private ObjectMapper getObjectMapper() { } public Handler<RoutingContext> start(String contextPath, - FunqyConfig funqyConfig, Supplier<Vertx> vertx, ShutdownContext shutdown, BeanContainer beanContainer, @@ -75,18 +73,6 @@ public void run() { }); FunctionConstructor.CONTAINER = beanContainer; - final FunctionInvoker defaultInvoker; - if (funqyConfig.export.isPresent()) { - defaultInvoker = FunctionRecorder.registry.matchInvoker(funqyConfig.export.get()); - if (defaultInvoker == null) { - throw new RuntimeException("quarkus.funqy.export value does not map a function: " + funqyConfig.export.get()); - } - } else if (FunctionRecorder.registry.invokers().size() == 1) { - defaultInvoker = FunctionRecorder.registry.invokers().iterator().next(); - } else { - defaultInvoker = null; - } - - return new VertxRequestHandler(vertx.get(), defaultInvoker, beanContainer, contextPath, executor); + return new VertxRequestHandler(vertx.get(), beanContainer, contextPath, executor); } } diff --git a/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/VertxRequestHandler.java b/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/VertxRequestHandler.java index f1c0a9b9c4b..04ebc543593 100644 --- a/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/VertxRequestHandler.java +++ b/extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/VertxRequestHandler.java @@ -39,15 +39,12 @@ public class VertxRequestHandler implements Handler<RoutingContext> { protected final CurrentIdentityAssociation association; protected final CurrentVertxRequest currentVertxRequest; protected final Executor executor; - protected final FunctionInvoker defaultInvoker; public VertxRequestHandler(Vertx vertx, - FunctionInvoker defaultInvoker, BeanContainer beanContainer, String rootPath, Executor executor) { this.vertx = vertx; - this.defaultInvoker = defaultInvoker; this.beanContainer = beanContainer; // make sure rootPath ends with "/" for easy parsing if (rootPath == null) { @@ -79,12 +76,7 @@ public void handle(RoutingContext routingContext) { path = path.substring(rootPath.length()); - final FunctionInvoker invoker; - if (!path.isEmpty()) { - invoker = FunctionRecorder.registry.matchInvoker(path); - } else { - invoker = defaultInvoker; - } + FunctionInvoker invoker = FunctionRecorder.registry.matchInvoker(path); if (invoker == null) { routingContext.fail(404);
['extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunctionTest.java', 'extensions/funqy/funqy-http/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/http/FunqyHttpBuildStep.java', 'extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/FunqyHttpBindingRecorder.java', 'extensions/funqy/funqy-http/runtime/src/main/java/io/quarkus/funqy/runtime/bindings/http/VertxRequestHandler.java', 'extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java', 'extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/RootPathTest.java', 'extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SingleFunction.java']
{'.java': 7}
7
7
0
0
7
11,774,544
2,301,559
306,405
3,255
1,844
375
41
3
1,108
131
308
23
3
1
2020-11-05T09:58:45
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,911
quarkusio/quarkus/13130/13107
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13107
https://github.com/quarkusio/quarkus/pull/13130
https://github.com/quarkusio/quarkus/pull/13130
1
fixes
Qute: fishy `#if` expressions
I tried several variations of `{#if foo.bar == 'something' || foo.bar == 'other'}` and got mixed results, but not valid results. I think the second boolean operand was ignored, or random. For some reason, `{#if (foo.bar == 'something') || (foo.bar == 'other')}` got me an error.
3e98e8861fc9a24a8aba920a7d811ec2cb60e9a8
fefa5471b131b4eb4f80580a8053015a5aad8d08
https://github.com/quarkusio/quarkus/compare/3e98e8861fc9a24a8aba920a7d811ec2cb60e9a8...fefa5471b131b4eb4f80580a8053015a5aad8d08
diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expressions.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expressions.java index 2600b77e693..4d7d08cf5fc 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expressions.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Expressions.java @@ -71,7 +71,7 @@ public static List<String> splitParts(String value, SplitConfig splitConfig) { char separator = 0; byte infix = 0; byte brackets = 0; - ImmutableList.Builder<String> builder = ImmutableList.builder(); + ImmutableList.Builder<String> parts = ImmutableList.builder(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); @@ -82,9 +82,7 @@ public static List<String> splitParts(String value, SplitConfig splitConfig) { if (splitConfig.shouldPrependSeparator(c)) { buffer.append(c); } - if (buffer.length() > 0) { - // Flush the part - builder.add(buffer.toString()); + if (addPart(buffer, parts)) { buffer = new StringBuilder(); } if (splitConfig.shouldAppendSeparator(c)) { @@ -110,13 +108,13 @@ public static List<String> splitParts(String value, SplitConfig splitConfig) { // Next infix method infix = 1; buffer.append(RIGHT_BRACKET); - builder.add(buffer.toString()); - buffer = new StringBuilder(); + if (addPart(buffer, parts)) { + buffer = new StringBuilder(); + } } else { // First space - start infix method infix++; - if (buffer.length() > 0) { - builder.add(buffer.toString()); + if (addPart(buffer, parts)) { buffer = new StringBuilder(); } } @@ -138,10 +136,25 @@ public static List<String> splitParts(String value, SplitConfig splitConfig) { if (infix > 0) { buffer.append(RIGHT_BRACKET); } - if (buffer.length() > 0) { - builder.add(buffer.toString()); + addPart(buffer, parts); + return parts.build(); + } + + /** + * + * @param buffer + * @param parts + * @return true if a new buffer should be created + */ + private static boolean addPart(StringBuilder buffer, ImmutableList.Builder<String> parts) { + if (buffer.length() == 0) { + return false; + } + String val = buffer.toString().trim(); + if (!val.isEmpty()) { + parts.add(val); } - return builder.build(); + return true; } private static final SplitConfig DEFAULT_SPLIT_CONFIG = new DefaultSplitConfig(); diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/IfSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/IfSectionHelper.java index 3cdc5a4f302..1c42d06ef72 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/IfSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/IfSectionHelper.java @@ -191,6 +191,11 @@ public Operator getOperator() { return operator; } + @Override + public String toString() { + return "OperandCondition [operator=" + operator + ", expression=" + expression.toOriginalString() + "]"; + } + } static class CompositeCondition implements Condition { @@ -272,6 +277,11 @@ public boolean isEmpty() { return conditions.isEmpty(); } + @Override + public String toString() { + return "CompositeCondition [conditions=" + conditions.size() + ", operator=" + operator + "]"; + } + } enum Operator { diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java index d9a01629402..edc071b12ac 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java @@ -486,7 +486,11 @@ private void processParams(String tag, String label, Iterator<String> iter) { List<String> paramValues = new ArrayList<>(); while (iter.hasNext()) { - paramValues.add(iter.next()); + // Ignore whitespace strings + String val = iter.next().trim(); + if (!val.isEmpty()) { + paramValues.add(val); + } } if (paramValues.size() > factoryParams.size()) { LOGGER.debugf("Too many params [label=%s, params=%s, factoryParams=%s]", label, paramValues, factoryParams); @@ -549,9 +553,12 @@ private void processParams(String tag, String label, Iterator<String> iter) { * * @param part * @return the index of an equals char outside of any string literal, - * <code>-1</code> if no such char is found + * <code>-1</code> if no such char is found or if the part represents a composite param */ static int getFirstDeterminingEqualsCharPosition(String part) { + if (!part.isEmpty() && part.charAt(0) == START_COMPOSITE_PARAM) { + return -1; + } boolean stringLiteral = false; for (int i = 0; i < part.length(); i++) { if (LiteralSupport.isStringLiteralSeparator(part.charAt(i))) { diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/IfSectionTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/IfSectionTest.java index 4ad57315d65..497d3bf6ccd 100644 --- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/IfSectionTest.java +++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/IfSectionTest.java @@ -76,6 +76,37 @@ public void testCompositeParameters() { assertEquals("OK", engine.parse("{#if (foo || false || true) && (true)}OK{/if}").render()); assertEquals("NOK", engine.parse("{#if foo || false}OK{#else}NOK{/if}").render()); assertEquals("OK", engine.parse("{#if false || (foo || (false || true))}OK{#else}NOK{/if}").render()); + assertEquals("NOK", engine.parse("{#if (true && false)}OK{#else}NOK{/if}").render()); + assertEquals("OK", engine.parse("{#if true && true}OK{#else}NOK{/if}").render()); + assertEquals("NOK", engine.parse("{#if true && false}OK{#else}NOK{/if}").render()); + assertEquals("NOK", engine.parse("{#if false && true}OK{#else}NOK{/if}").render()); + assertEquals("OK", engine.parse("{#if true and (true or false)}OK{#else}NOK{/if}").render()); + assertEquals("NOK", engine.parse("{#if true and (true == false)}OK{#else}NOK{/if}").render()); + assertEquals("OK", engine.parse("{#if true && (false == false)}OK{#else}NOK{/if}").render()); + + Map<String, String> foo = new HashMap<>(); + foo.put("bar", "something"); + assertEquals("NOK", + engine.parse("{#if foo.bar != 'something' && foo.bar != 'other'}OK{#else}NOK{/if}").data("foo", foo).render()); + assertEquals("OK", + engine.parse("{#if foo.bar != 'nothing' && foo.bar != 'other'}OK{#else}NOK{/if}").data("foo", foo).render()); + assertEquals("OK", + engine.parse("{#if foo.bar == 'something' || foo.bar != 'other'}OK{#else}NOK{/if}").data("foo", foo).render()); + assertEquals("OK", engine.parse("{#if (foo.bar == 'something') || (foo.bar == 'other')}OK{#else}NOK{/if}") + .data("foo", foo).render()); + + Map<String, String> qual = new HashMap<>(); + Template template = engine.parse( + "{#if qual.name != 'javax.inject.Named' \\n" + + " && qual.name != 'javax.enterprise.inject.Any'\\n" + + " && qual.name != 'javax.enterprise.inject.Default'}{qual.name}{/if}"); + qual.put("name", "org.acme.MyQual"); + assertEquals("org.acme.MyQual", template + .data("qual", qual).render()); + qual.put("name", "javax.enterprise.inject.Any"); + assertEquals("", template + .data("qual", qual).render()); + } @Test diff --git a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java index ed042bab6a3..7d06822b1e4 100644 --- a/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java +++ b/independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java @@ -170,12 +170,18 @@ public void testSectionParameters() { 1); assertParserError("{#if (foo || bar}{/}", "Parser error on line 1: unterminated string literal or composite parameter detected for [#if (foo || bar]", 1); + assertParams("item.name == 'foo' and item.name is false", "item.name", "==", "'foo'", "and", "item.name", "is", + "false"); + assertParams("(item.name == 'foo') and (item.name is false)", "(item.name == 'foo')", "and", "(item.name is false)"); + assertParams("(item.name != 'foo') || (item.name == false)", "(item.name != 'foo')", "||", "(item.name == false)"); } @Test public void testWhitespace() { Engine engine = Engine.builder().addDefaults().build(); assertEquals("Hello world", engine.parse("{#if true }Hello {name }{/if }").data("name", "world").render()); + assertEquals("Hello world", engine.parse("{#if true \\n }Hello {name }{/if }").data("name", "world").render()); + assertEquals("Hello world", engine.parse("{#if true \\n || false}Hello {name }{/if }").data("name", "world").render()); assertEquals("Hello world", engine.parse("Hello {name ?: 'world' }").render()); }
['independent-projects/qute/core/src/main/java/io/quarkus/qute/IfSectionHelper.java', 'independent-projects/qute/core/src/test/java/io/quarkus/qute/IfSectionTest.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Expressions.java', 'independent-projects/qute/core/src/test/java/io/quarkus/qute/ParserTest.java']
{'.java': 5}
5
5
0
0
5
11,778,089
2,302,274
306,474
3,255
2,275
411
56
3
281
46
72
3
0
0
2020-11-05T09:37:45
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,912
quarkusio/quarkus/13116/13113
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13113
https://github.com/quarkusio/quarkus/pull/13116
https://github.com/quarkusio/quarkus/pull/13116
1
fixes
Character escaping in Qute doesn't work
**Describe the bug** Characters like '&' aren't escaped. [qute-test.zip](https://github.com/quarkusio/quarkus/files/5487996/qute-test.zip) **Expected behavior** Characters like '&', '"', ... should be escaped to '&amp;', '&quot;' etc. **Actual behavior** The html output contains invalid characters like '&' ... **To Reproduce** Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. 2. 3. **Configuration** ```properties # Add your application.properties here, if applicable. ``` **Screenshots** (If applicable, add screenshots to help explain your problem.) **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux 5.8.16-300.fc33.x86_64 #1 SMP Mon Oct 19 13:18:33 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux - Output of `java -version`: openjdk 11.0.9 2020-10-20 OpenJDK Runtime Environment 18.9 (build 11.0.9+11) OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11, mixed mode, sharing) - GraalVM version (if different from Java): --- - Quarkus version or git rev: 1.9.1.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Maven 3.6.3 **Additional context** (Add any other context about the problem here.)
106cdaa3044bb5b62ce9a2045bcf44d2c8078482
e47a50e53a99dfbebfa68b8e20cd1c55a73dad53
https://github.com/quarkusio/quarkus/compare/106cdaa3044bb5b62ce9a2045bcf44d2c8078482...e47a50e53a99dfbebfa68b8e20cd1c55a73dad53
diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/EscapingTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/EscapingTest.java index a5c54c1a4fa..dbd4e830f0a 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/EscapingTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/EscapingTest.java @@ -2,6 +2,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.Locale; + import javax.inject.Inject; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -14,6 +16,7 @@ import io.quarkus.qute.RawString; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateData; +import io.quarkus.qute.Variant; import io.quarkus.test.QuarkusUnitTest; public class EscapingTest { @@ -61,6 +64,13 @@ public void testValidation() { engine.getTemplate("validation").data("text", "<div>").render()); } + @Test + public void testEngineParse() { + assertEquals("&lt;div&gt; <div>", + engine.parse("{text} {text.raw}", + new Variant(Locale.ENGLISH, "text/html", "UTF-8")).data("text", "<div>").render()); + } + @TemplateData public static class Item { diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Engine.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Engine.java index b2b8db68b51..e738fa08387 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/Engine.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/Engine.java @@ -27,7 +27,7 @@ static EngineBuilder builder() { * @return the template */ default Template parse(String content) { - return parse(content, null); + return parse(content, null, null); } /** @@ -40,7 +40,7 @@ default Template parse(String content) { * @return the template */ default Template parse(String content, Variant variant) { - return parse(content, null, null); + return parse(content, variant, null); } /**
['extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/EscapingTest.java', 'independent-projects/qute/core/src/main/java/io/quarkus/qute/Engine.java']
{'.java': 2}
2
2
0
0
2
11,770,233
2,300,686
306,283
3,254
172
34
4
1
1,368
178
384
44
1
1
2020-11-04T13:59: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,913
quarkusio/quarkus/13105/13078
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13078
https://github.com/quarkusio/quarkus/pull/13105
https://github.com/quarkusio/quarkus/pull/13105
1
fixes
com.amazonaws.xray.interceptors.TracingInterceptor Native Image Failure
**Describe the bug** Fix from #12842 fails in native builds. **Expected behavior** Tracing Interceptor is Created in AWS SDK Clients **Actual behavior** ``` Error: Classes that should be initialized at run time got initialized during image building: com.amazonaws.xray.interceptors.TracingInterceptor the class was requested to be initialized at run time (from feature io.quarkus.runner.AutoFeature.beforeAnalysis). io.quarkus.runner.ApplicationImpl caused initialization of this class with the following trace: at com.amazonaws.xray.interceptors.TracingInterceptor.<clinit>(TracingInterceptor.java) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at io.smallrye.config.Converters.lambda$static$7c03a47f$1(Converters.java:109) at io.smallrye.config.Converters$EmptyValueConverter.convert(Converters.java:925) at io.smallrye.config.Converters$TrimmingConverter.convert(Converters.java:946) at io.smallrye.config.Converters$BuiltInConverter.convert(Converters.java:852) at io.smallrye.config.Converters$CollectionConverter.convert(Converters.java:683) at io.smallrye.config.Converters$CollectionConverter.convert(Converters.java:660) at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:770) at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:751) at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:161) at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$amazon$common$runtime$SdkBuildTimeConfig(Config.zig:34557) at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$amazon$s3$runtime$S3BuildTimeConfig(Config.zig:34692) at io.quarkus.runtime.generated.Config.<clinit>(Config.zig:920) at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:72) com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building: com.amazonaws.xray.interceptors.TracingInterceptor the class was requested to be initialized at run time (from feature io.quarkus.runner.AutoFeature.beforeAnalysis). io.quarkus.runner.ApplicationImpl caused initialization of this class with the following trace: at com.amazonaws.xray.interceptors.TracingInterceptor.<clinit>(TracingInterceptor.java) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at io.smallrye.config.Converters.lambda$static$7c03a47f$1(Converters.java:109) at io.smallrye.config.Converters$EmptyValueConverter.convert(Converters.java:925) at io.smallrye.config.Converters$TrimmingConverter.convert(Converters.java:946) at io.smallrye.config.Converters$BuiltInConverter.convert(Converters.java:852) at io.smallrye.config.Converters$CollectionConverter.convert(Converters.java:683) at io.smallrye.config.Converters$CollectionConverter.convert(Converters.java:660) at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:770) at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:751) at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:161) at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$amazon$common$runtime$SdkBuildTimeConfig(Config.zig:34557) at io.quarkus.runtime.generated.Config.initGroup$io$quarkus$amazon$s3$runtime$S3BuildTimeConfig(Config.zig:34692) at io.quarkus.runtime.generated.Config.<clinit>(Config.zig:920) at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:72) at com.oracle.svm.core.util.UserError.abort(UserError.java:68) at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.checkDelayedInitialization(ConfigurableClassInitialization.java:518) at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:187) at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:720) at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70) at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720) at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:538) at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:451) at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Error: Image build request failed with exit status 1 ``` **To Reproduce** See #12842 **Configuration** ```properties quarkus.s3.interceptors=com.amazonaws.xray.interceptors.TracingInterceptor. ``` **Environment (please complete the following information):** - Output of `java -version`: openjdk version "1.8.0_252" OpenJDK Runtime Environment (build 1.8.0_252-b09) OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 25.252-b09-jvmci-20.1-b02, mixed mode) - Quarkus version or git rev: 1.9.1.Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): 3.6.3 **Additional context** cc @marcinczeczko @gsmet
ac151bab4a00bc071f2c796c1a259efc69db1a85
d5f2fab281fe1d5184825c55e753b52e225dc2e3
https://github.com/quarkusio/quarkus/compare/ac151bab4a00bc071f2c796c1a259efc69db1a85...d5f2fab281fe1d5184825c55e753b52e225dc2e3
diff --git a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java index cda8f72528e..197c7039094 100644 --- a/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java +++ b/extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java @@ -69,8 +69,9 @@ void setup(CombinedIndexBuildItem combinedIndexBuildItem, for (AmazonClientBuildItem client : amazonClients) { SdkBuildTimeConfig clientSdkConfig = client.getBuildTimeSdkConfig(); if (clientSdkConfig != null) { - clientSdkConfig.interceptors.orElse(Collections.emptyList()).forEach(interceptorClass -> { - if (!knownInterceptorImpls.contains(interceptorClass.getName())) { + clientSdkConfig.interceptors.orElse(Collections.emptyList()).forEach(interceptorClassName -> { + interceptorClassName = interceptorClassName.trim(); + if (!knownInterceptorImpls.contains(interceptorClassName)) { throw new ConfigurationError( String.format( "quarkus.%s.interceptors (%s) - must list only existing implementations of software.amazon.awssdk.core.interceptor.ExecutionInterceptor", diff --git a/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/AmazonClientRecorder.java b/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/AmazonClientRecorder.java index f812009c3bd..9e225a4551b 100644 --- a/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/AmazonClientRecorder.java +++ b/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/AmazonClientRecorder.java @@ -72,18 +72,19 @@ public void initSdkClient(SdkClientBuilder builder, String extension, SdkConfig config.apiCallAttemptTimeout.ifPresent(overrides::apiCallAttemptTimeout); buildConfig.interceptors.orElse(Collections.emptyList()).stream() + .map(String::trim) .map(this::createInterceptor) .filter(Objects::nonNull) .forEach(overrides::addExecutionInterceptor); builder.overrideConfiguration(overrides.build()); } - private ExecutionInterceptor createInterceptor(Class<?> interceptorClass) { + private ExecutionInterceptor createInterceptor(String interceptorClassName) { try { return (ExecutionInterceptor) Class - .forName(interceptorClass.getName(), false, Thread.currentThread().getContextClassLoader()).newInstance(); + .forName(interceptorClassName, false, Thread.currentThread().getContextClassLoader()).newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - LOG.error("Unable to create interceptor", e); + LOG.error("Unable to create interceptor " + interceptorClassName, e); return null; } } diff --git a/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/SdkBuildTimeConfig.java b/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/SdkBuildTimeConfig.java index 364aab283b9..4f366aecff9 100644 --- a/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/SdkBuildTimeConfig.java +++ b/extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/SdkBuildTimeConfig.java @@ -22,5 +22,5 @@ public class SdkBuildTimeConfig { * @see software.amazon.awssdk.core.interceptor.ExecutionInterceptor */ @ConfigItem - public Optional<List<Class<?>>> interceptors; + public Optional<List<String>> interceptors; // cannot be classes as can be runtime initialized (e.g. XRay interceptor) }
['extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/AmazonClientRecorder.java', 'extensions/amazon-services/common/deployment/src/main/java/io/quarkus/amazon/common/deployment/AmazonServicesClientsProcessor.java', 'extensions/amazon-services/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/SdkBuildTimeConfig.java']
{'.java': 3}
3
3
0
0
3
11,770,233
2,300,686
306,283
3,254
1,227
198
14
3
5,775
263
1,345
87
0
2
2020-11-04T10:52: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,914
quarkusio/quarkus/13060/13035
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13035
https://github.com/quarkusio/quarkus/pull/13060
https://github.com/quarkusio/quarkus/pull/13060
1
fixes
1.9.1 throws Response has already been written from RouteFilter
**Describe the bug** After updating from 1.8.3.Final to 1.9.1.Final our tests have started to throw this to the logs: ``` 2020-10-30 17:33:39,400 ERROR [io.qua.mut.run.MutinyInfrastructure] (vert.x-eventloop-thread-9) Mutiny had to drop the following exception: java.lang.IllegalStateException: Response has already been written at io.vertx.core.http.impl.HttpServerResponseImpl.end(HttpServerResponseImpl.java:376) at io.vertx.core.http.impl.HttpServerResponseImpl.end(HttpServerResponseImpl.java:365) at io.vertx.core.http.impl.HttpServerResponseImpl.end(HttpServerResponseImpl.java:421) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$1$1.accept(HttpSecurityRecorder.java:75) at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$1$1.accept(HttpSecurityRecorder.java:72) ``` This happens in a ``@RouteFilter(401)`` when it calls ``rc.next()``. This does not happen with earlier versions. **Expected behavior** No such error should be output. **Actual behavior** **To Reproduce** ```java @RouteFilter(401) void oasAcceptHeaderMangler(RoutingContext rc) { if (rc.normalisedPath().endsWith("openapi.json")) { rc.request().headers().remove("Accept"); rc.request().headers().add("Accept", "application/json"); } rc.next(); } ``` We use HttpAuthenticationMechanism and these tests are triggering the failure path: ```java public Uni<SecurityIdentity> authenticate(RoutingContext routingContext, IdentityProviderManager identityProviderManager) { ... .onFailure().transform(AuthenticationFailedException::new) ... ```
a8385d1815b2d304d04a11941ad539d8f5fc52d6
d0d87dccf0d3ceb351fd66c64e8a697fc618ef49
https://github.com/quarkusio/quarkus/compare/a8385d1815b2d304d04a11941ad539d8f5fc52d6...d0d87dccf0d3ceb351fd66c64e8a697fc618ef49
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 3eafc73f2e4..242673cf431 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 @@ -72,7 +72,9 @@ public void accept(RoutingContext routingContext, Throwable throwable) { authenticator.sendChallenge(event).subscribe().with(new Consumer<Boolean>() { @Override public void accept(Boolean aBoolean) { - event.response().end(); + if (!event.response().ended()) { + event.response().end(); + } } }, new Consumer<Throwable>() { @Override
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java']
{'.java': 1}
1
1
0
0
1
11,696,285
2,286,741
304,651
3,244
234
23
4
1
1,653
116
382
40
0
3
2020-11-02T11:08: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,916
quarkusio/quarkus/12977/12976
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/12976
https://github.com/quarkusio/quarkus/pull/12977
https://github.com/quarkusio/quarkus/pull/12977
1
fixes
Hibernate ORM's JTAPlatform implementation is leaking a reference to its registry
**Describe the bug** The `QuarkusJtaPlatform` implementation is extending a base class from upstream ORM which maks it a bad choice for also being used as a static singleton. In particular this leads the classloader to hold on to a reference of the ORM `ServiceRegistry`, in turn leaking a significant amount of memory. We can easily fix it to be a real stateless JtaPlatform, as we don't need the registry.
fb39c961b2910335275df034c25a9bb2e37762ba
a33daeae19c81846bf61b817d7a2f76297792d47
https://github.com/quarkusio/quarkus/compare/fb39c961b2910335275df034c25a9bb2e37762ba...a33daeae19c81846bf61b817d7a2f76297792d47
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java index 66c60a703ff..bcef7173c40 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java @@ -1,26 +1,72 @@ package io.quarkus.hibernate.orm.runtime.customized; +import javax.transaction.Synchronization; +import javax.transaction.SystemException; +import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform; +import org.hibernate.engine.transaction.jta.platform.internal.JtaSynchronizationStrategy; +import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerAccess; +import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerBasedSynchronizationStrategy; +import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; -public final class QuarkusJtaPlatform extends AbstractJtaPlatform { +public final class QuarkusJtaPlatform implements JtaPlatform, TransactionManagerAccess { public static final QuarkusJtaPlatform INSTANCE = new QuarkusJtaPlatform(); + private final JtaSynchronizationStrategy tmSynchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy( + this); + private volatile TransactionManager transactionManager; + private volatile UserTransaction userTransaction; + private QuarkusJtaPlatform() { //nothing } @Override - protected TransactionManager locateTransactionManager() { - return com.arjuna.ats.jta.TransactionManager.transactionManager(); + public TransactionManager retrieveTransactionManager() { + TransactionManager transactionManager = this.transactionManager; + if (transactionManager == null) { + transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager(); + this.transactionManager = transactionManager; + } + return transactionManager; + } + + @Override + public TransactionManager getTransactionManager() { + return retrieveTransactionManager(); + } + + @Override + public UserTransaction retrieveUserTransaction() { + UserTransaction userTransaction = this.userTransaction; + if (this.userTransaction == null) { + userTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction(); + this.userTransaction = userTransaction; + } + return userTransaction; + } + + @Override + public Object getTransactionIdentifier(final Transaction transaction) { + return transaction; + } + + @Override + public void registerSynchronization(Synchronization synchronization) { + this.tmSynchronizationStrategy.registerSynchronization(synchronization); + } + + @Override + public boolean canRegisterSynchronization() { + return this.tmSynchronizationStrategy.canRegisterSynchronization(); } @Override - protected UserTransaction locateUserTransaction() { - return com.arjuna.ats.jta.UserTransaction.userTransaction(); + public int getCurrentStatus() throws SystemException { + return this.retrieveTransactionManager().getStatus(); } }
['extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java']
{'.java': 1}
1
1
0
0
1
11,660,723
2,279,949
303,754
3,232
2,724
453
58
1
412
69
90
5
0
0
2020-10-27T11:30:02
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,850
quarkusio/quarkus/14939/14911
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/14911
https://github.com/quarkusio/quarkus/pull/14939
https://github.com/quarkusio/quarkus/pull/14939
1
fix
property `quarkus.swagger-ui.always-include` doesn't work on Native mode.
## Description When I set up an application with `quarkus.swagger-ui.always-include` enabled, swagger-ui must be available. However on Native mode are not available. example: ``` quarkus.http.root-path=/api quarkus.swagger-ui.always-include=true ``` - Compile and run your app on native mode and then make the following query: ``` Request method: GET Request URI: http://test-http-advanced-pablo-test.apps.ocp45.dynamic.quarkus/api/q/swagger-ui HTTP/1.1 404 Not Found ``` **Notes:** - Tested with Rest assurance. [Jira Ref](https://issues.redhat.com/browse/QUARKUS-752)
bbcf48ab8e8f62cfe2f86fb082e934ba8d82311a
2113ab1a48cef0e10bc428827e53e3be5ab79dba
https://github.com/quarkusio/quarkus/compare/bbcf48ab8e8f62cfe2f86fb082e934ba8d82311a...2113ab1a48cef0e10bc428827e53e3be5ab79dba
diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index e60376b90d7..4fa39309e35 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -470,8 +470,8 @@ void getGraphqlUiFinalDestination( } String graphQLPath = httpRootPath.adjustPath(graphQLConfig.rootPath); - String graphQLUiPath = nonApplicationRootPathBuildItem - .adjustPath(graphQLConfig.ui.rootPath); + String graphQLUiPath = httpRootPath + .adjustPath(nonApplicationRootPathBuildItem.adjustPath(graphQLConfig.ui.rootPath)); AppArtifact artifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, GRAPHQL_UI_WEBJAR_GROUP_ID, GRAPHQL_UI_WEBJAR_ARTIFACT_ID); @@ -479,13 +479,15 @@ void getGraphqlUiFinalDestination( Path tempPath = WebJarUtil.copyResourcesForDevOrTest(curateOutcomeBuildItem, launchMode, artifact, GRAPHQL_UI_WEBJAR_PREFIX); WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLPath, LINE_TO_UPDATE, LINE_FORMAT); - WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), httpRootPath.adjustPath(graphQLUiPath), + WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLUiPath, UI_LINE_TO_UPDATE, UI_LINE_FORMAT); - smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(tempPath.toAbsolutePath().toString(), - httpRootPath.adjustPath(graphQLUiPath))); + smallRyeGraphQLBuildProducer + .produce(new SmallRyeGraphQLBuildItem(tempPath.toAbsolutePath().toString(), graphQLUiPath)); notFoundPageDisplayableEndpointProducer - .produce(new NotFoundPageDisplayableEndpointBuildItem(graphQLUiPath + "/", "MicroProfile GraphQL UI")); + .produce(new NotFoundPageDisplayableEndpointBuildItem( + nonApplicationRootPathBuildItem.adjustPath(graphQLConfig.ui.rootPath) + "/", + "MicroProfile GraphQL UI")); // Handle live reload of branding files if (liveReloadBuildItem.isLiveReload() && !liveReloadBuildItem.getChangedResources().isEmpty()) { @@ -506,7 +508,7 @@ void getGraphqlUiFinalDestination( LINE_FORMAT) .getBytes(StandardCharsets.UTF_8); content = WebJarUtil - .updateUrl(new String(content, StandardCharsets.UTF_8), httpRootPath.adjustPath(graphQLUiPath), + .updateUrl(new String(content, StandardCharsets.UTF_8), graphQLUiPath, UI_LINE_TO_UPDATE, UI_LINE_FORMAT) .getBytes(StandardCharsets.UTF_8); @@ -517,8 +519,7 @@ void getGraphqlUiFinalDestination( nativeImageResourceProducer.produce(new NativeImageResourceBuildItem(fileName)); } - smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(GRAPHQL_UI_FINAL_DESTINATION, - httpRootPath.adjustPath(graphQLUiPath))); + smallRyeGraphQLBuildProducer.produce(new SmallRyeGraphQLBuildItem(GRAPHQL_UI_FINAL_DESTINATION, graphQLUiPath)); } } } diff --git a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java index 3f8d8135b59..99e57df6b6e 100644 --- a/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java +++ b/extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java @@ -417,6 +417,7 @@ void registerUiExtension( } String healthPath = httpRootPath.adjustPath(nonApplicationRootPathBuildItem.adjustPath(healthConfig.rootPath)); + String healthUiPath = httpRootPath.adjustPath(nonApplicationRootPathBuildItem.adjustPath(healthConfig.ui.rootPath)); AppArtifact artifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, HEALTH_UI_WEBJAR_GROUP_ID, HEALTH_UI_WEBJAR_ARTIFACT_ID); @@ -426,8 +427,8 @@ void registerUiExtension( HEALTH_UI_WEBJAR_PREFIX); updateApiUrl(tempPath.resolve(FILE_TO_UPDATE), healthPath); - smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(tempPath.toAbsolutePath().toString(), - httpRootPath.adjustPath(healthConfig.ui.rootPath))); + smallRyeHealthBuildProducer + .produce(new SmallRyeHealthBuildItem(tempPath.toAbsolutePath().toString(), healthUiPath)); notFoundPageDisplayableEndpointProducer .produce(new NotFoundPageDisplayableEndpointBuildItem( @@ -457,8 +458,7 @@ void registerUiExtension( nativeImageResourceProducer.produce(new NativeImageResourceBuildItem(fileName)); } - smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(HEALTH_UI_FINAL_DESTINATION, - httpRootPath.adjustPath(healthConfig.ui.rootPath))); + smallRyeHealthBuildProducer.produce(new SmallRyeHealthBuildItem(HEALTH_UI_FINAL_DESTINATION, healthUiPath)); } } } diff --git a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java index 4fe7fb361d1..c59d4a84276 100644 --- a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java +++ b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java @@ -107,8 +107,7 @@ public void getSwaggerUiFinalDestination( WebJarUtil.updateFile(tempPath.resolve("index.html"), generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig)); - swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(tempPath.toAbsolutePath().toString(), - nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path))); + swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(tempPath.toAbsolutePath().toString(), swaggerUiPath)); displayableEndpoints.produce(new NotFoundPageDisplayableEndpointBuildItem( nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path + "/"), "Open API UI")); @@ -136,8 +135,7 @@ public void getSwaggerUiFinalDestination( nativeImageResourceBuildItemBuildProducer.produce(new NativeImageResourceBuildItem(fileName)); } } - swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(SWAGGER_UI_FINAL_DESTINATION, - nonApplicationRootPathBuildItem.adjustPath(swaggerUiConfig.path))); + swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(SWAGGER_UI_FINAL_DESTINATION, swaggerUiPath)); } } }
['extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java', 'extensions/smallrye-health/deployment/src/main/java/io/quarkus/smallrye/health/deployment/SmallRyeHealthProcessor.java', 'extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java']
{'.java': 3}
3
3
0
0
3
14,602,269
2,847,246
379,296
4,016
3,197
604
33
3
600
62
156
22
2
2
2021-02-09T12:30: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,150
quarkusio/quarkus/34207/34163
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/34163
https://github.com/quarkusio/quarkus/pull/34207
https://github.com/quarkusio/quarkus/pull/34207
1
fixes
Qute section helper type check is not complete
### Describe the bug I'm writing the following Qute section helpers: ```java @EngineConfiguration public class QuteCode128Code extends QuteBarCode { public QuteCode128Code() { super("code128", Barcode::code128Img); } } public abstract class QuteBarCode implements SectionHelperFactory<QuteBarCode.CustomSectionHelper> { @FunctionalInterface public static interface BarCodeEncoder { String encode(String value, int width, int height); } private String name; private BarCodeEncoder encoder; public QuteBarCode(String name, BarCodeEncoder encoder) { this.name = name; this.encoder = encoder; } @Override public List<String> getDefaultAliases() { return List.of(name); } @Override public ParametersInfo getParameters() { return ParametersInfo.builder() .addParameter(Parameter.builder("value")) .addParameter(Parameter.builder("size").optional()) .addParameter(Parameter.builder("width").optional()) .addParameter(Parameter.builder("height").optional()) .build(); } @Override public Scope initializeBlock(Scope outerScope, BlockInfo block) { Util.declareBlock(block, "value", "size", "width", "height"); return SectionHelperFactory.super.initializeBlock(outerScope, block); } @Override public CustomSectionHelper initialize(SectionInitContext context) { Util.requireParameter(context, "value"); // FIXME: support compile-time type-checking when Qute supports it Map<String, Expression> params = Util.collectExpressions(context, "value", "size", "width", "height"); if (context.hasParameter("size")) { if (params.containsKey("width") || params.containsKey("height")) { throw new TemplateException("Cannot set both size and (width or height): choose one the others"); } } return new CustomSectionHelper(params, encoder); } static class CustomSectionHelper implements SectionHelper { private Map<String, Expression> params; private BarCodeEncoder encoder; public CustomSectionHelper(Map<String, Expression> params, BarCodeEncoder encoder) { this.params = params; this.encoder = encoder; } @Override public CompletionStage<ResultNode> resolve(SectionResolutionContext context) { return Futures.evaluateParams(params, context.resolutionContext()) .thenApply(values -> { String value = Util.typecheckValue(values, "value", String.class); Integer size = Util.typecheckValue(values, "size", Integer.class, 200); Integer width = Util.typecheckValue(values, "width", Integer.class, size); Integer height = Util.typecheckValue(values, "height", Integer.class, size); return new SingleResultNode(encoder.encode(value, width, height)); }); } } } ``` And I get exceptions at runtime: ``` Suppressed: io.quarkus.qute.TemplateException: A class annotated with @EngineConfiguration must implement one of the [io.quarkus.qute.SectionHelperFactory, io.quarkus.qute.ValueResolver, io.quarkus.qute.NamespaceResolver]: io.quarkiverse.renarde.barcode.runtime.QuteCode39Code at io.quarkus.qute.deployment.QuteProcessor.collectEngineConfigurations(QuteProcessor.java:2121) ``` This is because the code in `QuteProcessor` only checks direct super interfaces, and mine comes from the superclass: ```java private static boolean isImplementorOf(ClassInfo target, DotName interfaceName) { for (DotName name : target.asClass().interfaceNames()) { if (name.equals(interfaceName)) { return true; } } return false; } ``` I think we should have some better subtyping rules here, no? ### 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_
afbb3151e898d40e77799943c0b3c9a5907a8432
5a391239a3911d967f5953247ba62702c7db65e6
https://github.com/quarkusio/quarkus/compare/afbb3151e898d40e77799943c0b3c9a5907a8432...5a391239a3911d967f5953247ba62702c7db65e6
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 ce524f97723..e4effe48efb 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 @@ -464,6 +464,7 @@ TemplatesAnalysisBuildItem analyzeTemplates(List<TemplatePathBuildItem> template TemplateFilePathsBuildItem filePaths, List<CheckedTemplateBuildItem> checkedTemplates, List<MessageBundleMethodBuildItem> messageBundleMethods, List<TemplateGlobalBuildItem> globals, QuteConfig config, Optional<EngineConfigurationsBuildItem> engineConfigurations, + BeanArchiveIndexBuildItem beanArchiveIndex, BuildProducer<CheckedFragmentValidationBuildItem> checkedFragmentValidations) { long start = System.nanoTime(); @@ -490,7 +491,8 @@ TemplatesAnalysisBuildItem analyzeTemplates(List<TemplatePathBuildItem> template // Register additional section factories if (engineConfigurations.isPresent()) { Collection<ClassInfo> sectionFactories = engineConfigurations.get().getConfigurations().stream() - .filter(c -> isImplementorOf(c, Names.SECTION_HELPER_FACTORY)).collect(Collectors.toList()); + .filter(c -> Types.isImplementorOf(c, Names.SECTION_HELPER_FACTORY, beanArchiveIndex.getIndex())) + .collect(Collectors.toList()); // Use the deployment class loader - it can load application classes; it's non-persistent and isolated ClassLoader tccl = Thread.currentThread().getContextClassLoader(); for (ClassInfo factoryClass : sectionFactories) { @@ -2078,11 +2080,11 @@ CustomTemplateLocatorPatternsBuildItem validateAndCollectCustomTemplateLocatorLo // Collect TemplateLocators annotated with io.quarkus.qute.Locate for (AnnotationInstance locate : beanArchiveIndex.getIndex().getAnnotations(Names.LOCATE)) { AnnotationTarget locateTarget = locate.target(); - if (isTargetClass(locateTarget)) { - if (isNotTemplateLocatorImpl(locateTarget)) { - reportFoundInvalidTarget(validationErrors, locateTarget); - } else { + if (locateTarget.kind() == Kind.CLASS) { + if (Types.isImplementorOf(locateTarget.asClass(), Names.TEMPLATE_LOCATOR, beanArchiveIndex.getIndex())) { addLocationRegExToLocators(locationPatterns, locate.value(), locateTarget, validationErrors); + } else { + reportFoundInvalidTarget(validationErrors, locateTarget); } } } @@ -2090,14 +2092,14 @@ CustomTemplateLocatorPatternsBuildItem validateAndCollectCustomTemplateLocatorLo // Collect TemplateLocators annotated with multiple 'io.quarkus.qute.Locate' for (AnnotationInstance locates : beanArchiveIndex.getIndex().getAnnotations(Names.LOCATES)) { AnnotationTarget locatesTarget = locates.target(); - if (isTargetClass(locatesTarget)) { - if (isNotTemplateLocatorImpl(locatesTarget)) { - reportFoundInvalidTarget(validationErrors, locatesTarget); - } else { + if (locatesTarget.kind() == Kind.CLASS) { + if (Types.isImplementorOf(locatesTarget.asClass(), Names.TEMPLATE_LOCATOR, beanArchiveIndex.getIndex())) { // locates.value() is array of 'io.quarkus.qute.Locate' for (AnnotationInstance locate : locates.value().asNestedArray()) { addLocationRegExToLocators(locationPatterns, locate.value(), locatesTarget, validationErrors); } + } else { + reportFoundInvalidTarget(validationErrors, locatesTarget); } } } @@ -2111,9 +2113,16 @@ void collectEngineConfigurations( BuildProducer<EngineConfigurationsBuildItem> engineConfig, BuildProducer<ValidationErrorBuildItem> validationErrors) { + Collection<AnnotationInstance> engineConfigAnnotations = beanArchiveIndex.getIndex() + .getAnnotations(Names.ENGINE_CONFIGURATION); + if (engineConfigAnnotations.isEmpty()) { + return; + } + List<ClassInfo> engineConfigClasses = new ArrayList<>(); + IndexView index = beanArchiveIndex.getIndex(); - for (AnnotationInstance annotation : beanArchiveIndex.getIndex().getAnnotations(Names.ENGINE_CONFIGURATION)) { + for (AnnotationInstance annotation : engineConfigAnnotations) { AnnotationTarget target = annotation.target(); if (target.kind() == Kind.CLASS) { ClassInfo targetClass = target.asClass(); @@ -2125,7 +2134,7 @@ void collectEngineConfigurations( new TemplateException(String.format( "Only top-level and static nested classes may be annotated with @%s: %s", EngineConfiguration.class.getSimpleName(), targetClass.name())))); - } else if (isImplementorOf(targetClass, Names.SECTION_HELPER_FACTORY)) { + } else if (Types.isImplementorOf(targetClass, Names.SECTION_HELPER_FACTORY, index)) { if (targetClass.hasNoArgsConstructor()) { engineConfigClasses.add(targetClass); } else { @@ -2135,8 +2144,8 @@ void collectEngineConfigurations( "A class annotated with @%s that also implements io.quarkus.qute.SectionHelperFactory must declare a no-args constructor: %s", EngineConfiguration.class.getSimpleName(), targetClass.name())))); } - } else if (isImplementorOf(targetClass, Names.VALUE_RESOLVER) - || isImplementorOf(targetClass, Names.NAMESPACE_RESOLVER)) { + } else if (Types.isImplementorOf(targetClass, Names.VALUE_RESOLVER, index) + || Types.isImplementorOf(targetClass, Names.NAMESPACE_RESOLVER, index)) { engineConfigClasses.add(targetClass); } else { validationErrors.produce( @@ -2151,10 +2160,7 @@ void collectEngineConfigurations( } } } - - if (!engineConfigClasses.isEmpty()) { - engineConfig.produce(new EngineConfigurationsBuildItem(engineConfigClasses)); - } + engineConfig.produce(new EngineConfigurationsBuildItem(engineConfigClasses)); } private void addLocationRegExToLocators(Collection<Pattern> locationToLocators, @@ -2181,30 +2187,6 @@ private void reportFoundInvalidTarget(BuildProducer<ValidationErrorBuildItem> va locateTarget.asClass().name().toString())))); } - private boolean isTargetClass(AnnotationTarget locateTarget) { - return locateTarget.kind() == Kind.CLASS; - } - - private boolean isNotTemplateLocatorImpl(AnnotationTarget locateTarget) { - boolean targetImplTemplateLocator = false; - for (DotName interfaceName : locateTarget.asClass().interfaceNames()) { - if (interfaceName.equals(Names.TEMPLATE_LOCATOR)) { - targetImplTemplateLocator = true; - break; - } - } - return !targetImplTemplateLocator; - } - - private static boolean isImplementorOf(ClassInfo target, DotName interfaceName) { - for (DotName name : target.asClass().interfaceNames()) { - if (name.equals(interfaceName)) { - return true; - } - } - return false; - } - @BuildStep TemplateVariantsBuildItem collectTemplateVariants(List<TemplatePathBuildItem> templatePaths) throws IOException { Set<String> allPaths = templatePaths.stream().map(TemplatePathBuildItem::getPath).collect(Collectors.toSet()); diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Types.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Types.java index 4cb99a9c95e..362d2aed769 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Types.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Types.java @@ -215,4 +215,27 @@ static Type box(Primitive primitive) { } } + static boolean isImplementorOf(ClassInfo target, DotName interfaceName, IndexView index) { + if (target.interfaceNames().contains(interfaceName)) { + // Direct implementor + return true; + } + DotName superName = target.superName(); + if (superName != null && !superName.equals(DotName.OBJECT_NAME)) { + ClassInfo superClass = index.getClassByName(superName); + if (superClass != null && isImplementorOf(superClass, interfaceName, index)) { + // Superclass is implementor + return true; + } + } + for (DotName name : target.interfaceNames()) { + ClassInfo interfaceClass = index.getClassByName(name); + if (interfaceClass != null && isImplementorOf(interfaceClass, interfaceName, index)) { + // Superinterface is implementor + return true; + } + } + return false; + } + } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TypesTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TypesTest.java index 764a7635b1b..1be95694e93 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TypesTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TypesTest.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.io.Serializable; import java.math.BigDecimal; +import java.util.concurrent.CompletionStage; import org.jboss.jandex.ArrayType; import org.jboss.jandex.ClassType; @@ -18,6 +19,8 @@ import org.jboss.jandex.Type; import org.junit.jupiter.api.Test; +import io.quarkus.qute.EvalContext; +import io.quarkus.qute.ValueResolver; import io.quarkus.qute.deployment.Types.AssignabilityCheck; public class TypesTest { @@ -59,6 +62,19 @@ public void testIsAssignableFrom() throws IOException { assertFalse(assignabilityCheck.isAssignableFrom(byteArrayType, intArrayType)); } + @Test + public void testIsImplementorOf() throws IOException { + Index index = index(MyResolver1.class, MyResolver2.class, MyResolver3.class, MyResolver4.class, CoolResolver.class, + BaseResolver.class, String.class); + + assertTrue(Types.isImplementorOf(index.getClassByName(MyResolver1.class), Names.VALUE_RESOLVER, index)); + assertTrue(Types.isImplementorOf(index.getClassByName(MyResolver2.class), Names.VALUE_RESOLVER, index)); + assertTrue(Types.isImplementorOf(index.getClassByName(MyResolver3.class), Names.VALUE_RESOLVER, index)); + assertTrue(Types.isImplementorOf(index.getClassByName(MyResolver4.class), Names.VALUE_RESOLVER, index)); + assertTrue(Types.isImplementorOf(index.getClassByName(CoolResolver.class), Names.VALUE_RESOLVER, index)); + assertFalse(Types.isImplementorOf(index.getClassByName(String.class), Names.VALUE_RESOLVER, index)); + } + private static Index index(Class<?>... classes) throws IOException { Indexer indexer = new Indexer(); for (Class<?> clazz : classes) { @@ -70,4 +86,42 @@ private static Index index(Class<?>... classes) throws IOException { return indexer.complete(); } + public static class MyResolver1 implements ValueResolver { + + @Override + public CompletionStage<Object> resolve(EvalContext context) { + return null; + } + + } + + public static class MyResolver2 extends BaseResolver { + + } + + public static class BaseResolver implements ValueResolver { + + @Override + public CompletionStage<Object> resolve(EvalContext context) { + return null; + } + } + + public interface CoolResolver extends ValueResolver { + + } + + public static class MyResolver3 implements CoolResolver { + + @Override + public CompletionStage<Object> resolve(EvalContext context) { + return null; + } + + } + + public static class MyResolver4 extends MyResolver3 { + + } + } diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/engineconfigurations/resolver/CustomResolversTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/engineconfigurations/resolver/CustomResolversTest.java index d6bf336e3d3..25090d0aec4 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/engineconfigurations/resolver/CustomResolversTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/engineconfigurations/resolver/CustomResolversTest.java @@ -22,8 +22,9 @@ public class CustomResolversTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() - .withApplicationRoot(root -> root.addClasses(CustomValueResolver.class, CustomNamespaceResolver.class) - .addAsResource(new StringAsset("{bool.foo}::{custom:bar}"), "templates/foo.html")); + .withApplicationRoot( + root -> root.addClasses(CustomValueResolver.class, CustomNamespaceResolver.class, ResolverBase.class) + .addAsResource(new StringAsset("{bool.foo}::{custom:bar}"), "templates/foo.html")); @Inject Template foo; @@ -34,7 +35,7 @@ public void testResolvers() { } @EngineConfiguration - static class CustomValueResolver implements ValueResolver { + static class CustomValueResolver extends ResolverBase { @Override public boolean appliesTo(EvalContext context) { @@ -48,6 +49,10 @@ public CompletionStage<Object> resolve(EvalContext context) { } + static abstract class ResolverBase implements ValueResolver { + + } + @EngineConfiguration static class CustomNamespaceResolver implements NamespaceResolver {
['extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/engineconfigurations/resolver/CustomResolversTest.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Types.java', 'extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/TypesTest.java', 'extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java']
{'.java': 4}
4
4
0
0
4
26,998,450
5,324,936
685,603
6,322
4,447
837
87
2
4,567
383
918
145
0
3
2023-06-21T08:14: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,789
quarkusio/quarkus/16426/16347
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16347
https://github.com/quarkusio/quarkus/pull/16426
https://github.com/quarkusio/quarkus/pull/16426
1
fixes
quarkus-jacoco bug in Quarkus 1.13.0
## Describe the bug We (@chris-asl) create a simple project by running: ``` mvn io.quarkus:quarkus-maven-plugin:create \\ -DprojectGroupId=org.acme \\ -DprojectArtifactId=tests-with-coverage-quickstart ``` Then we add the jacoco dependency: ``` <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jacoco</artifactId> <scope>test</scope> </dependency> ``` Running tests with `./mvnw clean verify` we can generate the jacoco report and everything works as expected. However when we add kubernetes client dependency ``` <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-kubernetes-client</artifactId> </dependency> ``` and rerun the tests they fail with build errors: ``` ... # root exception Cannot process instrumented class io/fabric8/kubernetes/api/model/KubeSchema. Please supply original non-instrumented classes ... Caused by: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.lang.IllegalStateException: Cannot process instrumented class io/fabric8/kubernetes/api/model/KubeSchema. Please supply original non-instrumented classes. ``` The docs here https://quarkus.io/guides/tests-with-coverage#coverage-for-tests-not-using-quarkustest mention that we should configure offline transformation when we are not using `@QuarkusTest`. Although the `src/test/java/org/acme/GreetingResourceTest.java` is currently annottated as such. Do we need to setup offline instrumentation when using kubernetes-client extension? ### Expected behavior Runs tests successfully and produce the jacoco report. ### Actual behavior Tests fail due to build errors: ``` ... # root exception Cannot process instrumented class io/fabric8/kubernetes/api/model/KubeSchema. Please supply original non-instrumented classes ... Caused by: java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.lang.RuntimeException: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.io.IOException: Error while instrumenting io.fabric8.kubernetes.api.model.KubeSchema. Caused by: java.lang.IllegalStateException: Cannot process instrumented class io/fabric8/kubernetes/api/model/KubeSchema. Please supply original non-instrumented classes. ``` ## To Reproduce Here is a project that reproduces the issue (as described above) https://github.com/el10686/tests-with-coverage-quickstart Steps to reproduce the behavior: 1. git clone 2. git checkout add-kuberbetes-client-dep 3. ./mvnw clean verify ### Configuration Empty file ## Environment (please complete the following information): ### Output of `uname -a` or `ver` Linux vanias-G5-5500 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing) ### GraalVM version (if different from Java) Not using GraalVM ### Quarkus version or git rev 1.13.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/vanias/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.8.0-48-generic", arch: "amd64", family: "unix"
851ef0a789e81909c36a14c9f7e8bd897a01f5f1
963358c4c3bbf3b1927c5e9f4ce9db57db4c4ea6
https://github.com/quarkusio/quarkus/compare/851ef0a789e81909c36a14c9f7e8bd897a01f5f1...963358c4c3bbf3b1927c5e9f4ce9db57db4c4ea6
diff --git a/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java b/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java index c6f4632447d..d9763c585fa 100644 --- a/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java +++ b/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java @@ -57,8 +57,13 @@ void transformerBuildItem(BuildProducer<BytecodeTransformerBuildItem> transforme Files.deleteIfExists(Paths.get(dataFile)); Instrumenter instrumenter = new Instrumenter(new OfflineInstrumentationAccessGenerator()); + Set<String> seen = new HashSet<>(); for (ClassInfo i : indexBuildItem.getIndex().getKnownClasses()) { String className = i.name().toString(); + if (seen.contains(className)) { + continue; + } + seen.add(className); transformers.produce( new BytecodeTransformerBuildItem.Builder().setClassToTransform(className) .setCacheable(true)
['test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java']
{'.java': 1}
1
1
0
0
1
15,781,912
3,071,820
408,122
4,351
165
27
5
1
4,495
400
1,157
98
2
5
2021-04-12T00:43:08
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,780
quarkusio/quarkus/16536/16534
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16534
https://github.com/quarkusio/quarkus/pull/16536
https://github.com/quarkusio/quarkus/pull/16536
1
fixes
Dev UI - DevConsolePostHandler.flashMessage() results in EOFException
Steps to reproduce: 1. Start [cache-quickstart](https://github.com/quarkusio/quarkus-quickstarts/tree/main/cache-quickstart) in the dev mode 2. Open http://localhost:8080/q/dev/io.quarkus.quarkus-cache/caches in the browser 3. Clear the cache - the cache is cleared but the following exception is thrown: ``` java.io.EOFException at java.base/java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2872) at java.base/java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3367) at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:936) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:379) at io.quarkus.devconsole.runtime.spi.FlashScopeUtil.unmarshallMap(FlashScopeUtil.java:55) at io.quarkus.devconsole.runtime.spi.FlashScopeUtil.handleFlashCookie(FlashScopeUtil.java:34) at io.quarkus.vertx.http.deployment.devmode.console.FlashScopeHandler.handle(FlashScopeHandler.java:11) at io.quarkus.vertx.http.deployment.devmode.console.FlashScopeHandler.handle(FlashScopeHandler.java:7) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1129) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151) at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:196) at io.vertx.ext.web.impl.RouterImpl.handleContext(RouterImpl.java:236) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1129) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133) at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:55) at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:37) at io.quarkus.vertx.http.deployment.devmode.console.DevConsoleProcessor$2$1.handle(DevConsoleProcessor.java:189) at io.quarkus.vertx.http.deployment.devmode.console.DevConsoleProcessor$2$1.handle(DevConsoleProcessor.java:186) at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52) at io.vertx.core.impl.EventLoopContext.lambda$emit$1(EventLoopContext.java:59) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) Resulted in: java.lang.RuntimeException: java.io.EOFException at io.quarkus.devconsole.runtime.spi.FlashScopeUtil.unmarshallMap(FlashScopeUtil.java:58) ... 23 more ``` NOTE: The same behavior can be reproduced with the [scheduler-quickstart](https://github.com/quarkusio/quarkus-quickstarts/tree/main/scheduler-quickstart).
418f02329ade0f88dcf611fe0175bab5f6c47b0f
1cfab0dd91383a07fb3af1c3abd325f6e467f8fe
https://github.com/quarkusio/quarkus/compare/418f02329ade0f88dcf611fe0175bab5f6c47b0f...1cfab0dd91383a07fb3af1c3abd325f6e467f8fe
diff --git a/extensions/vertx-http/dev-console-runtime-spi/src/main/java/io/quarkus/devconsole/runtime/spi/FlashScopeUtil.java b/extensions/vertx-http/dev-console-runtime-spi/src/main/java/io/quarkus/devconsole/runtime/spi/FlashScopeUtil.java index 42791ad49bf..fe12ed6e0be 100644 --- a/extensions/vertx-http/dev-console-runtime-spi/src/main/java/io/quarkus/devconsole/runtime/spi/FlashScopeUtil.java +++ b/extensions/vertx-http/dev-console-runtime-spi/src/main/java/io/quarkus/devconsole/runtime/spi/FlashScopeUtil.java @@ -29,11 +29,19 @@ public static Object getFlash(RoutingContext event) { public static void handleFlashCookie(RoutingContext event) { Cookie cookie = event.request().getCookie(FLASH_COOKIE_NAME); - event.response().removeCookie(FLASH_COOKIE_NAME); if (cookie != null) { - Map<String, Object> data = unmarshallMap(Base64.getDecoder().decode(cookie.getValue().getBytes())); - event.data().put(FLASH_CONTEXT_DATA_NAME, data); + byte[] bytes = cookie.getValue().getBytes(); + if (bytes != null && bytes.length != 0) { + byte[] decoded = Base64.getDecoder().decode(bytes); + // API says it can't be null + if (decoded.length > 0) { + Map<String, Object> data = unmarshallMap(decoded); + event.data().put(FLASH_CONTEXT_DATA_NAME, data); + } + } } + // must do this after we've read the value, otherwise we can't read it, for some reason + event.response().removeCookie(FLASH_COOKIE_NAME); } // we don't use json because quarkus-vertx-http does not depend on Jackson databind and therefore the
['extensions/vertx-http/dev-console-runtime-spi/src/main/java/io/quarkus/devconsole/runtime/spi/FlashScopeUtil.java']
{'.java': 1}
1
1
0
0
1
15,768,671
3,069,213
407,803
4,350
836
167
14
1
3,104
109
732
41
3
1
2021-04-15T08:32: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,781
quarkusio/quarkus/16511/16484
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16484
https://github.com/quarkusio/quarkus/pull/16511
https://github.com/quarkusio/quarkus/pull/16511
1
fixes
reactive-pg-client sslMode=verify-full not working
## Describe the bug When using reactive-pg-client it is not possible to use sslMode verify_full because it fails with: ```java 2021-04-13 17:23:24,498 ERROR [org.hib.rea.errors] (vert.x-eventloop-thread-3) could not execute query: java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Host verification algorithm must be specified under verify-full sslmode at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331) at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:670) at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658) at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094) at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:143) at org.hibernate.reactive.pool.impl.ProxyConnection.withConnection(ProxyConnection.java:45) at org.hibernate.reactive.pool.impl.ProxyConnection.selectJdbc(ProxyConnection.java:109) at org.hibernate.reactive.loader.ReactiveLoader.executeReactiveQueryStatement(ReactiveLoader.java:129) at org.hibernate.reactive.loader.ReactiveLoader.doReactiveQueryAndInitializeNonLazyCollections(ReactiveLoader.java:69) at org.hibernate.reactive.loader.CachingReactiveLoader.doReactiveList(CachingReactiveLoader.java:62) at org.hibernate.reactive.loader.CachingReactiveLoader.reactiveListIgnoreQueryCache(CachingReactiveLoader.java:80) at org.hibernate.reactive.loader.custom.impl.ReactiveCustomLoader.reactiveList(ReactiveCustomLoader.java:94) at org.hibernate.reactive.session.impl.ReactiveSessionImpl.lambda$listReactiveCustomQuery$12(ReactiveSessionImpl.java:462) at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106) at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235) at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:143) at org.hibernate.reactive.session.impl.ReactiveSessionImpl.listReactiveCustomQuery(ReactiveSessionImpl.java:462) at org.hibernate.reactive.session.impl.ReactiveSessionImpl.reactiveList(ReactiveSessionImpl.java:450) at org.hibernate.reactive.session.impl.ReactiveNativeQueryImpl.getReactiveResultList(ReactiveNativeQueryImpl.java:98) at org.hibernate.reactive.session.impl.ReactiveNativeQueryImpl.getReactiveSingleResult(ReactiveNativeQueryImpl.java:80) at io.smallrye.context.impl.wrappers.SlowContextualSupplier.get(SlowContextualSupplier.java:21) at io.smallrye.mutiny.operators.uni.builders.UniCreateFromCompletionStage.subscribe(UniCreateFromCompletionStage.java:24) at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36) at io.smallrye.mutiny.operators.uni.UniRunSubscribeOn.lambda$subscribe$0(UniRunSubscribeOn.java:27) at org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl.lambda$null$0(MutinySessionFactoryImpl.java:56) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.IllegalArgumentException: Host verification algorithm must be specified under verify-full sslmode at io.vertx.pgclient.impl.PgConnectionFactory.connect(PgConnectionFactory.java:141) at io.vertx.pgclient.impl.PgConnectionFactory.connectAndInit(PgConnectionFactory.java:105) at io.vertx.pgclient.impl.PgPoolImpl.connect(PgPoolImpl.java:47) at io.vertx.sqlclient.impl.ConnectionPool.check(ConnectionPool.java:207) at io.vertx.sqlclient.impl.ConnectionPool.acquire(ConnectionPool.java:76) at io.vertx.sqlclient.impl.PoolBase.getConnection(PoolBase.java:59) at io.quarkus.reactive.pg.client.runtime.ThreadLocalPgPool$PgPoolWrapper.getConnection(ThreadLocalPgPool.java:42) at io.quarkus.reactive.datasource.runtime.ThreadLocalPool.getConnection(ThreadLocalPool.java:104) at io.vertx.pgclient.PgPool_1d09fb569cbf9d284c8a4c30125d6bc55c456596_Synthetic_ClientProxy.getConnection(PgPool_1d09fb569cbf9d284c8a4c30125d6bc55c456596_Synthetic_ClientProxy.zig:116) at org.hibernate.reactive.pool.impl.SqlClientPool.lambda$getConnectionFromPool$1(SqlClientPool.java:76) at org.hibernate.reactive.pool.impl.Handlers.toCompletionStage(Handlers.java:24) at org.hibernate.reactive.pool.impl.SqlClientPool.getConnectionFromPool(SqlClientPool.java:75) at org.hibernate.reactive.pool.impl.SqlClientPool.getConnection(SqlClientPool.java:66) at org.hibernate.reactive.pool.impl.ProxyConnection.withConnection(ProxyConnection.java:44) ... 28 more ``` But it is not possible to set host verification algorithm. We tried to set it as an uri parameter (hostnameVerificationAlgorithm) which is normally used by vertx but this does not work either. ### Expected behavior You can configure hostnameVerificationAlgorithm the same way as you can configure sslMode. ### Actual behavior You can only configure sslMode but not hostnameVerificationAlgorithm ## To Reproduce No reproducer. It is sufficient to set sslMode without an existing db. ### Configuration ```properties quarkus.datasource.db-kind=postgresql quarkus.datasource.username=${POSTGRESQL_USER} quarkus.datasource.password=${POSTGRESQL_PASSWORD} quarkus.datasource.reactive.url=postgresql://${POSTGRESQL_HOST}:${POSTGRESQL_PORT}/${POSTGRESQL_DB}?hostnameVerificationAlgorithm=HTTPS quarkus.datasource.reactive.trust-certificate-pem=true quarkus.datasource.reactive.trust-certificate-pem.certs=${POSTGRESQL_SSL_ROOT_CERT} quarkus.datasource.reactive.postgresql.ssl-mode=verify-full ``` ## Environment (please complete the following information): ### Output of `uname -a` or `ver` Darwin LMUCM870527 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64 ### Output of `java -version` openjdk version "11.0.10" 2021-01-19 LTS OpenJDK Runtime Environment Corretto-11.0.10.9.1 (build 11.0.10+9-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode) ### Quarkus version or git rev 1.13.1.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) 3.6.3
04f12b81bdc029e8c31f4ba9ab4a6b30e0780597
9cd72caa2247ba39b76803c5de61059319ffea39
https://github.com/quarkusio/quarkus/compare/04f12b81bdc029e8c31f4ba9ab4a6b30e0780597...9cd72caa2247ba39b76803c5de61059319ffea39
diff --git a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java index 641b819c3bf..12aca499601 100644 --- a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java +++ b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java @@ -109,6 +109,13 @@ public class DataSourceReactiveRuntimeConfig { @ConfigItem(defaultValue = "PT1S") public Duration reconnectInterval = Duration.ofSeconds(1L); + /** + * The hostname verification algorithm to use in case the server's identity should be checked. + * Should be HTTPS, LDAPS or an empty string. + */ + @ConfigItem + public Optional<String> hostnameVerificationAlgorithm = Optional.empty(); + /** * The maximum time a connection remains unused in the pool before it is closed. */ diff --git a/extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java b/extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java index 14376023144..99974956ac6 100644 --- a/extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java +++ b/extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java @@ -149,6 +149,11 @@ private DB2ConnectOptions toConnectOptions(DataSourceRuntimeConfig dataSourceRun connectOptions.setReconnectInterval(dataSourceReactiveRuntimeConfig.reconnectInterval.toMillis()); + if (dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.isPresent()) { + connectOptions.setHostnameVerificationAlgorithm( + dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()); + } + return connectOptions; } } diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java index 38eeaa87e1b..9ff2584bfcc 100644 --- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java +++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java @@ -26,6 +26,7 @@ import io.vertx.core.Vertx; import io.vertx.mysqlclient.MySQLConnectOptions; import io.vertx.mysqlclient.MySQLPool; +import io.vertx.mysqlclient.SslMode; import io.vertx.sqlclient.PoolOptions; @Recorder @@ -141,7 +142,15 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo } if (dataSourceReactiveMySQLConfig.sslMode.isPresent()) { - mysqlConnectOptions.setSslMode(dataSourceReactiveMySQLConfig.sslMode.get()); + final SslMode sslMode = dataSourceReactiveMySQLConfig.sslMode.get(); + mysqlConnectOptions.setSslMode(sslMode); + + // If sslMode is verify-identity, we also need a hostname verification algorithm + if (sslMode == SslMode.VERIFY_IDENTITY && (!dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm + .isPresent() || "".equals(dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()))) { + throw new IllegalArgumentException( + "quarkus.datasource.reactive.hostname-verification-algorithm must be specified under verify-identity sslmode"); + } } mysqlConnectOptions.setTrustAll(dataSourceReactiveRuntimeConfig.trustAll); @@ -158,6 +167,11 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo mysqlConnectOptions.setReconnectInterval(dataSourceReactiveRuntimeConfig.reconnectInterval.toMillis()); + if (dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.isPresent()) { + mysqlConnectOptions.setHostnameVerificationAlgorithm( + dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()); + } + return mysqlConnectOptions; } diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java index c1dc0f2ac58..88e4971aff1 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java @@ -26,6 +26,7 @@ import io.vertx.core.Vertx; import io.vertx.pgclient.PgConnectOptions; import io.vertx.pgclient.PgPool; +import io.vertx.pgclient.SslMode; import io.vertx.sqlclient.PoolOptions; @Recorder @@ -129,7 +130,8 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu if (dataSourceReactivePostgreSQLConfig.cachePreparedStatements.isPresent()) { log.warn( "datasource.reactive.postgresql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead"); - pgConnectOptions.setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get()); + pgConnectOptions + .setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get()); } else { pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements); } @@ -139,7 +141,15 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu } if (dataSourceReactivePostgreSQLConfig.sslMode.isPresent()) { - pgConnectOptions.setSslMode(dataSourceReactivePostgreSQLConfig.sslMode.get()); + final SslMode sslMode = dataSourceReactivePostgreSQLConfig.sslMode.get(); + pgConnectOptions.setSslMode(sslMode); + + // If sslMode is verify-full, we also need a hostname verification algorithm + if (sslMode == SslMode.VERIFY_FULL && (!dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm + .isPresent() || "".equals(dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()))) { + throw new IllegalArgumentException( + "quarkus.datasource.reactive.hostname-verification-algorithm must be specified under verify-full sslmode"); + } } pgConnectOptions.setTrustAll(dataSourceReactiveRuntimeConfig.trustAll); @@ -156,6 +166,11 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu pgConnectOptions.setReconnectInterval(dataSourceReactiveRuntimeConfig.reconnectInterval.toMillis()); + if (dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.isPresent()) { + pgConnectOptions.setHostnameVerificationAlgorithm( + dataSourceReactiveRuntimeConfig.hostnameVerificationAlgorithm.get()); + } + return pgConnectOptions; } }
['extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java', 'extensions/reactive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/runtime/DB2PoolRecorder.java', 'extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java', 'extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java']
{'.java': 4}
4
4
0
0
4
15,770,710
3,069,626
407,838
4,350
2,905
496
47
4
6,824
309
1,611
98
0
2
2021-04-14T13:40:35
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,783
quarkusio/quarkus/16462/16461
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16461
https://github.com/quarkusio/quarkus/pull/16462
https://github.com/quarkusio/quarkus/pull/16462
1
fixes
Remove FunctionGaugeSupport from the Micrometer extension
This interface is no longer needed with MP Metrics 3.0 dependency
40a58de61966f9c935eade76b26e47787105295c
95089e201a8803c2398a9a1c69c4f5735918f4d1
https://github.com/quarkusio/quarkus/compare/40a58de61966f9c935eade76b26e47787105295c...95089e201a8803c2398a9a1c69c4f5735918f4d1
diff --git a/extensions/micrometer/runtime/src/main/java/io/smallrye/metrics/api/FunctionGaugeSupport.java b/extensions/micrometer/runtime/src/main/java/io/smallrye/metrics/api/FunctionGaugeSupport.java deleted file mode 100644 index 427a7687768..00000000000 --- a/extensions/micrometer/runtime/src/main/java/io/smallrye/metrics/api/FunctionGaugeSupport.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.smallrye.metrics.api; - -import java.util.function.Supplier; - -import org.eclipse.microprofile.metrics.Gauge; -import org.eclipse.microprofile.metrics.Tag; - -import io.smallrye.common.annotation.Experimental; - -/** - * Temporary tool to support function gauges in 2.4.x even though they become part of the official API in 3.0. - * This is scheduled to be removed along with the upgrade to SmallRye Metrics 3.0. - */ -@Experimental("Temporarily backported API from Metrics 3.0 to support it in 2.4.x") -@Deprecated -public interface FunctionGaugeSupport { - - <T extends Number> Gauge<T> gauge(String name, Supplier<T> supplier, Tag... tags); - -}
['extensions/micrometer/runtime/src/main/java/io/smallrye/metrics/api/FunctionGaugeSupport.java']
{'.java': 1}
1
1
0
0
1
15,786,385
3,072,649
408,211
4,351
663
150
20
1
65
11
14
1
0
0
2021-04-13T06:13: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,784
quarkusio/quarkus/16460/16170
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16170
https://github.com/quarkusio/quarkus/pull/16460
https://github.com/quarkusio/quarkus/pull/16460
1
fixes
Http2 does not work with reactive routes in quarkus dev mode
## Describe the bug When using enabling http2 & SSL receiving a request from browser that is processed via HTTP2 on quarkus backend yields `java.lang.IllegalStateException: Request has already been read` Error if using reactive route in dev mode As far as I can see in VertxHttpRecorder there is an attempt to resume a request which raises an error - This "Recorder" is added in front of any Route added with @Route annotation If Http1.1 is used the same code works ok ### Expected behavior That a route would serve the request without raising an error ### Actual behavior Registering any Reactive route results in raising an IllegalStateException ## To Reproduce I've setup a small example repo on git https://github.com/lrotim/quarkus-bug.git Steps to reproduce the behavior: 1. `git clone https://github.com/lrotim/quarkus-bug.git` 2. `cd quarkus-bug` 3. Run quarkus in dev mode with provided certificate for SSL (dev certificates are in the given repo), command: `mvn -Dquarkus.http.ssl.certificate.file="$(pwd)/dev.com+3.pem" -Dquarkus.http.ssl.certificate.key-file="$(pwd)/dev.com+3-key.pem" quarkus:dev` 4. Goto http://localhost:8080/hello -> works without error, using HTTP1.1 5. Goto https://localhost:8443/hello -> raises an error, using HTTP2 ### Configuration ```properties quarkus.http.http2=true quarkus.http.ssl-port=8443 ``` ## Environment (please complete the following information): ### Output of `uname -a` or `ver` Darwin nb-lrotim.local 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64 ### Output of `java -version` openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment GraalVM CE 20.0.0 (build 11.0.6+9-jvmci-20.0-b02) OpenJDK 64-Bit Server VM GraalVM CE 20.0.0 (build 11.0.6+9-jvmci-20.0-b02, mixed mode, sharing) ### Quarkus version or git rev 1.13.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Maven home: /Users/leonrotim/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.6, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.0.0/Contents/Home Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
c6f9747c90eba7fb15d387d3b82ea1e5e3b2cd52
a071f848c5df00789e78cbab0f8120a6f17890bb
https://github.com/quarkusio/quarkus/compare/c6f9747c90eba7fb15d387d3b82ea1e5e3b2cd52...a071f848c5df00789e78cbab0f8120a6f17890bb
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 747f8d76f8d..9fd08338ad1 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 @@ -1118,7 +1118,9 @@ public void run() { } }); } else { - event.request().resume(); + if (!event.request().isEnded()) { + event.request().resume(); + } if (CAN_HAVE_BODY.contains(event.request().method())) { bodyHandler.handle(event); } else {
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java']
{'.java': 1}
1
1
0
0
1
15,786,167
3,072,584
408,212
4,351
175
24
4
1
2,360
282
708
52
4
1
2021-04-13T00:39: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,785
quarkusio/quarkus/16446/13363
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/13363
https://github.com/quarkusio/quarkus/pull/16446
https://github.com/quarkusio/quarkus/pull/16446
1
fixes
JWT authentication failure responds with Basic Auth challenge when both JWT and basic mechanisms are enabled
**Describe the bug** When using quarkus-smallrye-jwt, and on authentication failure of a request, Quarkus responds with the wrong challenge `www-authenticate: basic realm= ...` instead of `www-authenticate: Bearer {token}` in the 401 response. This causes the Chrome browser to display a Basic Auth login popup on XHR requests where it shouldn't. **Expected behavior** If multiple `HttpAuthenticationMechanism` implementations are present, It's not entirely clear how Quarkus should know which HttpAuthenticationMechanism to use for the challenge to respond with. However, it should be possible to prevent Basic Auth from providing the challenge in the response. It should somehow be possible to get Quarkus to use `io.quarkus.smallrye.jwt.runtime.auth.JWTAuthMechanism.getChallenge(RoutingContext)`. **Actual behavior** `HttpAuthenticator.sendChallenge(RoutingContext)` uses the first mechanism it finds to send the challenge, and that always seems to be `BasicAuthenticationMechanism`. **To Reproduce** It's hard to come up with a small reproducer, because it requires some OIDC server. Maybe a custom authentication mechanism with its own `getChallenge()` implementation could serve to demonstrate that that never gets called. **Environment (please complete the following information):** - Output of `uname -a` or `ver`: Linux + Mac - Output of `java -version`: openjdk version "11.0.4" 2019-07-16 - GraalVM version (if different from Java): N/A - Quarkus version or git rev: 1.8.3-Final - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) **Additional context** Using Keycloak as OIDC server
1bb72b43c7287d5abb43a5b21504008ddc078f80
9a0ecff3cbd87cf8d3dca0c05c8b706fd062e17c
https://github.com/quarkusio/quarkus/compare/1bb72b43c7287d5abb43a5b21504008ddc078f80...9a0ecff3cbd87cf8d3dca0c05c8b706fd062e17c
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BearerAuthenticationMechanism.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BearerAuthenticationMechanism.java index 84746c29886..6d4411447a0 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BearerAuthenticationMechanism.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BearerAuthenticationMechanism.java @@ -1,5 +1,6 @@ package io.quarkus.oidc.runtime; +import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpResponseStatus; import io.quarkus.oidc.AccessTokenCredential; import io.quarkus.oidc.OidcTenantConfig; @@ -15,7 +16,7 @@ public class BearerAuthenticationMechanism extends AbstractOidcAuthenticationMechanism { protected static final ChallengeData UNAUTHORIZED_CHALLENGE = new ChallengeData(HttpResponseStatus.UNAUTHORIZED.code(), - null, null); + HttpHeaderNames.WWW_AUTHENTICATE, OidcConstants.BEARER_SCHEME); public Uni<SecurityIdentity> authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { diff --git a/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/JwtAuthUnitTest.java b/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/JwtAuthUnitTest.java index 1409f8bd6ce..100dbc74294 100644 --- a/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/JwtAuthUnitTest.java +++ b/extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/JwtAuthUnitTest.java @@ -1,5 +1,7 @@ package io.quarkus.jwt.test; +import static org.hamcrest.Matchers.equalTo; + import java.io.StringReader; import java.net.HttpURLConnection; import java.util.HashMap; @@ -48,11 +50,11 @@ public void generateToken() throws Exception { authTimeClaim = timeClaims.get(Claims.auth_time.name()); } - // Basic @ServletSecurity tests @Test() public void testSecureAccessFailure() { RestAssured.when().get("/endp/verifyInjectedIssuer").then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } /** diff --git a/extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/JWTAuthMechanism.java b/extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/JWTAuthMechanism.java index e15bc1e860a..e59fe2486b3 100644 --- a/extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/JWTAuthMechanism.java +++ b/extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/JWTAuthMechanism.java @@ -53,7 +53,7 @@ public Uni<ChallengeData> getChallenge(RoutingContext context) { ChallengeData result = new ChallengeData( HttpResponseStatus.UNAUTHORIZED.code(), HttpHeaderNames.WWW_AUTHENTICATE, - "Bearer {token}"); + "Bearer"); return Uni.createFrom().item(result); } 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 ccb68d0ac56..5bb1f947864 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 @@ -147,16 +147,14 @@ public void testBasicAuthFailure() { CookieFilter cookies = new CookieFilter(); RestAssured .given() - .auth().basic("admin", "wrongpassword") + .auth().preemptive().basic("admin", "wrongpassword") .filter(cookies) .redirects().follow(false) - .when() .get("/admin") .then() .assertThat() - .statusCode(302) - .header("location", containsString("/login")) - .cookie("quarkus-redirect-location", containsString("/admin")); + .statusCode(401) + .header("WWW-Authenticate", equalTo("basic realm=\\"Quarkus\\"")); } } 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 21377fa1057..afa28198ebb 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 @@ -66,7 +66,6 @@ public class BasicAuthenticationMechanism implements HttpAuthenticationMechanism */ public static final String USER_AGENT_CHARSETS = "user-agent-charsets"; - private final String name; private final String challenge; private static final String BASIC = "basic"; @@ -87,32 +86,40 @@ public class BasicAuthenticationMechanism implements HttpAuthenticationMechanism private final Map<Pattern, Charset> userAgentCharsets; public BasicAuthenticationMechanism(final String realmName) { - this(realmName, "BASIC"); + this(realmName, false); } + public BasicAuthenticationMechanism(final String realmName, final boolean silent) { + this(realmName, silent, StandardCharsets.UTF_8, Collections.emptyMap()); + } + + public BasicAuthenticationMechanism(final String realmName, final boolean silent, + Charset charset, Map<Pattern, Charset> userAgentCharsets) { + this.challenge = BASIC_PREFIX + "realm=\\"" + realmName + "\\""; + this.silent = silent; + this.charset = charset; + this.userAgentCharsets = Collections.unmodifiableMap(new LinkedHashMap<>(userAgentCharsets)); + } + + @Deprecated public BasicAuthenticationMechanism(final String realmName, final String mechanismName) { this(realmName, mechanismName, false); } + @Deprecated public BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent) { this(realmName, mechanismName, silent, StandardCharsets.UTF_8, Collections.emptyMap()); } + @Deprecated public BasicAuthenticationMechanism(final String realmName, final String mechanismName, final boolean silent, Charset charset, Map<Pattern, Charset> userAgentCharsets) { this.challenge = BASIC_PREFIX + "realm=\\"" + realmName + "\\""; - this.name = mechanismName; this.silent = silent; this.charset = charset; this.userAgentCharsets = Collections.unmodifiableMap(new LinkedHashMap<>(userAgentCharsets)); } - private static void clear(final char[] array) { - for (int i = 0; i < array.length; i++) { - array[i] = 0x00; - } - } - @Override public Uni<SecurityIdentity> authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java index 9f839a0fb9f..15f6e4c852a 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java @@ -152,7 +152,7 @@ static Uni<ChallengeData> getRedirect(final RoutingContext exchange, final Strin public Uni<SecurityIdentity> authenticate(RoutingContext context, IdentityProviderManager identityProviderManager) { - if (context.normalisedPath().endsWith(postLocation) && context.request().method().equals(HttpMethod.POST)) { + if (context.normalizedPath().endsWith(postLocation) && context.request().method().equals(HttpMethod.POST)) { //we always re-auth if it is a post to the auth URL return runFormAuth(context, identityProviderManager); } else { @@ -173,7 +173,7 @@ public void accept(SecurityIdentity securityIdentity) { @Override public Uni<ChallengeData> getChallenge(RoutingContext context) { - if (context.normalisedPath().endsWith(postLocation) && context.request().method().equals(HttpMethod.POST)) { + if (context.normalizedPath().endsWith(postLocation) && context.request().method().equals(HttpMethod.POST)) { log.debugf("Serving form auth error page %s for %s", loginPage, context); // This method would no longer be called if authentication had already occurred. return getRedirect(context, errorPage); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpAuthenticator.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpAuthenticator.java index 26c50cb1910..94f266f4597 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpAuthenticator.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpAuthenticator.java @@ -19,7 +19,9 @@ import io.quarkus.security.identity.SecurityIdentity; import io.quarkus.security.identity.request.AnonymousAuthenticationRequest; import io.quarkus.security.identity.request.AuthenticationRequest; +import io.quarkus.vertx.http.runtime.security.HttpCredentialTransport.Type; import io.smallrye.mutiny.Uni; +import io.vertx.core.http.HttpHeaders; import io.vertx.ext.web.RoutingContext; /** @@ -27,7 +29,6 @@ */ @ApplicationScoped public class HttpAuthenticator { - final HttpAuthenticationMechanism[] mechanisms; @Inject IdentityProviderManager identityProviderManager; @@ -97,6 +98,11 @@ IdentityProviderManager getIdentityProviderManager() { */ public Uni<SecurityIdentity> attemptAuthentication(RoutingContext routingContext) { + HttpAuthenticationMechanism matchingMech = findMechanismWithAuthorizationScheme(routingContext); + if (matchingMech != null) { + return matchingMech.authenticate(routingContext, identityProviderManager); + } + Uni<SecurityIdentity> result = mechanisms[0].authenticate(routingContext, identityProviderManager); for (int i = 1; i < mechanisms.length; ++i) { HttpAuthenticationMechanism mech = mechanisms[i]; @@ -118,18 +124,26 @@ public Uni<SecurityIdentity> apply(SecurityIdentity data) { * @return */ public Uni<Boolean> sendChallenge(RoutingContext routingContext) { - Uni<Boolean> result = mechanisms[0].sendChallenge(routingContext); - for (int i = 1; i < mechanisms.length; ++i) { - HttpAuthenticationMechanism mech = mechanisms[i]; - result = result.onItem().transformToUni(new Function<Boolean, Uni<? extends Boolean>>() { - @Override - public Uni<? extends Boolean> apply(Boolean authDone) { - if (authDone) { - return Uni.createFrom().item(authDone); + Uni<Boolean> result = null; + + HttpAuthenticationMechanism matchingMech = findMechanismWithAuthorizationScheme(routingContext); + if (matchingMech != null) { + result = matchingMech.sendChallenge(routingContext); + } + if (result == null) { + result = mechanisms[0].sendChallenge(routingContext); + for (int i = 1; i < mechanisms.length; ++i) { + HttpAuthenticationMechanism mech = mechanisms[i]; + result = result.onItem().transformToUni(new Function<Boolean, Uni<? extends Boolean>>() { + @Override + public Uni<? extends Boolean> apply(Boolean authDone) { + if (authDone) { + return Uni.createFrom().item(authDone); + } + return mech.sendChallenge(routingContext); } - return mech.sendChallenge(routingContext); - } - }); + }); + } } return result.onItem().transformToUni(new Function<Boolean, Uni<? extends Boolean>>() { @Override @@ -144,6 +158,10 @@ public Uni<? extends Boolean> apply(Boolean authDone) { } public Uni<ChallengeData> getChallenge(RoutingContext routingContext) { + HttpAuthenticationMechanism matchingMech = findMechanismWithAuthorizationScheme(routingContext); + if (matchingMech != null) { + return matchingMech.getChallenge(routingContext); + } Uni<ChallengeData> result = mechanisms[0].getChallenge(routingContext); for (int i = 1; i < mechanisms.length; ++i) { HttpAuthenticationMechanism mech = mechanisms[i]; @@ -161,6 +179,32 @@ public Uni<? extends ChallengeData> apply(ChallengeData data) { return result; } + private HttpAuthenticationMechanism findMechanismWithAuthorizationScheme(RoutingContext routingContext) { + String authScheme = getAuthorizationScheme(routingContext); + if (authScheme == null) { + return null; + } + for (int i = 0; i < mechanisms.length; ++i) { + HttpCredentialTransport credType = mechanisms[i].getCredentialTransport(); + if (credType != null && credType.getTransportType() == Type.AUTHORIZATION + && credType.getTypeTarget().toLowerCase().startsWith(authScheme.toLowerCase())) { + return mechanisms[i]; + } + } + return null; + } + + private static String getAuthorizationScheme(RoutingContext routingContext) { + String authorization = routingContext.request().getHeader(HttpHeaders.AUTHORIZATION); + if (authorization != null) { + int spaceIndex = authorization.indexOf(' '); + if (spaceIndex > 0) { + return authorization.substring(0, spaceIndex); + } + } + return null; + } + static class NoAuthenticationMechanism implements HttpAuthenticationMechanism { @Override diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpCredentialTransport.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpCredentialTransport.java index 41575c3ed9c..4c978386d03 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpCredentialTransport.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpCredentialTransport.java @@ -57,13 +57,13 @@ public boolean equals(Object o) { if (transportType != that.transportType) return false; - return typeTarget != null ? typeTarget.equals(that.typeTarget) : that.typeTarget == null; + return typeTarget.equals(that.typeTarget); } @Override public int hashCode() { - int result = transportType != null ? transportType.hashCode() : 0; - result = 31 * result + (typeTarget != null ? typeTarget.hashCode() : 0); + int result = transportType.hashCode(); + result = 31 * result + typeTarget.hashCode(); return result; } @@ -74,4 +74,12 @@ public String toString() { ", typeTarget='" + typeTarget + '\\'' + '}'; } + + public Type getTransportType() { + return transportType; + } + + public String getTypeTarget() { + return typeTarget; + } } 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 af43ab529a1..b3fa260c4eb 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 @@ -271,7 +271,7 @@ public Supplier<?> setupBasicAuth(HttpBuildTimeConfig buildTimeConfig) { return new Supplier<BasicAuthenticationMechanism>() { @Override public BasicAuthenticationMechanism get() { - return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm, "BASIC", buildTimeConfig.auth.form.enabled); + return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm, buildTimeConfig.auth.form.enabled); } }; } diff --git a/integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java b/integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java index 8bfe74a8b97..c463bf9ff02 100644 --- a/integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java +++ b/integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java @@ -61,7 +61,8 @@ public void testDeniedAccessAdminResource() { public void testDeniedNoBearerToken() { RestAssured.given() .when().get("/api/users/me").then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } @Test @@ -71,7 +72,8 @@ public void testExpiredBearerToken() { RestAssured.given().auth().oauth2(token).when() .get("/api/users/me") .then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } @Test @@ -81,7 +83,8 @@ public void testBearerTokenWrongIssuer() { RestAssured.given().auth().oauth2(token).when() .get("/api/users/me") .then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } @Test @@ -91,7 +94,8 @@ public void testBearerTokenWrongAudience() { RestAssured.given().auth().oauth2(token).when() .get("/api/users/me") .then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } private String getAccessToken(String userName, Set<String> groups) { 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 a0a186fe96e..5cc88a26da0 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 @@ -137,14 +137,16 @@ public void testDeniedAccessAdminResource() { public void testVerificationFailedNoBearerToken() { RestAssured.given() .when().get("/api/users/me").then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } @Test public void testVerificationFailedInvalidToken() { RestAssured.given().auth().oauth2("123") .when().get("/api/users/me").then() - .statusCode(401); + .statusCode(401) + .header("WWW-Authenticate", equalTo("Bearer")); } //see https://github.com/quarkusio/quarkus/issues/5809
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BearerAuthenticationMechanism.java', '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/HttpAuthenticator.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpSecurityRecorder.java', 'integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/BearerTokenAuthorizationTest.java', 'extensions/smallrye-jwt/runtime/src/main/java/io/quarkus/smallrye/jwt/runtime/auth/JWTAuthMechanism.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/HttpCredentialTransport.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/FormAuthenticationMechanism.java', 'extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/BasicAuthenticationMechanism.java', 'extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/JwtAuthUnitTest.java', 'extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/security/CombinedFormBasicAuthTestCase.java']
{'.java': 11}
11
11
0
0
11
15,790,068
3,073,361
408,289
4,351
5,657
1,080
118
7
1,710
221
411
23
0
0
2021-04-12T14:01:02
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,786
quarkusio/quarkus/16445/16131
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16131
https://github.com/quarkusio/quarkus/pull/16445
https://github.com/quarkusio/quarkus/pull/16445
1
closes
[native] Quarkus not able to parse GraalVM version in upcoming 21.1
## Describe the bug Quakus fails to parse the GraalVM version from `native-image --version` in upcoming GraalVM 21.1. This is because in the upcoming GraalVM the version is: ``` GraalVM Version 21.0.0 (Java Version 11.0.10+8-jvmci-21.0-b06) ``` while in previous versions it used to be: ``` GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+5-jvmci-21.1-b02) ``` Note the removal of "Version" and the addition of "Java 11 CE". ### Expected behavior Quarkus should be able to get the version without any warning or error. ### Actual behavior Quarkus prints: ``` [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Unable to get GraalVM version from the native-image binary. ``` ## To Reproduce 1. Grab GraalVM from https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/21.1.0-dev-20210330_0726 2. Build a Quarkus app or test with `-Dnative` and `GRAALVM_HOME` pointing to GraalVM 21.1.0-dev
55687bead7bebde29e98d6e886031fe9c1236380
c8c79e0a2dc38c4146dbde865b80669dd50c9264
https://github.com/quarkusio/quarkus/compare/55687bead7bebde29e98d6e886031fe9c1236380...c8c79e0a2dc38c4146dbde865b80669dd50c9264
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java index 345cc3f8cd6..063d3daeafd 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java @@ -8,14 +8,9 @@ final class GraalVM { static final class Version implements Comparable<Version> { private static final Pattern PATTERN = Pattern.compile( - "GraalVM Version (([1-9][0-9]*)\\\\.([0-9]+)\\\\.[0-9]+|\\\\p{XDigit}*)[^(\\n$]*(\\\\(Mandrel Distribution\\\\))?\\\\s*"); + "(GraalVM|native-image)( Version)? ([1-9][0-9]*)\\\\.([0-9]+)\\\\.[0-9]+(-dev\\\\p{XDigit}*)?([^\\n$]*)\\\\s*"); static final Version UNVERSIONED = new Version("Undefined", -1, -1, Distribution.ORACLE); - static final Version SNAPSHOT_ORACLE = new Version("Snapshot", Integer.MAX_VALUE, Integer.MAX_VALUE, - Distribution.ORACLE); - static final Version SNAPSHOT_MANDREL = new Version("Snapshot", Integer.MAX_VALUE, Integer.MAX_VALUE, - Distribution.MANDREL); - static final Version VERSION_20_3 = new Version("GraalVM 20.3", 20, 3, Distribution.ORACLE); static final Version VERSION_21_0 = new Version("GraalVM 21.0", 21, 0, Distribution.ORACLE); @@ -50,10 +45,6 @@ boolean isMandrel() { return distribution == Distribution.MANDREL; } - boolean isSnapshot() { - return this == SNAPSHOT_ORACLE || this == SNAPSHOT_MANDREL; - } - boolean isNewerThan(Version version) { return this.compareTo(version) > 0; } @@ -81,27 +72,21 @@ static Version of(Stream<String> lines) { final String line = it.next(); final Matcher matcher = PATTERN.matcher(line); if (matcher.find() && matcher.groupCount() >= 3) { - final String distro = matcher.group(4); - if (isSnapshot(matcher.group(2))) { - return isMandrel(distro) ? SNAPSHOT_MANDREL : SNAPSHOT_ORACLE; - } else { - return new Version( - line, - Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)), - isMandrel(distro) ? Distribution.MANDREL : Distribution.ORACLE); - } + final String major = matcher.group(3); + final String minor = matcher.group(4); + final String distro = matcher.group(6); + return new Version( + line, + Integer.parseInt(major), Integer.parseInt(minor), + isMandrel(distro) ? Distribution.MANDREL : Distribution.ORACLE); } } return UNVERSIONED; } - private static boolean isSnapshot(String s) { - return s == null; - } - private static boolean isMandrel(String s) { - return "(Mandrel Distribution)".equals(s); + return s.contains("Mandrel Distribution"); } @Override diff --git a/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStepTest.java b/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStepTest.java index d953271b887..d93d78cba6e 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStepTest.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStepTest.java @@ -15,10 +15,6 @@ public class NativeImageBuildStepTest { @Test public void testGraalVMVersionDetected() { - assertVersion(1, 0, ORACLE, Version.of(Stream.of("GraalVM Version 1.0.0"))); - assertVersion(19, 3, ORACLE, Version.of(Stream.of("GraalVM Version 19.3.0"))); - assertVersion(19, 3, ORACLE, Version.of(Stream.of("GraalVM Version 19.3.3"))); - assertVersion(20, 0, ORACLE, Version.of(Stream.of("GraalVM Version 20.0.0"))); assertVersion(20, 1, ORACLE, Version.of(Stream.of("GraalVM Version 20.1.0 (Java Version 11.0.7)"))); assertVersion(20, 1, MANDREL, Version .of(Stream.of("GraalVM Version 20.1.0.1.Alpha2 56d4ee1b28 (Mandrel Distribution) (Java Version 11.0.8)"))); @@ -28,6 +24,14 @@ public void testGraalVMVersionDetected() { .of(Stream.of("GraalVM Version 21.0.0.0-0b3 (Mandrel Distribution) (Java Version 11.0.8)"))); assertVersion(20, 3, MANDREL, Version .of(Stream.of("GraalVM Version 20.3.1.2-dev (Mandrel Distribution) (Java Version 11.0.8)"))); + assertVersion(21, 1, MANDREL, Version + .of(Stream.of("native-image 21.1.0.0 Java 11 Mandrel Distribution (Java Version 11.0.11)"))); + assertVersion(21, 1, MANDREL, Version + .of(Stream.of("GraalVM 21.1.0.0 Java 11 Mandrel Distribution (Java Version 11.0.11)"))); + assertVersion(21, 1, ORACLE, Version + .of(Stream.of("GraalVM 21.1.0 Java 11 CE (Java Version 11.0.11+5-jvmci-21.1-b02)"))); + assertVersion(21, 1, ORACLE, Version + .of(Stream.of("native-image 21.1.0.0 Java 11 CE (Java Version 11.0.11+5-jvmci-21.1-b02)"))); } static void assertVersion(int major, int minor, Distribution distro, Version version) { @@ -46,21 +50,9 @@ public void testGraalVMVersionUndetected() { assertThat(Version.of(Stream.of("foo bar")).isDetected()).isFalse(); } - @Test - public void testGraalVMVersionSnapshot() { - assertSnapshot(MANDREL, - Version.of(Stream.of("GraalVM Version beb2fd6 (Mandrel Distribution) (Java Version 11.0.9-internal)"))); - } - - static void assertSnapshot(Distribution distro, Version version) { - assertThat(version.distribution).isEqualTo(distro); - assertThat(version.isDetected()).isEqualTo(true); - assertThat(version.isSnapshot()).isEqualTo(true); - } - @Test public void testGraalVMVersionsOlderThan() { - assertOlderThan("GraalVM Version 1.0.0", "GraalVM Version 19.3.0"); + assertOlderThan("GraalVM Version 19.3.0", "GraalVM Version 20.2.0"); assertOlderThan("GraalVM Version 20.0.0", "GraalVM Version 20.1.0"); }
['core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/GraalVM.java', 'core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStepTest.java']
{'.java': 2}
2
2
0
0
2
15,786,167
3,072,584
408,212
4,351
1,854
390
33
1
930
122
288
27
1
3
2021-04-12T13:11:00
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,788
quarkusio/quarkus/16428/16427
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16427
https://github.com/quarkusio/quarkus/pull/16428
https://github.com/quarkusio/quarkus/pull/16428
1
fixes
Quarkus 1.13.x WebSocket Client - wrong ClassLoader?
Since upgrading from 1.12.x to 1.13.x the WebSocket Client callbacks no longer interact with the container correctly. I am seeing issues such as: ``` ERROR: UT026013: Unhandled error in annotated endpoint org.acme.websockets.ChatTest$Client@54e6d66f java.lang.RuntimeException: java.util.ServiceConfigurationError: io.smallrye.config.SmallRyeConfigFactory: io.quarkus.runtime.configuration.QuarkusConfigFactory not a subtype ``` I'm guessing a ClassLoader issue? I observed this initially on a server-side WS Client but it is also reproducible in the ChatTest example (attached). [Reproducer: websockets-quickstart.zip](https://github.com/quarkusio/quarkus/files/6293295/websockets-quickstart.zip)
851ef0a789e81909c36a14c9f7e8bd897a01f5f1
b541a8c19efdfa7a439788075b9276b8ea7998da
https://github.com/quarkusio/quarkus/compare/851ef0a789e81909c36a14c9f7e8bd897a01f5f1...b541a8c19efdfa7a439788075b9276b8ea7998da
diff --git a/extensions/websockets/runtime/src/main/java/io/quarkus/undertow/websockets/runtime/WebsocketRecorder.java b/extensions/websockets/runtime/src/main/java/io/quarkus/undertow/websockets/runtime/WebsocketRecorder.java index fc5c834d8ac..f0f16c3f1e4 100644 --- a/extensions/websockets/runtime/src/main/java/io/quarkus/undertow/websockets/runtime/WebsocketRecorder.java +++ b/extensions/websockets/runtime/src/main/java/io/quarkus/undertow/websockets/runtime/WebsocketRecorder.java @@ -19,6 +19,7 @@ import io.quarkus.arc.runtime.BeanContainer; import io.quarkus.runtime.ExecutorRecorder; import io.quarkus.runtime.annotations.Recorder; +import io.undertow.websockets.UndertowContainerProvider; import io.undertow.websockets.WebSocketDeploymentInfo; import io.undertow.websockets.util.ContextSetupHandler; import io.undertow.websockets.util.ObjectFactory; @@ -107,6 +108,7 @@ public WebSocketDeploymentInfo createDeploymentInfo(Set<String> annotatedEndpoin public Handler<RoutingContext> createHandler(BeanContainer beanContainer, Supplier<EventLoopGroup> eventLoopGroupSupplier, WebSocketDeploymentInfo info) throws DeploymentException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); ManagedContext requestContext = Arc.container().requestContext(); VertxServerWebSocketContainer container = new VertxServerWebSocketContainer(new ObjectIntrospecter() { @Override @@ -137,11 +139,22 @@ public <T, C> Action<T, C> create(Action<T, C> action) { return new Action<T, C>() { @Override public T call(C context) throws Exception { - requestContext.activate(); + ClassLoader old = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(cl); + boolean required = !requestContext.isActive(); + if (required) { + requestContext.activate(); + } try { return action.call(context); } finally { - requestContext.terminate(); + try { + if (required) { + requestContext.terminate(); + } + } finally { + Thread.currentThread().setContextClassLoader(old); + } } } }; @@ -159,6 +172,7 @@ public Executor get() { for (ServerEndpointConfig i : info.getProgramaticEndpoints()) { container.addEndpoint(i); } + UndertowContainerProvider.setDefaultContainer(container); return new VertxWebSocketHandler(container, info); }
['extensions/websockets/runtime/src/main/java/io/quarkus/undertow/websockets/runtime/WebsocketRecorder.java']
{'.java': 1}
1
1
0
0
1
15,781,912
3,071,820
408,122
4,351
1,129
118
18
1
711
66
171
11
1
1
2021-04-12T02:07:45
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,790
quarkusio/quarkus/16317/16268
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16268
https://github.com/quarkusio/quarkus/pull/16317
https://github.com/quarkusio/quarkus/pull/16317
1
fix
interceptor fails with IllegalArgumentException when parameters are modified and the target method uses primitive types
## Describe the bug When an @AroundInvoke interceptor is used on a method that accepts one or many arguments with primitive types, and one of the arguments are modified, the application crashes with an IllegalArgumentException. ``` java.lang.IllegalArgumentException: The parameter type [class java.lang.Integer] does not match the type for the target method [int] at io.quarkus.arc.impl.AbstractInvocationContext.validateParameters(AbstractInvocationContext.java:81) at io.quarkus.arc.impl.AbstractInvocationContext.setParameters(AbstractInvocationContext.java:62) at org.acme.getting.started.MyInterceptor.intercept(MyInterceptor.java:30) at org.acme.getting.started.MyInterceptor_Bean.intercept(MyInterceptor_Bean.zig:286) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:57) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:43) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32) at org.acme.getting.started.ReactiveGreetingService_Subclass.greetings(ReactiveGreetingService_Subclass.zig:264) at org.acme.getting.started.ReactiveGreetingService_ClientProxy.greetings(ReactiveGreetingService_ClientProxy.zig:131) at org.acme.getting.started.ReactiveGreetingResource.greetings(ReactiveGreetingResource.java:30) at org.acme.getting.started.ReactiveGreetingResource_Subclass.greetings$$superaccessor4(ReactiveGreetingResource_Subclass.zig:646) at org.acme.getting.started.ReactiveGreetingResource_Subclass$$function$$4.apply(ReactiveGreetingResource_Subclass$$function$$4.zig:43) at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:57) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:43) at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521) at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41) at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41) at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32) at org.acme.getting.started.ReactiveGreetingResource_Subclass.greetings(ReactiveGreetingResource_Subclass.zig:601) at org.acme.getting.started.ReactiveGreetingResource$quarkusrestinvoker$greetings_fc5e8e89f58b8153f92fa0c6d8b7cae3808086b5.invoke(ReactiveGreetingResource$quarkusrestinvoker$greetings_fc5e8e89f58b8153f92fa0c6d8b7cae3808086b5.zig:47) at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29) at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:7) at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:122) at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:47) at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17) at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.quarkus.vertx.http.runtime.StaticResourcesRecorder.lambda$start$1(StaticResourcesRecorder.java:65) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:101) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132) at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:206) at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:832) ``` ### Expected behavior Should not crash. ### Actual behavior Crashes. ## To Reproduce I've attached a simple reproducer. It's just the getting-started-reactive project with the addition of a simple interceptor that attempts to change the first argument to the intercepted method. [getting-started-reactive.tar.gz](https://github.com/quarkusio/quarkus/files/6264222/getting-started-reactive.tar.gz) ``` @Dependent @Interceptor @Three @Priority(Interceptor.Priority.APPLICATION) public class MyInterceptor { @AroundInvoke public Object intercept(final InvocationContext context) throws Exception { final Object[] params = context.getParameters(); params[0] = 3; context.setParameters(params); return context.proceed(); } } ``` The interceptor is applied to this method in ReactiveGreetingService ``` @Three public Multi<String> greetings(int count, String name) { ``` and the bug is triggered by GET http://localhost:8080/hello/greeting/10/johan after starting the app in dev mode. NOTE The application will crash with the exact same error even if the int-argument is left untouched, e.g. if we remove `params[0] = 3` and instead try to do `params[1] = "johan"` ## Environment ### Output of `java -version` openjdk version "14.0.2" 2020-07-14 OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-1) OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-1, mixed mode, sharing) ### Quarkus version or git rev 1.13.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) pache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/.../.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 14.0.2, vendor: Private Build, runtime: /usr/lib/jvm/java-14-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.8.0-45-generic", arch: "amd64", family: "unix"
a60db60ae5d39ed4e09454f037ed3688cf318e22
beb843d8189b46f3ab9a5feb06244c9688bdcb76
https://github.com/quarkusio/quarkus/compare/a60db60ae5d39ed4e09454f037ed3688cf318e22...beb843d8189b46f3ab9a5feb06244c9688bdcb76
diff --git a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java index ef917d0f9e6..fc79e1279d2 100644 --- a/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java +++ b/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java @@ -77,7 +77,7 @@ protected void validateParameters(Object[] params) { + ", type: " + parameterTypes[i] + "]"); } if (params[i] != null) { - if (!parameterTypes[i].isAssignableFrom(params[i].getClass())) { + if (!Types.boxedClass(parameterTypes[i]).isAssignableFrom(Types.boxedClass(params[i].getClass()))) { throw new IllegalArgumentException("The parameter type [" + params[i].getClass() + "] can not be assigned to the type for the target method [" + parameterTypes[i] + "]"); } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptor.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptor.java index 6e63f18fc24..3363ddbd901 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptor.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptor.java @@ -15,7 +15,11 @@ Object interceptParameters(InvocationContext ctx) throws Exception { Object[] params = ctx.getParameters(); if (params.length == 1 && params[0] != null) { - params[0] = params[0].getClass().getSimpleName(); + if (params[0] instanceof CharSequence) { + params[0] = params[0].getClass().getSimpleName(); + } else if (params[0] instanceof Number) { + params[0] = 123456; + } ctx.setParameters(params); } return ctx.proceed(); diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptorTest.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptorTest.java index 30b70599675..67d18576b28 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptorTest.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptorTest.java @@ -37,6 +37,16 @@ public void testInterception() { assertThrows(IllegalArgumentException.class, () -> { simpleBean.setStringBuilderVal(new StringBuilder("intercept")); }); + + simpleBean.setPrimitiveIntVal(0); + assertEquals("123456", simpleBean.getVal()); + + simpleBean.setIntVal(1); + assertEquals("123456", simpleBean.getVal()); + + simpleBean.setNumberVal(2L); + assertEquals("123456", simpleBean.getVal()); + handle.destroy(); } } diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/SimpleBean.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/SimpleBean.java index fb638e8e94f..e94a82a77fa 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/SimpleBean.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/SimpleBean.java @@ -17,6 +17,21 @@ void setStringBuilderVal(StringBuilder val) { this.val = val; } + @Simple + void setNumberVal(final Number val) { + this.val = val != null ? val.toString() : null; + } + + @Simple + void setPrimitiveIntVal(final int val) { + this.val = Integer.toString(val); + } + + @Simple + void setIntVal(final Integer val) { + this.val = val != null ? val.toString() : null; + } + String getVal() { return val != null ? val.toString() : null; }
['independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractInvocationContext.java', 'independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptor.java', 'independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/SimpleBean.java', 'independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/interceptors/parameters/ParamInterceptorTest.java']
{'.java': 4}
4
4
0
0
4
15,684,821
3,052,874
405,740
4,325
199
39
2
1
7,348
366
1,813
121
2
3
2021-04-07T11:48:08
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,801
quarkusio/quarkus/16007/15909
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/15909
https://github.com/quarkusio/quarkus/pull/16007
https://github.com/quarkusio/quarkus/pull/16007
1
fixes
AWS Lambda HTTP Content-Type is lost
## Describe the bug Quarkus RestEasy AWS Lambda's Content-Types don't get returned by AWS API Gateway. ### Expected behavior The content type returned by the API Gateway is the one set by RESTEasy (ie 'application/json' unless set otherwise via @Produces) ### Actual behavior The content type is `text/plain`. ## To Reproduce 1. Generate the Amazon Lambda HTTP example at https://quarkus.io/guides/amazon-lambda-http 2. Delete the `GreetingVertx`, `GreetingFunction` and `GreetingServlet` classes, and modify the pom accordingly to remove the corrresponding dependencies 3. Modify `GreetingResource`. Change the `@Produces` annotation to `APPLICATION_JSON` (RestEasy defaults to `application/json` but at least like that it is explicit) and modify the returned String to be a valid piece of JSON 4. Build the native Lambda: `mvn clean install -DskipTests=true -Pnative -Dnative-image.docker-build=true` 5. Upload it to AWS: `aws lambda create-function --function-name mynativefunction --zip-file fileb://target/function.zip --handler not.used.in.provided.runtimei --runtime provided --role arn:aws:iam::1234567890123:role/MyAppropriateRole` 6. Create an API on the API Gateway: 6.1. Create a new HTTP API 6.2. Choose the lambda integration uploaded in 5 6.3. Configure a `GET /hello` route 6.4. Configure the `$default` stage and create the API 7. Copy the Invoke URL and invoke it: `wget -S https://abcdef.execute-api.zone.amazonaws.com/hello` Inspect the content-type returned by the invocation - it is `text/plain` despite the content type being `application/json` in the `GreetingResource` class. ### Configuration NA ### Screenshots NA ## Environment (please complete the following information): ### Output of `uname -a` or `ver` `Linux DESKTOP-GJJ95MV 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux` ### Output of `java -version` openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode) ### GraalVM version (if different from Java) NA ### Quarkus version or git rev 1.12.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) ``` Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/rich/.sdkman/candidates/maven/current Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: /home/rich/.sdkman/candidates/java/11.0.10.hs-adpt Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "4.19.104-microsoft-standard", arch: "amd64", family: "unix" ``` ## Additional context I have managed to fix this locally by adding the following hacky code to the `msg instanceof HttpResponse` clause of the `LambdaHttpHandler` class. I will try to get a pull request done soon. ```java final List<Entry<String, String>> entries = res.headers().entries(); final Map<String, String> responseHeaders = new HashMap<>(); for (final Iterator<Entry<String, String>> i = entries.iterator(); i.hasNext();) { final Entry<String, String> e = i.next(); log.info(e.getKey() + " : " + e.getValue()); responseHeaders.put(e.getKey(), e.getValue()); } responseBuilder.setHeaders(responseHeaders); ```
40ee5863d2a6b61d660463183713ff3c85806bec
7dbfae1aaf24fc5ca27a0b5366087605f06db83c
https://github.com/quarkusio/quarkus/compare/40ee5863d2a6b61d660463183713ff3c85806bec...7dbfae1aaf24fc5ca27a0b5366087605f06db83c
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 fa99269e88e..e747f23e2be 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 @@ -6,7 +6,10 @@ import java.nio.channels.WritableByteChannel; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -92,12 +95,21 @@ public void handleMessage(Object msg) { HttpResponse res = (HttpResponse) msg; responseBuilder.setStatusCode(res.status().code()); - Headers multiValueHeaders = new Headers(); - responseBuilder.setMultiValueHeaders(multiValueHeaders); + final Map<String, String> headers = new HashMap<>(); + responseBuilder.setHeaders(headers); for (String name : res.headers().names()) { - for (String v : res.headers().getAll(name)) { - multiValueHeaders.add(name, v); + final List<String> allForName = res.headers().getAll(name); + if (allForName == null || allForName.isEmpty()) { + continue; } + final StringBuilder sb = new StringBuilder(); + for (Iterator<String> valueIterator = allForName.iterator(); valueIterator.hasNext();) { + sb.append(valueIterator.next()); + if (valueIterator.hasNext()) { + sb.append(","); + } + } + headers.put(name, sb.toString()); } } if (msg instanceof HttpContent) { @@ -122,7 +134,7 @@ public void handleMessage(Object msg) { } if (msg instanceof LastHttpContent) { if (baos != null) { - if (isBinary(((Headers) responseBuilder.getMultiValueHeaders()).getFirst("Content-Type"))) { + if (isBinary(responseBuilder.getHeaders().get("Content-Type"))) { responseBuilder.setIsBase64Encoded(true); responseBuilder.setBody(Base64.getMimeEncoder().encodeToString(baos.toByteArray())); } else { diff --git a/integration-tests/amazon-lambda-http-resteasy/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java b/integration-tests/amazon-lambda-http-resteasy/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java index 62937980ccc..03f4a55cd48 100644 --- a/integration-tests/amazon-lambda-http-resteasy/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java +++ b/integration-tests/amazon-lambda-http-resteasy/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java @@ -44,7 +44,7 @@ private void testGetText(String path) { APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); Assertions.assertEquals(body(out), "hello"); - Assertions.assertTrue(out.getMultiValueHeaders().get("Content-Type").get(0).startsWith("text/plain")); + Assertions.assertTrue(out.getHeaders().get("Content-Type").startsWith("text/plain")); } private APIGatewayV2HTTPEvent request(String path) { @@ -77,7 +77,7 @@ private void testPostText(String path) { APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); Assertions.assertEquals(body(out), "hello Bill"); - Assertions.assertTrue(out.getMultiValueHeaders().get("Content-Type").get(0).startsWith("text/plain")); + Assertions.assertTrue(out.getHeaders().get("Content-Type").startsWith("text/plain")); } @Test @@ -92,7 +92,7 @@ public void testPostBinary() throws Exception { request.setIsBase64Encoded(true); APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); - Assertions.assertEquals(out.getMultiValueHeaders().get("Content-Type").get(0), + Assertions.assertEquals(out.getHeaders().get("Content-Type"), MediaType.APPLICATION_OCTET_STREAM); Assertions.assertTrue(out.getIsBase64Encoded()); byte[] rtn = Base64.decodeBase64(out.getBody()); diff --git a/integration-tests/amazon-lambda-http/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java b/integration-tests/amazon-lambda-http/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java index ed8b602e925..afebdd73b5d 100644 --- a/integration-tests/amazon-lambda-http/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java +++ b/integration-tests/amazon-lambda-http/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java @@ -58,7 +58,7 @@ private void testGetText(String path) { APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); Assertions.assertEquals(body(out), "hello"); - Assertions.assertTrue(out.getMultiValueHeaders().get("Content-Type").get(0).startsWith("text/plain")); + Assertions.assertTrue(out.getHeaders().get("Content-Type").startsWith("text/plain")); } private APIGatewayV2HTTPEvent request(String path) { @@ -93,7 +93,7 @@ private void testPostText(String path) { APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); Assertions.assertEquals(body(out), "hello Bill"); - Assertions.assertTrue(out.getMultiValueHeaders().get("Content-Type").get(0).startsWith("text/plain")); + Assertions.assertTrue(out.getHeaders().get("Content-Type").startsWith("text/plain")); } @Test @@ -108,7 +108,7 @@ public void testPostBinary() throws Exception { request.setIsBase64Encoded(true); APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); - Assertions.assertEquals(out.getMultiValueHeaders().get("Content-Type").get(0), + Assertions.assertEquals(out.getHeaders().get("Content-Type"), MediaType.APPLICATION_OCTET_STREAM); Assertions.assertTrue(out.getIsBase64Encoded()); byte[] rtn = Base64.decodeBase64(out.getBody()); @@ -138,7 +138,7 @@ public void testFunqy(String path) { APIGatewayV2HTTPResponse out = LambdaClient.invoke(APIGatewayV2HTTPResponse.class, request); Assertions.assertEquals(out.getStatusCode(), 200); Assertions.assertEquals(body(out), "\\"Make it funqy Bill\\""); - Assertions.assertTrue(out.getMultiValueHeaders().get("Content-Type").get(0).startsWith("application/json")); + Assertions.assertTrue(out.getHeaders().get("Content-Type").startsWith("application/json")); } @Test
['integration-tests/amazon-lambda-http-resteasy/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java', 'extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java', 'integration-tests/amazon-lambda-http/src/test/java/io/quarkus/it/amazon/lambda/AmazonLambdaSimpleTestCase.java']
{'.java': 3}
3
3
0
0
3
15,485,916
3,015,915
401,110
4,279
1,365
207
22
1
3,290
402
880
70
2
2
2021-03-24T21:29: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,792
quarkusio/quarkus/16265/16239
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16239
https://github.com/quarkusio/quarkus/pull/16265
https://github.com/quarkusio/quarkus/pull/16265
1
fix
Missing Hazelcast logs after change #15636
## Describe the bug We use Hazelcast embedded in one of our projects. After upgrading to 1.13.0.Final version we get `"LogManager error of type WRITE_FAILURE: The delayed handler's queue was overrun and log record(s) were lost. Did you forget to configure logging?"` during server startup. All Hazelcast startup logs are lost. I suspect it is related to change https://github.com/quarkusio/quarkus/pull/15636. Hazelcast is initialized in a producer method. I added some logging into this producer method to see if they are printed however those logs get lost as well. PS: When I start the project in `dev` mode the logs are printed correctly.
e7f7bea58097b2a0556edebb50b63e877c50048b
7a89e049560b7416a21483c82c5eba0635798e3c
https://github.com/quarkusio/quarkus/compare/e7f7bea58097b2a0556edebb50b63e877c50048b...7a89e049560b7416a21483c82c5eba0635798e3c
diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java index b39f29a5d57..74883b44991 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java @@ -23,6 +23,7 @@ import java.util.logging.ErrorManager; import java.util.logging.Formatter; import java.util.logging.Handler; +import java.util.logging.Level; import java.util.logging.Logger; import org.jboss.logmanager.ExtHandler; import org.jboss.logmanager.ExtLogRecord; @@ -66,6 +67,10 @@ protected void doPublish(final ExtLogRecord record) { publishToNestedHandlers(record); super.doPublish(record); } else { + // until the handler is fully activated, we drop anything below the info level + if (record.getLevel().intValue() < Level.INFO.intValue()) { + return; + } // Determine whether the queue was overrun if (logRecords.size() >= queueLimit) { reportError(
['independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java']
{'.java': 1}
1
1
0
0
1
15,670,070
3,050,234
405,398
4,325
269
43
5
1
649
101
148
6
1
0
2021-04-06T09:50:12
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,794
quarkusio/quarkus/16183/16113
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16113
https://github.com/quarkusio/quarkus/pull/16183
https://github.com/quarkusio/quarkus/pull/16183
1
fixes
Regression issue: Fast Jar not working using OpenShift and Docker strategy
## Describe the bug When using the Docker strategy when deploying an application using OpenShift, the build failed because the generated artifacts are not found: ``` [INFO] [io.quarkus.container.image.openshift.deployment.OpenshiftProcessor] STEP 6: ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" [INFO] [io.quarkus.container.image.openshift.deployment.OpenshiftProcessor] --> 54085069869 [INFO] [io.quarkus.container.image.openshift.deployment.OpenshiftProcessor] STEP 7: COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/ [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:09 min [INFO] Finished at: 2021-03-30T09:47:32+02:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.13.0.Final:build (default) on project openshift-quickstart-13: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.container.image.openshift.deployment.OpenshiftProcessor#openshiftBuildFromJar threw an exception: java.lang.IllegalStateException: Build:custom-1 failed! Dockerfile build strategy has failed. [ERROR] at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftBuild(OpenshiftProcessor.java:444) [ERROR] at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.lambda$openshiftBuild$10(OpenshiftProcessor.java:389) [ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) [ERROR] at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) [ERROR] at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) [ERROR] at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) [ERROR] at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) [ERROR] at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) [ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) [ERROR] at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) [ERROR] at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [ERROR] at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) [ERROR] at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftBuild(OpenshiftProcessor.java:389) [ERROR] at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.createContainerImage(OpenshiftProcessor.java:340) [ERROR] at io.quarkus.container.image.openshift.deployment.OpenshiftProcessor.openshiftBuildFromJar(OpenshiftProcessor.java:257) [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$2.execute(ExtensionLoader.java:920) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) [ERROR] at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:501) ``` ### Actual behavior The build should find the artifacts in the right folder. ## To Reproduce Steps to reproduce the behavior: 1. `mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create -DprojectGroupId=org.acme -DprojectArtifactId=openshift-quickstart -DclassName="org.acme.rest.GreetingResource" -Dpath="/greeting" -Dextensions=openshift` 2. cd `openshift-quickstart` 3. Deploy it using `mvn package -Dquarkus.kubernetes.deploy=true -Dquarkus.openshift.build-strategy=docker` The maven command fails with the exception in the description. ## Environment (please complete the following information): ### Quarkus version or git rev 999-SNAPSHOT or 1.13.0.Final It worked fine using 1.11+ ## Additional context I think that this is a regression issue caused by the new fast jar method. If we change the target folder in the `Dockerfile.jvm` file from `target/quarkus-app` to `target`, then it starts working fine. (Not saying this is the right way to fix it).
f8ce0f26d2fb63bdfc15c449670c2a9651206c57
df695f35e3630c315d6166a6a1da7684d7d83bc0
https://github.com/quarkusio/quarkus/compare/f8ce0f26d2fb63bdfc15c449670c2a9651206c57...df695f35e3630c315d6166a6a1da7684d7d83bc0
diff --git a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java index ed0d451359b..b64ae4b9093 100644 --- a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java +++ b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java @@ -2,6 +2,7 @@ import static io.quarkus.container.image.openshift.deployment.OpenshiftUtils.mergeConfig; import static io.quarkus.container.util.PathsUtil.findMainSourcesRoot; +import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.DEFAULT_FAST_JAR_DIRECTORY_NAME; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -252,7 +253,8 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig, //The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'. //For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement. //For s2i kind of builds where jars are expected directly in the '/' we have to use null. - String contextRoot = config.buildStrategy == BuildStrategy.DOCKER ? "target" : null; + String outputDirName = out.getOutputDirectory().getFileName().toString(); + String contextRoot = getContextRoot(outputDirName, packageConfig.isFastJar(), config.buildStrategy); if (packageConfig.isFastJar()) { createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), jar.getPath().getParent()); @@ -266,6 +268,16 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig, artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap())); } + private String getContextRoot(String outputDirName, boolean isFastJar, BuildStrategy buildStrategy) { + if (buildStrategy != BuildStrategy.DOCKER) { + return null; + } + if (!isFastJar) { + return outputDirName; + } + return outputDirName + "/" + DEFAULT_FAST_JAR_DIRECTORY_NAME; + } + @BuildStep(onlyIf = { IsNormalNotRemoteDev.class, OpenshiftBuild.class, NativeBuild.class }) public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig s2iConfig, ContainerImageConfig containerImageConfig,
['extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java']
{'.java': 1}
1
1
0
0
1
15,622,357
3,041,033
404,245
4,309
736
152
14
1
4,930
297
1,206
63
0
1
2021-04-01T13:19:20
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,796
quarkusio/quarkus/16157/16151
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16151
https://github.com/quarkusio/quarkus/pull/16157
https://github.com/quarkusio/quarkus/pull/16157
1
fixes
OIDC Extension does not work anymore with Azure AD and Quarkus 1.13.0
## Describe the bug Looks like there is a regression when updating from Quarkus `1.12.x` to `1.13.0` We get a `401 Unauthorized` when we try to authenticate through Azure AD with Quarkus OIDC, this used to work fine in the previous versions. I did some debugging and turns out Azure AD doesn't like the chunked transfer headers. I intercepted the requests to Azure AD with ProxyMan and Quarkus running locally. Below are the cURL exports from those requests. Quarkus `1.12.x` ``` curl 'https://login.microsoftonline.com/<<tenant>>/oauth2/v2.0/token' \\ -X POST \\ -H 'Content-Length: 878' \\ -H 'Accept: application/json,application/x-www-form-urlencoded;q=0.9' \\ -H 'Authorization: Basic <<secret>>' \\ -H 'Content-Type: application/x-www-form-urlencoded' \\ -H 'Host: login.microsoftonline.com' \\ --proxy http://localhost:9090 \\ -d 'code=<<code>>&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth&grant_type=authorization_code' ``` Quarkus `1.13.0` ``` curl 'https://login.microsoftonline.com/<<tenant>>/oauth2/v2.0/token' \\ -X POST \\ -H 'Transfer-Encoding: chunked' \\ -H 'Content-Type: application/x-www-form-urlencoded' \\ -H 'User-Agent: Vert.x-WebClient/3.9.5' \\ -H 'Authorization: Basic <<secret>>' \\ -H 'Host: login.microsoftonline.com' \\ --proxy http://localhost:9090 \\ -d 'grant_type=authorization_code&code=<<code>>&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fauth' ``` The last request returns a `404 Not Found` from Azure AD. It looks like that Azure AD doesn't like the chunked transfer encoding from the Vert.x WebClient. If I remove the header `'Transfer-Encoding: chunked'` I can successfully obtain a token with the above cURL request. Can we set some config for the Vert.x WebClient or do we need to dive a bit deeper here? I would be glad to help out and test some more. ### Expected behavior Successful authentication through Azure AD with Quarkus OIDC. ### Actual behavior Quarkus returns a 401 Unauthorized after successfully authenticating to Azure AD as a user. ## To Reproduce Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. Set up a project with Quarkus OIDC 2. Set the needed properties for your OIDC server with Azure AD 3. Try to login with Azure AD 4. You get a 401 Unauthorized from Quarkus ### Configuration ```properties # Add your application.properties here, if applicable. ``` ### Screenshots (If applicable, add screenshots to help explain your problem.) ## Environment (please complete the following information): ### Output of `uname -a` or `ver` ``` Darwin Willems-MBP.i.btp34.nl 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64 ``` ### Output of `java -version` ``` openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode) ``` ### GraalVM version (if different from Java) ### Quarkus version or git rev `1.13.0.FINAL` ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) ``` Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/wjglerum/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home Default locale: en_NL, platform encoding: UTF-8 OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac" ``` ## Additional context (Add any other context about the problem here.)
488d0095555090b5f69a68137302b7543486b5da
9e66209b51251b1d571bbcadd1109cc943b79798
https://github.com/quarkusio/quarkus/compare/488d0095555090b5f69a68137302b7543486b5da...9e66209b51251b1d571bbcadd1109cc943b79798
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 e8b87012149..5f883af8300 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 @@ -70,15 +70,17 @@ public Uni<Tokens> refreshTokens(String refreshToken) { return getJsonResponse(refreshGrantParams, true); } - private Uni<Tokens> getJsonResponse(MultiMap reqBody, boolean refresh) { + private Uni<Tokens> getJsonResponse(MultiMap formBody, boolean refresh) { //Uni needs to be lazy by default, we don't send the request unless //something has subscribed to it. This is important for the CAS state //management in TokensHelper return Uni.createFrom().deferred(new Supplier<Uni<? extends Tokens>>() { @Override public Uni<Tokens> get() { - MultiMap body = reqBody; + MultiMap body = formBody; HttpRequest<Buffer> request = client.postAbs(tokenRequestUri); + request.putHeader(HttpHeaders.CONTENT_TYPE.toString(), + HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED.toString()); if (clientSecretBasicAuthScheme != null) { request.putHeader(AUTHORIZATION_HEADER, clientSecretBasicAuthScheme); } else if (clientJwtKey != null) { @@ -88,7 +90,7 @@ public Uni<Tokens> get() { body.add(OidcConstants.CLIENT_ASSERTION, OidcCommonUtils.signJwtWithKey(oidcConfig, clientJwtKey)); } // Retry up to three times with a one second delay between the retries if the connection is closed - Uni<HttpResponse<Buffer>> response = request.sendForm(body) + Uni<HttpResponse<Buffer>> response = request.sendBuffer(OidcCommonUtils.encodeForm(body)) .onFailure(ConnectException.class) .retry() .atMost(3); 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 b037aeb527f..e9cb3de9363 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 @@ -1,11 +1,13 @@ package io.quarkus.oidc.common.runtime; import java.io.InputStream; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.Key; import java.security.KeyStore; import java.security.PrivateKey; import java.util.Base64; +import java.util.Map; import java.util.Optional; import javax.crypto.SecretKey; @@ -22,8 +24,13 @@ import io.vertx.core.http.HttpClientOptions; import io.vertx.core.json.JsonObject; import io.vertx.core.net.ProxyOptions; +import io.vertx.mutiny.core.MultiMap; +import io.vertx.mutiny.core.buffer.Buffer; public class OidcCommonUtils { + static final byte AMP = '&'; + static final byte EQ = '='; + private OidcCommonUtils() { } @@ -55,6 +62,27 @@ public static String prependSlash(String path) { return !path.startsWith("/") ? "/" + path : path; } + public static Buffer encodeForm(MultiMap form) { + Buffer buffer = Buffer.buffer(); + for (Map.Entry<String, String> entry : form) { + if (buffer.length() != 0) { + buffer.appendByte(AMP); + } + buffer.appendString(entry.getKey()); + buffer.appendByte(EQ); + buffer.appendString(urlEncode(entry.getValue())); + } + return buffer; + } + + public static String urlEncode(String value) { + try { + return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + public static void setHttpClientOptions(OidcCommonConfig oidcConfig, TlsConfig tlsConfig, HttpClientOptions options) { boolean trustAll = oidcConfig.tls.verification.isPresent() ? oidcConfig.tls.verification.get() == Verification.NONE : tlsConfig.trustAll; 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 fa5aeba7b3e..dc927bf2177 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 @@ -4,8 +4,6 @@ import static io.quarkus.oidc.runtime.OidcIdentityProvider.REFRESH_TOKEN_GRANT_RESPONSE; import java.net.URI; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.security.Permission; import java.util.ArrayList; import java.util.List; @@ -28,6 +26,7 @@ import io.quarkus.oidc.OidcTenantConfig.Authentication; import io.quarkus.oidc.RefreshToken; import io.quarkus.oidc.SecurityEvent; +import io.quarkus.oidc.common.runtime.OidcCommonUtils; import io.quarkus.oidc.common.runtime.OidcConstants; import io.quarkus.runtime.BlockingOperationControl; import io.quarkus.security.AuthenticationCompletionException; @@ -204,20 +203,22 @@ public Uni<ChallengeData> getChallengeInternal(RoutingContext context, TenantCon // client_id codeFlowParams.append(AMP).append(OidcConstants.CLIENT_ID).append(EQ) - .append(urlEncode(configContext.oidcConfig.clientId.get())); + .append(OidcCommonUtils.urlEncode(configContext.oidcConfig.clientId.get())); // scope List<String> scopes = new ArrayList<>(); scopes.add("openid"); configContext.oidcConfig.getAuthentication().scopes.ifPresent(scopes::addAll); - codeFlowParams.append(AMP).append(OidcConstants.TOKEN_SCOPE).append(EQ).append(urlEncode(String.join(" ", scopes))); + codeFlowParams.append(AMP).append(OidcConstants.TOKEN_SCOPE).append(EQ) + .append(OidcCommonUtils.urlEncode(String.join(" ", scopes))); // redirect_uri String redirectPath = getRedirectPath(configContext, context); String redirectUriParam = buildUri(context, isForceHttps(configContext), redirectPath); LOG.debugf("Authentication request redirect_uri parameter: %s", redirectUriParam); - codeFlowParams.append(AMP).append(OidcConstants.CODE_FLOW_REDIRECT_URI).append(EQ).append(urlEncode(redirectUriParam)); + codeFlowParams.append(AMP).append(OidcConstants.CODE_FLOW_REDIRECT_URI).append(EQ) + .append(OidcCommonUtils.urlEncode(redirectUriParam)); // state codeFlowParams.append(AMP).append(OidcConstants.CODE_FLOW_STATE).append(EQ) @@ -226,7 +227,8 @@ public Uni<ChallengeData> getChallengeInternal(RoutingContext context, TenantCon // extra redirect parameters, see https://openid.net/specs/openid-connect-core-1_0.html#AuthRequests if (configContext.oidcConfig.authentication.getExtraParams() != null) { for (Map.Entry<String, String> entry : configContext.oidcConfig.authentication.getExtraParams().entrySet()) { - codeFlowParams.append(AMP).append(entry.getKey()).append(EQ).append(urlEncode(entry.getValue())); + codeFlowParams.append(AMP).append(entry.getKey()).append(EQ) + .append(OidcCommonUtils.urlEncode(entry.getValue())); } } @@ -236,14 +238,6 @@ public Uni<ChallengeData> getChallengeInternal(RoutingContext context, TenantCon authorizationURL)); } - private static String urlEncode(String value) { - try { - return URLEncoder.encode(value, StandardCharsets.UTF_8.name()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - private Uni<SecurityIdentity> performCodeFlow(IdentityProviderManager identityProviderManager, RoutingContext context, TenantConfigContext configContext, String code) { diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java index 8e3eec0b7e5..4e12948ccd0 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java @@ -95,21 +95,22 @@ public Uni<AuthorizationCodeTokens> refreshAuthorizationCodeTokens(String refres return getHttpResponse(metadata.getTokenUri(), refreshGrantParams).transform(resp -> getAuthorizationCodeTokens(resp)); } - private UniOnItem<HttpResponse<Buffer>> getHttpResponse(String uri, MultiMap reqBody) { + private UniOnItem<HttpResponse<Buffer>> getHttpResponse(String uri, MultiMap formBody) { HttpRequest<Buffer> request = client.postAbs(uri); + request.putHeader(HttpHeaders.CONTENT_TYPE.toString(), HttpHeaders.APPLICATION_X_WWW_FORM_URLENCODED.toString()); if (clientSecretBasicAuthScheme != null) { request.putHeader(AUTHORIZATION_HEADER, clientSecretBasicAuthScheme); } else if (clientJwtKey != null) { - reqBody.add(OidcConstants.CLIENT_ASSERTION_TYPE, OidcConstants.JWT_BEARER_CLIENT_ASSERTION_TYPE); - reqBody.add(OidcConstants.CLIENT_ASSERTION, OidcCommonUtils.signJwtWithKey(oidcConfig, clientJwtKey)); + formBody.add(OidcConstants.CLIENT_ASSERTION_TYPE, OidcConstants.JWT_BEARER_CLIENT_ASSERTION_TYPE); + formBody.add(OidcConstants.CLIENT_ASSERTION, OidcCommonUtils.signJwtWithKey(oidcConfig, clientJwtKey)); } else if (OidcCommonUtils.isClientSecretPostAuthRequired(oidcConfig.credentials)) { - reqBody.add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get()); - reqBody.add(OidcConstants.CLIENT_SECRET, OidcCommonUtils.clientSecret(oidcConfig.credentials)); + formBody.add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get()); + formBody.add(OidcConstants.CLIENT_SECRET, OidcCommonUtils.clientSecret(oidcConfig.credentials)); } else { - reqBody.add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get()); + formBody.add(OidcConstants.CLIENT_ID, oidcConfig.clientId.get()); } // Retry up to three times with a one second delay between the retries if the connection is closed. - Uni<HttpResponse<Buffer>> response = request.sendForm(reqBody) + Uni<HttpResponse<Buffer>> response = request.sendBuffer(OidcCommonUtils.encodeForm(formBody)) .onFailure(ConnectException.class) .retry() .atMost(3);
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java', 'extensions/oidc-common/runtime/src/main/java/io/quarkus/oidc/common/runtime/OidcCommonUtils.java', 'extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java', 'extensions/oidc-client/runtime/src/main/java/io/quarkus/oidc/client/runtime/OidcClientImpl.java']
{'.java': 4}
4
4
0
0
4
15,616,682
3,040,093
404,130
4,308
4,335
919
73
4
3,746
469
1,063
91
4
6
2021-03-31T17:01:08
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,797
quarkusio/quarkus/16069/16042
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16042
https://github.com/quarkusio/quarkus/pull/16069
https://github.com/quarkusio/quarkus/pull/16069
1
fixes
[native] kafka-snappy integration-test fails with org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY]
## Describe the bug When running `integration-tests/kafka-snappy` in native mode with `-Dtest-containers` and latest Graal VM 21.1-dev it fails to run the IT tests on the native image with an error failing to load a native library. ### Expected behavior IT tests run fine on the native image ### Actual behavior ``` [INFO] Running io.quarkus.it.kafka.KafkaSnappyProducerITCase 2021-03-26 10:39:25,374 WARN [io.qua.deployment] (main) Producing values from constructors and fields is no longer supported and will be removed in a future release: io.quarkus.deployment.annotations.BuildProducer io.quarkus.it.classtransformer.ClassTransformerProcessor.transformers Executing [/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/target/quarkus-integration-test-kafka-snappy-999-SNAPSHOT-runner, -Dquarkus.http.port=8081, -Dquarkus.http.ssl-port=8444, -Dtest.url=http://localhost:8081, -Dquarkus.log.file.path=/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/target/quarkus.log, -Dquarkus.log.file.enable=true, -Dquarkus.kubernetes-service-binding.root=/home/sgehwolf/Documents/openjdk/quarkus/quarkus-source/integration-tests/kafka-snappy/src/test/resources/k8s-sb] Mar 26, 2021 10:39:29 AM io.quarkus.runtime.ApplicationLifecycleManager run ERROR: Failed to start application (with profile prod) org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=x86_64 at io.quarkus.kafka.client.runtime.KafkaRecorder.loadSnappy(KafkaRecorder.java:39) at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy_0(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:67) at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:40) at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:378) at io.quarkus.runtime.Application.start(Application.java:90) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100) at io.quarkus.runtime.Quarkus.run(Quarkus.java:66) at io.quarkus.runtime.Quarkus.run(Quarkus.java:42) at io.quarkus.runtime.Quarkus.run(Quarkus.java:119) at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29) [ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 2, Time elapsed: 17.952 s <<< FAILURE! - in io.quarkus.it.kafka.KafkaSnappyProducerITCase [ERROR] io.quarkus.it.kafka.KafkaSnappyProducerITCase.health Time elapsed: 0.01 s <<< ERROR! java.lang.RuntimeException: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details at io.quarkus.test.junit.NativeTestExtension.throwBootFailureException(NativeTestExtension.java:158) at io.quarkus.test.junit.NativeTestExtension.beforeEach(NativeTestExtension.java:56) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:159) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:158) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:125) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162) at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548) Caused by: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details at io.quarkus.test.common.LauncherUtil.waitForCapturedListeningData(LauncherUtil.java:73) at io.quarkus.test.common.NativeImageLauncher.start(NativeImageLauncher.java:116) at io.quarkus.test.junit.IntegrationTestUtil.startLauncher(IntegrationTestUtil.java:124) at io.quarkus.test.junit.NativeTestExtension.doNativeStart(NativeTestExtension.java:126) at io.quarkus.test.junit.NativeTestExtension.ensureStarted(NativeTestExtension.java:92) at io.quarkus.test.junit.NativeTestExtension.beforeAll(NativeTestExtension.java:65) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$8(ClassBasedTestDescriptor.java:368) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:368) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:192) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136) ... 34 more ``` ## To Reproduce 1. Set up Graal VM or Mandrel so as to being able to build with `-Dnative` 2. `$ ./mvnw clean verify -Dnative -Dtest-containers -pl integration-tests/kafka-snappy/` ## Environment (please complete the following information): Linux, Java 11, x86_64 ### GraalVM version (if different from Java) 21.1-dev ### Quarkus version or git rev main, revision 320a6322df01ffe6b981a002cd8ca77c0cdab560 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) $ ./mvnw --version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /home/sgehwolf/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3 Java version: 11.0.10, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-1.fc33.x86_64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.11.8-200.fc33.x86_64", arch: "amd64", family: "unix" ## Additional context It also fails the native integration tests of quarkus main with graal vm main. For example here: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/687103625 (native tests: Messaging)
ec42e1e30c006859b0ad39712d5d1475b34a0d9d
1bf98031472bd0687229bb930e41e710ebba50d2
https://github.com/quarkusio/quarkus/compare/ec42e1e30c006859b0ad39712d5d1475b34a0d9d...1bf98031472bd0687229bb930e41e710ebba50d2
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 128cc21e640..6b90114830e 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 @@ -46,6 +46,7 @@ import org.jboss.jandex.DotName; import org.jboss.jandex.Type; import org.jboss.jandex.Type.Kind; +import org.xerial.snappy.OSInfo; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; @@ -199,7 +200,7 @@ private void handleSnappy(BuildProducer<ReflectiveClassBuildItem> reflectiveClas String path = root + dir + "/" + snappyNativeLibraryName; nativeLibs.produce(new NativeImageResourceBuildItem(path)); } else { // otherwise the native lib of the platform this build runs on - String dir = getOs() + "/" + getArch(); + String dir = OSInfo.getNativeLibFolderPathForCurrentOS(); String snappyNativeLibraryName = System.mapLibraryName("snappyjava"); if (snappyNativeLibraryName.toLowerCase().endsWith(".dylib")) { snappyNativeLibraryName = snappyNativeLibraryName.replace(".dylib", ".jnilib"); @@ -414,23 +415,4 @@ void registerServiceBinding(Capabilities capabilities, KafkaBindingConverter.class.getName())); } } - - public static String getArch() { - String osArch = System.getProperty("os.arch"); - return osArch.replaceAll("\\\\W", ""); - } - - static String getOs() { - String osName = System.getProperty("os.name"); - - if (osName.contains("Windows")) { - return "Windows"; - } else if (osName.contains("Mac")) { - return "Mac"; - } else if (osName.contains("Linux")) { - return "Linux"; - } else { - return osName.replaceAll("\\\\W", ""); - } - } }
['extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaProcessor.java']
{'.java': 1}
1
1
0
0
1
15,486,394
3,016,019
401,128
4,279
705
151
22
1
11,115
457
2,599
124
2
1
2021-03-27T12:07:56
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,798
quarkusio/quarkus/16048/16047
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16047
https://github.com/quarkusio/quarkus/pull/16048
https://github.com/quarkusio/quarkus/pull/16048
1
resolves
Hot Reload: class redefinition failed: attempted to delete a method
## Describe the bug I have the following class in my project: ``` public class GreetingResource { private static final String CONST = "4"; public void help() { } } ``` I changed the CONST and removed the `help` method at the same time. A hot reload triggered the exception from below. ### Expected behavior No exception during hot reload. ### Actual behavior ``` 2021-03-26 13:26:19,160 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (vert.x-worker-thread-15) Changed source files detected, recompiling [C:\\workspaces\\aviator\\hot-reload-static-final\\src\\main\\java\\org\\acme\\GreetingResource.java] 2021-03-26 13:26:19,220 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (vert.x-worker-thread-15) Application restart not required, replacing classes via instrumentation 2021-03-26 13:26:19,221 ERROR [io.qua.dep.dev.RuntimeUpdatesProcessor] (vert.x-worker-thread-15) Failed to replace classes via instrumentation: java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses0(Native Method) at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:193) at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:236) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:62) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:52) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) ``` ## To Reproduce Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific). Or attach an archive containing the reproducer to the issue. Steps to reproduce the behavior: 1. Download the reproducer: [hot-reload-static-final.zip](https://github.com/quarkusio/quarkus/files/6211804/hot-reload-static-final.zip) 2. mvn quarkus:dev 3. In GreetingResource, change the value of CONST, and remove the "help()" Method. 4. Go to http://localhost:8080/hello 5. Exception from above happens ## Environment (please complete the following information): ### Output of `uname -a` or `ver` MSYS_NT-10.0 NANB7NLNVP2 2.10.0(0.325/5/3) 2018-06-13 23:34 x86_64 Msys ### Output of `java -version` java version "1.8.0_271" Java(TM) SE Runtime Environment (build 1.8.0_271-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode) ### Quarkus version or git rev 1.13.0.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\\eclipse\\tools\\apache-maven\\bin\\.. Java version: 11.0.7, vendor: Azul Systems, Inc., runtime: C:\\eclipse\\tools\\zulu11.39.15-ca-jdk11.0.7-win_x64 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
6f176fff681ac4de5448b58ee8fec522efc3c16e
f89bf8e4a355da770f7325209725f2bece6415f8
https://github.com/quarkusio/quarkus/compare/6f176fff681ac4de5448b58ee8fec522efc3c16e...f89bf8e4a355da770f7325209725f2bece6415f8
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/ClassComparisonUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/ClassComparisonUtil.java index afb543f8dc5..81850cefc40 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/ClassComparisonUtil.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/ClassComparisonUtil.java @@ -52,9 +52,14 @@ static boolean isSameStructure(ClassInfo clazz, ClassInfo old) { return false; } } - for (MethodInfo method : clazz.methods()) { + List<MethodInfo> methods = clazz.methods(); + List<MethodInfo> oldMethods = old.methods(); + if (methods.size() != oldMethods.size()) { + return false; + } + for (MethodInfo method : methods) { MethodInfo om = null; - for (MethodInfo i : old.methods()) { + for (MethodInfo i : oldMethods) { if (!i.name().equals(method.name())) { continue; }
['core/deployment/src/main/java/io/quarkus/deployment/dev/ClassComparisonUtil.java']
{'.java': 1}
1
1
0
0
1
15,486,394
3,016,019
401,128
4,279
391
78
9
1
3,422
287
918
72
2
2
2021-03-26T13:21:29
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,799
quarkusio/quarkus/16038/15817
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/15817
https://github.com/quarkusio/quarkus/pull/16038
https://github.com/quarkusio/quarkus/pull/16038
1
fixes
Quarkus maven plugin does not take pluginRepositories into consideration
## Describe the bug The Quarkus maven plugin downloads dependencies of the project. Unfortunately, it does not take into consideration the project's `pluginRepositories`. As a result, if there is a plugin that is not available in maven central, the Quarkus maven plugin fails, despite there is a `pluginRepository` defined that contains this plugin. To illustrate the situation, the reproducer (see below) uses the `jboss-parent` as its parent pom.xml. The `jboss-parent` overrides the `maven-compiler-plugin` version to `3.8.1-jboss-1`, which is available only in the JBoss Nexus. The `jboss-parent` defines a `pluginRepository` that points to the JBoss Nexus. Thus, while the `mvn clean install` completes successfully, `mvn quarkus:dev` does not. If the project defines the JBoss Nexus as a `repository` (and not a `pluginRepository`!), the `mvn quarkus:dev` downloads the dependency and runs successfully. ### Expected behavior Successfully run the application. ### Actual behavior Failed to execute goal io.quarkus:quarkus-maven-plugin:1.12.2.Final:dev (default-cli) on project quarkus-maven-plugin-reproducer: Failed to obtain descriptor for Maven plugin org.apache.maven.plugins:maven-compiler-plugin:3.8.1-jboss-1 goal compile: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.8.1-jboss-1 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.1-jboss-1 in central (https://repo.maven.apache.org/maven2) ## To Reproduce 1. erase the `maven-compiler-plugin:3.8.1-jboss-1` from your local maven repository 2. git clone https://github.com/rsynek/quarkus-maven-plugin-reproducer && cd quarkus-maven-plugin-reproducer 3. mvn quarkus:dev ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) maven ## Additional context
23b3435d0cae0fe428d7cf031a57809c0d510fc9
237ab55118f583e84ef9617f19a6756b06d56cb1
https://github.com/quarkusio/quarkus/compare/23b3435d0cae0fe428d7cf031a57809c0d510fc9...237ab55118f583e84ef9617f19a6756b06d56cb1
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 0978339a704..38bad7177a3 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -229,6 +229,9 @@ public class DevMojo extends AbstractMojo { @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true) private List<RemoteRepository> repos; + @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true, required = true) + private List<RemoteRepository> pluginRepos; + /** * This value is intended to be set to true when some generated bytecode * is erroneous causing the JVM to crash when the verify:none option is set (which is on by default) @@ -472,7 +475,7 @@ private Xpp3Dom getPluginConfig(Plugin plugin, String goal) throws MojoExecution private MojoDescriptor getMojoDescriptor(Plugin plugin, String goal) throws MojoExecutionException { try { - return pluginManager.getMojoDescriptor(plugin, goal, repos, repoSession); + return pluginManager.getMojoDescriptor(plugin, goal, pluginRepos, repoSession); } catch (Exception e) { throw new MojoExecutionException( "Failed to obtain descriptor for Maven plugin " + plugin.getId() + " goal " + goal, e);
['devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java']
{'.java': 1}
1
1
0
0
1
15,483,703
3,015,587
401,070
4,279
334
67
5
1
1,860
215
476
28
2
0
2021-03-26T08:21:09
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,778
quarkusio/quarkus/16636/16580
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16580
https://github.com/quarkusio/quarkus/pull/16636
https://github.com/quarkusio/quarkus/pull/16636
1
fixes
devtools - BuildFile - possible NPE
https://github.com/quarkusio/quarkus/blob/main/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java#L131 ```java private boolean isQuarkusExtension(final ArtifactKey key) { if (catalog != null) { return findInList(catalog.getExtensions(), key).isPresent(); } return isDefinedInRegistry(catalog.getExtensions(), key); } ``` `return isDefinedInRegistry(catalog.getExtensions(), key);` would throw NPE for `catalog` if it is reached
ab00a999770437193af1faed733fed6db1ca66ce
c50739036207d6047a9e5e5eef5e7d12c0389e29
https://github.com/quarkusio/quarkus/compare/ab00a999770437193af1faed733fed6db1ca66ce...c50739036207d6047a9e5e5eef5e7d12c0389e29
diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java index b96b4a80471..0e352cef901 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java @@ -17,8 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -129,10 +127,7 @@ protected void writeToProjectFile(final String fileName, final byte[] content) t } private boolean isQuarkusExtension(final ArtifactKey key) { - if (catalog != null) { - return findInList(catalog.getExtensions(), key).isPresent(); - } - return isDefinedInRegistry(catalog.getExtensions(), key); + return catalog != null ? isDefinedInRegistry(catalog.getExtensions(), key) : false; } private Set<ArtifactKey> getDependenciesKeys() throws IOException { @@ -142,11 +137,4 @@ private Set<ArtifactKey> getDependenciesKeys() throws IOException { public static boolean isDefinedInRegistry(Collection<Extension> registry, final ArtifactKey key) { return Extensions.findInList(registry, key).isPresent(); } - - private static Optional<io.quarkus.registry.catalog.Extension> findInList( - Collection<io.quarkus.registry.catalog.Extension> list, final ArtifactKey key) { - ArtifactKey k = new ArtifactKey(key.getGroupId(), key.getArtifactId(), key.getClassifier(), key.getType()); - return list.stream().filter(e -> Objects.equals(e.getArtifact().getKey(), k)).findFirst(); - } - }
['independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/BuildFile.java']
{'.java': 1}
1
1
0
0
1
15,843,572
3,083,547
409,611
4,373
733
150
14
1
543
34
126
12
1
1
2021-04-19T20:12: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,777
quarkusio/quarkus/16648/16537
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16537
https://github.com/quarkusio/quarkus/pull/16648
https://github.com/quarkusio/quarkus/pull/16648
1
fix
Dev UI: exception related to log streaming
Looking at the reproducer for https://github.com/quarkusio/quarkus/issues/16534, and hitting `http://localhost:8080/weather` and `http://localhost:8080/q/dev/io.quarkus.quarkus-cache/caches` I've seen this exception several times: ``` 2021-04-15 10:31:27,668 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-13) HTTP Request to /q/dev/logstream failed, error id: 890ea464-d38e-457e-b1cd-71ca5a3e8133-2: java.lang.IllegalStateException: Request has already been read at io.vertx.core.http.impl.Http1xServerRequest.checkEnded(Http1xServerRequest.java:628) at io.vertx.core.http.impl.Http1xServerRequest.handler(Http1xServerRequest.java:288) at io.vertx.core.http.impl.Http1xServerRequest.webSocket(Http1xServerRequest.java:423) at io.vertx.core.http.impl.Http1xServerRequest.webSocket(Http1xServerRequest.java:413) at io.vertx.core.http.impl.Http1xServerRequest.toWebSocket(Http1xServerRequest.java:402) at io.vertx.core.http.HttpServerRequest.toWebSocket(HttpServerRequest.java:367) at io.quarkus.vertx.http.runtime.AbstractRequestWrapper.toWebSocket(AbstractRequestWrapper.java:266) at io.vertx.ext.web.impl.HttpServerRequestWrapper.toWebSocket(HttpServerRequestWrapper.java:325) at io.quarkus.vertx.http.runtime.logstream.LogStreamWebSocket.handle(LogStreamWebSocket.java:42) at io.quarkus.vertx.http.runtime.logstream.LogStreamWebSocket.handle(LogStreamWebSocket.java:21) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1129) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151) at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:196) at io.vertx.ext.web.impl.RouterImpl.handleContext(RouterImpl.java:236) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1129) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:336) at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:314) at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1129) at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151) at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:86) at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$3.handle(VertxHttpHotReplacementSetup.java:75) at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:124) at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) ``` Steps to reproduce: - Start `cache-quickstart` in the dev mode - Open `http://localhost:8080/weather` - Open `http://localhost:8080/q/dev/io.quarkus.quarkus-cache/caches`
4856fc1fa9f5fb2445b500c7e356fa1d9d65761a
cd3088e8f84588943ef67bcb7aa0a5e3c57282df
https://github.com/quarkusio/quarkus/compare/4856fc1fa9f5fb2445b500c7e356fa1d9d65761a...cd3088e8f84588943ef67bcb7aa0a5e3c57282df
diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/logstream/LogStreamWebSocket.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/logstream/LogStreamWebSocket.java index 6fcdb3f6a24..fb5accc5c7a 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/logstream/LogStreamWebSocket.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/logstream/LogStreamWebSocket.java @@ -38,7 +38,7 @@ public LogStreamWebSocket(HistoryHandler historyHandler) { @Override public void handle(RoutingContext event) { - if ("websocket".equalsIgnoreCase(event.request().getHeader(HttpHeaderNames.UPGRADE))) { + if ("websocket".equalsIgnoreCase(event.request().getHeader(HttpHeaderNames.UPGRADE)) && !event.request().isEnded()) { event.request().toWebSocket(new Handler<AsyncResult<ServerWebSocket>>() { @Override public void handle(AsyncResult<ServerWebSocket> event) {
['extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/logstream/LogStreamWebSocket.java']
{'.java': 1}
1
1
0
0
1
15,844,770
3,083,726
409,642
4,373
223
44
2
1
3,596
120
883
45
5
1
2021-04-20T06:41:56
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,776
quarkusio/quarkus/16664/16662
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16662
https://github.com/quarkusio/quarkus/pull/16664
https://github.com/quarkusio/quarkus/pull/16664
1
fixes
io.netty.util.Version#identify not working in uber-jars
## Describe the bug When packaging a Quarkus application as an [uber-jar](https://quarkus.io/guides/maven-tooling#uber-jar-maven) the [io.netty.util.Version#identify](https://netty.io/4.1/api/io/netty/util/Version.html#identify--) method returns an empty map instead of the versions of the included netty artifacts. The reason is that each Netty artifact contains a `META-INF/io.netty.versions` which is not included in the uber-jar. `io.netty.util.Version#identify` not reporting the actual Netty version for example prevents the app from being monitored via Dynatrace. ### Expected behavior The fat-jar includes a `META-INF/io.netty.versions` file which contains the merged content of all `META-INF/io.netty.versions` of the included netty artifacts to ensure the correct behaviour of the method [io.netty.util.Version#identify](https://netty.io/4.1/api/io/netty/util/Version.html#identify--). ### Actual behavior When programmatically executing [io.netty.util.Version#identify](https://netty.io/4.1/api/io/netty/util/Version.html#identify--) an empty map is returned instead of the version. We also see the following Dynatrace error in the logs: ``` 2021-04-12 14:13:41.565 UTC [57bf881a] warning [java ] [agent ] Failed to detect Netty version 2021-04-12 14:13:41.649 UTC [57bf881a] warning [java ] [netty ] Caught exception in IntrospectionBase java.lang.NullPointerException at com.compuware.apm.agent.introspection.netty.NettyIntrospection$1.run(NettyIntrospection.java:167) at com.compuware.apm.agent.introspection.IntrospectionBase.introspect(IntrospectionBase.java:300) at com.compuware.apm.agent.introspection.IntrospectionBase.introspect(IntrospectionBase.java:213) at com.compuware.apm.agent.introspection.netty.NettyIntrospection.HttpRequestReceivedEnter(NettyIntrospection.java:158) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61) at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Unknown Source) ``` ## To Reproduce Steps to reproduce the behavior: 1. download and unzip this sample application [netty-version-uberjar.zip](https://github.com/quarkusio/quarkus/files/6346243/netty-version-uberjar.zip) 2. run `mvn compile quarkus:dev` which will print something like: ``` __ ____ __ _____ ___ __ ____ ______ --/ __ \\/ / / / _ | / _ \\/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\\ \\ --\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/ 2021-04-20 21:27:41,146 INFO [io.quarkus] (Quarkus Main Thread) netty-version-uberjar 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.13.2.Final) started in 4.023s. Listening on: http://localhost:8080 2021-04-20 21:27:41,166 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2021-04-20 21:27:41,168 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi] ************************************ Netty Versions: {netty-buffer=netty-buffer-4.1.49.Final.d0ec961, netty-codec=netty-codec-4.1.49.Final.d0ec961, netty-codec-dns=netty-codec-dns-4.1.49.Final.d0ec961, netty-codec-http=netty-codec-http-4.1.49.Final.d0ec961, netty-codec-http2=netty-codec-http2-4.1.49.Final.d0ec961, netty-codec-socks=netty-codec-socks-4.1.49.Final.d0ec961, netty-common=netty-common-4.1.49.Final.d0ec961, netty-handler=netty-handler-4.1.49.Final.d0ec961, netty-handler-proxy=netty-handler-proxy-4.1.49.Final.d0ec961, netty-resolver=netty-resolver-4.1.49.Final.d0ec961, netty-resolver-dns=netty-resolver-dns-4.1.49.Final.d0ec961, netty-transport=netty-transport-4.1.49.Final.d0ec961} ************************************ ``` 3. create the uberjar using `mvn package` 4. run `java -jar target\\netty-version-uberjar-1.0.0-SNAPSHOT-runner.jar` which will print something like: ``` __ ____ __ _____ ___ __ ____ ______ --/ __ \\/ / / / _ | / _ \\/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\\ \\ --\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/ 2021-04-20 21:29:04,225 INFO [io.quarkus] (main) netty-version-uberjar 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.13.2.Final) started in 2.060s. Listening on: http://0.0.0.0:8080 2021-04-20 21:29:04,257 INFO [io.quarkus] (main) Profile prod activated. 2021-04-20 21:29:04,259 INFO [io.quarkus] (main) Installed features: [cdi] ************************************ Netty Versions: {} ************************************ 2021-04-20 21:29:04,298 INFO [io.quarkus] (main) netty-version-uberjar stopped in 0.033s ``` ## Environment (please complete the following information): ### Output of `uname -a` or `ver` Linux app-31-rq52p 3.10.0-1160.6.1.el7.x86_64 #1 SMP Wed Oct 21 13:44:38 EDT 2020 x86_64 GNU/Linux ### Output of `java -version` openjdk version "11.0.10" 2021-01-19 LTS ### Quarkus version or git rev Quarkus 1.13.2.Final ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
0892d85985fc63eb44348ab0213a2e52d5ca79c2
524a9fd83eb3bde5619ecbe38eb18e091016accf
https://github.com/quarkusio/quarkus/compare/0892d85985fc63eb44348ab0213a2e52d5ca79c2...524a9fd83eb3bde5619ecbe38eb18e091016accf
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java index ea1637face8..66d638de248 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java @@ -41,6 +41,7 @@ import java.util.function.BiPredicate; import java.util.function.BooleanSupplier; import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.stream.Collectors; @@ -106,6 +107,8 @@ public class JarResultBuildStep { "META-INF/LICENSE", "META-INF/LICENSE.txt", "META-INF/LICENSE.md", + "META-INF/LGPL-3.0.txt", + "META-INF/ASL-2.0.txt", "META-INF/NOTICE", "META-INF/NOTICE.txt", "META-INF/NOTICE.md", @@ -115,7 +118,6 @@ public class JarResultBuildStep { "META-INF/DEPENDENCIES", "META-INF/DEPENDENCIES.txt", "META-INF/beans.xml", - "META-INF/io.netty.versions.properties", "META-INF/quarkus-config-roots.list", "META-INF/quarkus-javadoc.properties", "META-INF/quarkus-extension.properties", @@ -127,6 +129,14 @@ public class JarResultBuildStep { "META-INF/build.metadata", // present in the Red Hat Build of Quarkus "LICENSE"); + private static final Predicate<String> CONCATENATED_ENTRIES_PREDICATE = new Predicate<>() { + @Override + public boolean test(String path) { + return "META-INF/io.netty.versions.properties".equals(path) || + (path.startsWith("META-INF/services/") && path.length() > 18); + } + }; + private static final Logger log = Logger.getLogger(JarResultBuildStep.class); // we shouldn't have to specify these flags when opening a ZipFS (since they are the default ones), but failure to do so // makes a subsequent uberJar creation fail in java 8 (but works fine in Java 11) @@ -296,7 +306,7 @@ private void buildUberJar0(CurateOutcomeBuildItem curateOutcomeBuildItem, final Map<String, String> seen = new HashMap<>(); final Map<String, Set<AppDependency>> duplicateCatcher = new HashMap<>(); - final Map<String, List<byte[]>> services = new HashMap<>(); + final Map<String, List<byte[]>> concatenatedEntries = new HashMap<>(); Set<String> finalIgnoredEntries = new HashSet<>(IGNORED_ENTRIES); packageConfig.userConfiguredIgnoredEntries.ifPresent(finalIgnoredEntries::addAll); @@ -323,13 +333,13 @@ private void buildUberJar0(CurateOutcomeBuildItem curateOutcomeBuildItem, if (!Files.isDirectory(resolvedDep)) { try (FileSystem artifactFs = ZipUtils.newFileSystem(resolvedDep)) { for (final Path root : artifactFs.getRootDirectories()) { - walkFileDependencyForDependency(root, runnerZipFs, seen, duplicateCatcher, services, + walkFileDependencyForDependency(root, runnerZipFs, seen, duplicateCatcher, concatenatedEntries, finalIgnoredEntries, appDep, transformedFromThisArchive); } } } else { walkFileDependencyForDependency(resolvedDep, runnerZipFs, seen, duplicateCatcher, - services, finalIgnoredEntries, appDep, transformedFromThisArchive); + concatenatedEntries, finalIgnoredEntries, appDep, transformedFromThisArchive); } } } @@ -342,7 +352,8 @@ private void buildUberJar0(CurateOutcomeBuildItem curateOutcomeBuildItem, } } } - copyCommonContent(runnerZipFs, services, applicationArchivesBuildItem, transformedClasses, generatedClasses, + copyCommonContent(runnerZipFs, concatenatedEntries, applicationArchivesBuildItem, transformedClasses, + generatedClasses, generatedResources, seen, finalIgnoredEntries); } @@ -376,7 +387,7 @@ private static boolean includeAppDep(AppDependency appDep, Optional<Set<AppArtif } private void walkFileDependencyForDependency(Path root, FileSystem runnerZipFs, Map<String, String> seen, - Map<String, Set<AppDependency>> duplicateCatcher, Map<String, List<byte[]>> services, + Map<String, Set<AppDependency>> duplicateCatcher, Map<String, List<byte[]>> concatenatedEntries, Set<String> finalIgnoredEntries, AppDependency appDep, Set<String> transformedFromThisArchive) throws IOException { final Path metaInfDir = root.resolve("META-INF"); Files.walkFileTree(root, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, @@ -409,8 +420,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) boolean transformed = transformedFromThisArchive != null && transformedFromThisArchive.contains(relativePath); if (!transformed) { - if (relativePath.startsWith("META-INF/services/") && relativePath.length() > 18) { - services.computeIfAbsent(relativePath, (u) -> new ArrayList<>()) + if (CONCATENATED_ENTRIES_PREDICATE.test(relativePath)) { + concatenatedEntries.computeIfAbsent(relativePath, (u) -> new ArrayList<>()) .add(Files.readAllBytes(file)); return FileVisitResult.CONTINUE; } else if (!finalIgnoredEntries.contains(relativePath)) { @@ -420,11 +431,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) seen.put(relativePath, appDep.toString()); Files.copy(file, runnerZipFs.getPath(relativePath), StandardCopyOption.REPLACE_EXISTING); - } else if (!relativePath.endsWith(".class")) { - //for .class entries we warn as a group - log.warn("Duplicate entry " + relativePath + " entry from " + appDep - + " will be ignored. Existing file was provided by " - + seen.get(relativePath)); } } } @@ -1066,7 +1072,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) } } - private void copyCommonContent(FileSystem runnerZipFs, Map<String, List<byte[]>> services, + private void copyCommonContent(FileSystem runnerZipFs, Map<String, List<byte[]>> concatenatedEntries, ApplicationArchivesBuildItem appArchives, TransformedClassesBuildItem transformedClassesBuildItem, List<GeneratedClassBuildItem> generatedClasses, List<GeneratedResourceBuildItem> generatedResources, Map<String, String> seen, @@ -1110,8 +1116,8 @@ private void copyCommonContent(FileSystem runnerZipFs, Map<String, List<byte[]>> if (Files.exists(target)) { continue; } - if (i.getName().startsWith("META-INF/services")) { - services.computeIfAbsent(i.getName(), (u) -> new ArrayList<>()).add(i.getClassData()); + if (i.getName().startsWith("META-INF/services/")) { + concatenatedEntries.computeIfAbsent(i.getName(), (u) -> new ArrayList<>()).add(i.getClassData()); } else { try (final OutputStream os = wrapForJDK8232879(Files.newOutputStream(target, DEFAULT_OPEN_OPTIONS))) { os.write(i.getClassData()); @@ -1120,10 +1126,10 @@ private void copyCommonContent(FileSystem runnerZipFs, Map<String, List<byte[]>> } for (Path root : appArchives.getRootArchive().getRootDirs()) { - copyFiles(root, runnerZipFs, services, ignoredEntries); + copyFiles(root, runnerZipFs, concatenatedEntries, ignoredEntries); } - for (Map.Entry<String, List<byte[]>> entry : services.entrySet()) { + for (Map.Entry<String, List<byte[]>> entry : concatenatedEntries.entrySet()) { try (final OutputStream os = wrapForJDK8232879( Files.newOutputStream(runnerZipFs.getPath(entry.getKey()), DEFAULT_OPEN_OPTIONS))) { for (byte[] i : entry.getValue()) { diff --git a/integration-tests/maven/src/test/resources/projects/reactive-routes/src/main/java/org/acme/reactive/routes/MyDeclarativeRoutes.java b/integration-tests/maven/src/test/resources/projects/reactive-routes/src/main/java/org/acme/reactive/routes/MyDeclarativeRoutes.java index 71579370db6..b7e0454e912 100644 --- a/integration-tests/maven/src/test/resources/projects/reactive-routes/src/main/java/org/acme/reactive/routes/MyDeclarativeRoutes.java +++ b/integration-tests/maven/src/test/resources/projects/reactive-routes/src/main/java/org/acme/reactive/routes/MyDeclarativeRoutes.java @@ -2,6 +2,7 @@ import javax.enterprise.context.ApplicationScoped; +import io.netty.util.Version; import io.quarkus.vertx.web.Route; import io.vertx.ext.web.RoutingContext; @@ -23,4 +24,11 @@ public void greetings(RoutingContext rc) { } rc.response().end("hello " + name); } + + @Route(path = "/netty-version", methods = HttpMethod.GET) + public void nettyVersion(RoutingContext rc) { + rc.response().end(Version.identify().containsKey("netty-common") + ";" + + Version.identify().containsKey("netty-handler") + ";" + + Version.identify().containsKey("netty-codec")); + } } diff --git a/integration-tests/maven/src/test/resources/projects/reactive-routes/src/test/java/org/acme/reactive/routes/RouteTest.java b/integration-tests/maven/src/test/resources/projects/reactive-routes/src/test/java/org/acme/reactive/routes/RouteTest.java index e1449dd7696..bd4e8aab2d4 100644 --- a/integration-tests/maven/src/test/resources/projects/reactive-routes/src/test/java/org/acme/reactive/routes/RouteTest.java +++ b/integration-tests/maven/src/test/resources/projects/reactive-routes/src/test/java/org/acme/reactive/routes/RouteTest.java @@ -26,6 +26,10 @@ public void testDeclarativeRoutes() { .header("X-Header", "intercepting the request") .statusCode(200) .body(is("hello quarkus")); + + RestAssured.get("/netty-version").then() + .statusCode(200) + .body(is("true;true;true")); } }
['core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java', 'integration-tests/maven/src/test/resources/projects/reactive-routes/src/test/java/org/acme/reactive/routes/RouteTest.java', 'integration-tests/maven/src/test/resources/projects/reactive-routes/src/main/java/org/acme/reactive/routes/MyDeclarativeRoutes.java']
{'.java': 3}
3
3
0
0
3
16,038,439
3,121,813
414,756
4,406
3,312
615
42
1
7,484
510
2,120
97
7
3
2021-04-20T21:12: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,758
quarkusio/quarkus/17279/16954
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16954
https://github.com/quarkusio/quarkus/pull/17279
https://github.com/quarkusio/quarkus/pull/17279
1
fixes
Cannot serialise field parent on object ... as setter and getters were different types
## Env Quarkus Version 1.13.2 on openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment 18.9 (build 11.0.11+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode, sharing) ## Describe the bug ``` [ERROR] testKameletWithProperties Time elapsed: 0.009 s <<< ERROR! java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#build threw an exception: java.lang.RuntimeException: Failed to record call to method public io.quarkus.runtime.RuntimeValue org.apache.camel.quarkus.component.kamelet.KameletRecorder.createTemplateLoaderCustomizer(java.util.List) at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:452) at io.quarkus.deployment.steps.MainClassBuildStep.writeRecordedBytecode(MainClassBuildStep.java:438) at io.quarkus.deployment.steps.MainClassBuildStep.build(MainClassBuildStep.java:170) 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:920) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at java.base/java.lang.Thread.run(Thread.java:829) at org.jboss.threads.JBossThread.run(JBossThread.java:501) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Cannot serialise field parent on object SetBody[exchangeProperty{CamelTimerCounter}] as setter and getters were different types at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadComplexObject(BytecodeRecorderImpl.java:1371) at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadObjectInstanceImpl(BytecodeRecorderImpl.java:956) at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadObjectInstance(BytecodeRecorderImpl.java:548) at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadComplexObject(BytecodeRecorderImpl.java:1114) at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadObjectInstanceImpl(BytecodeRecorderImpl.java:956) at io.quarkus.deployment.recording.BytecodeRecorderImpl.loadObjectInstance(BytecodeRecorderImpl.java:548) at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:447) ... 12 more ```` ## To Reproduce 1. clone https://github.com/lburgazzoli/apache-camel-quarkus/tree/kamelets 2. build the project `mvn install -Pquickly` 3. run the integrtion tests in `integration-tests/kamelet`
7b5a808b217296cdd15910694f7e14fa9443730c
88e771e993341e820606dda43c6958e26089c723
https://github.com/quarkusio/quarkus/compare/7b5a808b217296cdd15910694f7e14fa9443730c...88e771e993341e820606dda43c6958e26089c723
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/recording/PropertyUtils.java b/core/deployment/src/main/java/io/quarkus/deployment/recording/PropertyUtils.java index 0d23928a7f0..835c7aff70a 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/recording/PropertyUtils.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/recording/PropertyUtils.java @@ -28,7 +28,12 @@ public Property[] apply(Class<?> type) { if (i.getName().startsWith("get") && i.getName().length() > 3 && i.getParameterCount() == 0 && i.getReturnType() != void.class) { String name = Character.toLowerCase(i.getName().charAt(3)) + i.getName().substring(4); - getters.put(name, i); + Method existingGetter = getters.get(name); + // In some cases the overridden methods from supertypes can also appear in the array (for some reason). + // We want the most specific methods. + if (existingGetter == null || existingGetter.getReturnType().isAssignableFrom(i.getReturnType())) { + getters.put(name, i); + } } else if (i.getName().startsWith("is") && i.getName().length() > 3 && i.getParameterCount() == 0 && i.getReturnType() == boolean.class) { String name = Character.toLowerCase(i.getName().charAt(2)) + i.getName().substring(3);
['core/deployment/src/main/java/io/quarkus/deployment/recording/PropertyUtils.java']
{'.java': 1}
1
1
0
0
1
16,381,323
3,186,094
422,273
4,455
481
77
7
1
3,218
151
766
47
1
1
2021-05-17T11:20:45
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,759
quarkusio/quarkus/17262/17249
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/17249
https://github.com/quarkusio/quarkus/pull/17262
https://github.com/quarkusio/quarkus/pull/17262
1
fixes
Quarkus 2.0.0.Alpha2 continous testing not working with kotlin kapt plugin
## Describe the bug My code uses the kotlin arrow lib which can optionally use kotlin kapt. Continous testing in quarkus 2.0.0.Alpha2 does not work with kapt enabled but it works with quarkus 1.13.4.Final. ### Expected behavior continous testing will work fine with kapt. ### Actual behavior Continous testing fails with following error: ``` 2021-05-16 11:52:43,714 INFO [io.quarkus] (Quarkus Main Thread) kaptbug 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.0.0.Alpha2) started in 3.239s. Listening on: http://localhost:8080 2021-05-16 11:52:43,721 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2021-05-16 11:52:43,721 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, kotlin, smallrye-context-propagation] 2021-05-16 11:52:43,721 INFO [quarkus] (Quarkus Main Thread) Tests paused, press [r] to resume r 2021-05-16 11:52:47,847 INFO [quarkus] (Quarkus Terminal Reader) Running Tests for the first time 2021-05-16 11:52:48,047 INFO [quarkus] (Test runner thread) Running 0/1. 2021-05-16 11:52:48,125 ERROR [io.qua.test] (Test runner thread) Test GreetingResourceTest#testHelloEndpoint() failed : java.lang.RuntimeException: java.lang.RuntimeException: The test class class org.acme.GreetingResourceTest is not located in any of the directories [classes\\java\\native-integrationTest, classes\\scala\\integration-test, \\test-classes, classes\\kotlin\\native-integration-test, classes\\kotlin\\native-integrationTest, classes\\scala\\integrationTest, classes\\kotlin\\test, classes\\kotlin\\native-test, classes\\java\\native-integration-test, classes\\java\\native-test, classes\\java\\test, classes\\java\\integration-test, classes\\scala\\test, out\\test, classes\\kotlin\\integration-test, classes\\kotlin\\integrationTest, classes\\scala\\native-integrationTest, bin\\test, classes\\java\\integrationTest, classes\\scala\\native-integration-test, classes\\scala\\native-test] at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:693) at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:766) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.api.extension.InvocationInterceptor.interceptTestClassConstructor(InvocationInterceptor.java:72) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:77) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestClassConstructor(ClassBasedTestDescriptor.java:342) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:289) at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:79) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:267) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:259) at java.base/java.util.Optional.orElseGet(Optional.java:369) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:258) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:101) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:100) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84) at io.quarkus.deployment.dev.testing.JunitTestRunner.runTests(JunitTestRunner.java:202) at io.quarkus.deployment.dev.testing.TestRunner.runInternal(TestRunner.java:242) at io.quarkus.deployment.dev.testing.TestRunner$1.run(TestRunner.java:125) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.RuntimeException: The test class class org.acme.GreetingResourceTest is not located in any of the directories [classes\\java\\native-integrationTest, classes\\scala\\integration-test, \\test-classes, classes\\kotlin\\native-integration-test, classes\\kotlin\\native-integrationTest, classes\\scala\\integrationTest, classes\\kotlin\\test, classes\\kotlin\\native-test, classes\\java\\native-integration-test, classes\\java\\native-test, classes\\java\\test, classes\\java\\integration-test, classes\\scala\\test, out\\test, classes\\kotlin\\integration-test, classes\\kotlin\\integrationTest, classes\\scala\\native-integrationTest, bin\\test, classes\\java\\integrationTest, classes\\scala\\native-integration-test, classes\\scala\\native-test] at io.quarkus.test.common.PathTestHelper.getTestClassesLocation(PathTestHelper.java:145) at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:207) at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:661) at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:708) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$8(ClassBasedTestDescriptor.java:368) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:368) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:192) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136) ... 31 more ``` ## To Reproduce [A small reproducer](https://github.com/alexander-dammeier/quarkus-2-alpha2-kaptbug) This is only a project with resteasy, kotlin and gradle from your start coding website. I manually updated to quarkus2.0.0.Alpha2 and added the arrow and kapt dependency. You can simply remove the kapt plugin and the arrow-kapt dependency from the build.gradle file and it will work just fine. ## Environment: ### Output of `uname -a` or `ver` `Microsoft Windows [Version 10.0.19042.985]` The bug also occures in debian in wsl2: `Linux 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux` ### Output of `java -version` ``` java 11.0.1 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode) ``` ### GraalVM version not installed ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) ``` ------------------------------------------------------------ Gradle 6.8.3 ------------------------------------------------------------ Build time: 2021-02-22 16:13:28 UTC Revision: 9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78 Kotlin: 1.4.20 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 11.0.9.1 (Debian 11.0.9.1+1-post-Debian-1deb10u2) OS: Linux 4.19.128-microsoft-standard amd64 ``` ## Additional context The error says nothing about kapt so it took me a while to isolate this bug. I have about 100 kotlin files in my project and i found no pattern which file will occur this error. Maybe it is just the first kotlin file quarkus tries to load. Hope it helps. Keep up the great work!
55bfab4c52d26b10bff3ab0ee201525c5c5788b1
af6081fb924a868f0893eff912c2c0178a63bcf0
https://github.com/quarkusio/quarkus/compare/55bfab4c52d26b10bff3ab0ee201525c5c5788b1...af6081fb924a868f0893eff912c2c0178a63bcf0
diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java b/devtools/gradle/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java index 14a9b066923..203546f978a 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java @@ -112,7 +112,7 @@ public Path appJarOrClasses() { JavaPluginConvention javaConvention = convention.findPlugin(JavaPluginConvention.class); if (javaConvention != null) { final SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); - final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir()); + final String classesPath = QuarkusGradleUtils.getClassesDir(mainSourceSet, jarTask.getTemporaryDir(), false); if (classesPath != null) { classesDir = Paths.get(classesPath); } diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index f49b481eb38..61193bc33db 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -378,7 +378,7 @@ private void addLocalProject(Project project, GradleDevModeLauncher.Builder buil return; } - String classesDir = QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir()); + String classesDir = QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir(), false); if (classesDir == null) { return; } else { @@ -429,7 +429,7 @@ private void addLocalProject(Project project, GradleDevModeLauncher.Builder buil final File testResourcesOutputDir = testSourceSet.getOutput().getResourcesDir(); if (!testSourcePaths.isEmpty() || (testResourcesOutputDir != null && testResourcesOutputDir.exists())) { - String testClassesDir = QuarkusGradleUtils.getClassesDir(testSourceSet, project.getBuildDir()); + String testClassesDir = QuarkusGradleUtils.getClassesDir(testSourceSet, project.getBuildDir(), true); if (testClassesDir != null) { File testClassesDirFile = new File(testClassesDir); if (testClassesDirFile.exists()) { diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java index 99dcdc0c2a1..b83875b915c 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java @@ -56,17 +56,16 @@ public static PathsCollection getOutputPaths(Project project) { return builder.build(); } - public static String getClassesDir(SourceSet sourceSet, File tmpDir) { - return getClassesDir(sourceSet, tmpDir, true); + public static String getClassesDir(SourceSet sourceSet, File tmpDir, boolean test) { + return getClassesDir(sourceSet, tmpDir, true, test); } - public static String getClassesDir(SourceSet sourceSet, File tmpDir, boolean populated) { + public static String getClassesDir(SourceSet sourceSet, File tmpDir, boolean populated, boolean test) { FileCollection classesDirs = sourceSet.getOutput().getClassesDirs(); Set<File> classDirFiles = classesDirs.getFiles(); if (classDirFiles.size() == 1) { return classesDirs.getAsPath(); } - Path classesDir = null; final Iterator<File> i = classDirFiles.iterator(); int dirCount = 0; @@ -84,7 +83,7 @@ public static String getClassesDir(SourceSet sourceSet, File tmpDir, boolean pop //there does not seem to be any sane way of dealing with multiple output dirs, as there does not seem //to be a way to map them. We will need to address this at some point, but for now we just stick them //all in a temp dir - final Path tmpClassesDir = tmpDir.toPath().resolve("quarkus-app-classes"); + final Path tmpClassesDir = tmpDir.toPath().resolve("quarkus-app-classes" + (test ? "-test" : "")); if (!populated) { return tmpClassesDir.toString(); } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java index a6baf03b844..0ada8916845 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java @@ -53,6 +53,9 @@ public final class PathTestHelper { TEST_TO_MAIN_DIR_FRAGMENTS.put( "classes" + File.separator + "java" + File.separator + "native-integration-test", "classes" + File.separator + "java" + File.separator + "main"); + TEST_TO_MAIN_DIR_FRAGMENTS.put( //synthetic tmp dirs when there are multiple outputs + "quarkus-app-classes-test", + "quarkus-app-classes"); //endregion //region Kotlin TEST_TO_MAIN_DIR_FRAGMENTS.put(
['devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java', 'test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java', 'devtools/gradle/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java', 'devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusGradleUtils.java']
{'.java': 4}
4
4
0
0
4
16,413,696
3,191,767
423,025
4,464
1,399
309
15
3
12,158
593
2,830
137
2
3
2021-05-17T01:17:16
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,761
quarkusio/quarkus/17142/17137
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/17137
https://github.com/quarkusio/quarkus/pull/17142
https://github.com/quarkusio/quarkus/pull/17142
1
fixes
Quarkus 2.0.0.Alpha2 : quarkus-bootstrap-maven-plugin fails in camel-quarkus project
## Describe the bug quarkus-bootstrap-maven-plugin is failing in CI builds. Example for kudu extension, if you run mvn test: The maven configuration is : ``` <build> <plugins> <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-bootstrap-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>io.quarkus</groupId> <artifactId>quarkus-extension-processor</artifactId> <version>${quarkus.version}</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build> ``` The [full pom.xml file link](https://github.com/apache/camel-quarkus/blob/camel-main/extensions/kudu/runtime/pom.xml). The CI failure is here : [camel-quarkus CI build](https://github.com/apache/camel-quarkus/runs/2549289503?check_suite_focus=true) When I run with -e in my local machine, this is the log of the error : ``` Execution default of goal io.quarkus:quarkus-bootstrap-maven-plugin:2.0.0.Alpha2:extension-descriptor failed: /home/zbendhib/dev/apache/camel-quarkus/extensions/kudu/client/target/classes -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.quarkus:quarkus-bootstrap-maven-plugin:2.0.0.Alpha2:extension-descriptor (default) on project camel-quarkus-kudu: Execution default of goal io.quarkus:quarkus-bootstrap-maven-plugin:2.0.0.Alpha2:extension-descriptor failed: /home/zbendhib/dev/apache/camel-quarkus/extensions/kudu/client/target/classes at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal io.quarkus:quarkus-bootstrap-maven-plugin:2.0.0.Alpha2:extension-descriptor failed: /home/zbendhib/dev/apache/camel-quarkus/extensions/kudu/client/target/classes at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.nio.file.FileSystemNotFoundException: /home/zbendhib/dev/apache/camel-quarkus/extensions/kudu/client/target/classes at jdk.nio.zipfs.ZipFileSystem.<init> (ZipFileSystem.java:118) at jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem (ZipFileSystemProvider.java:136) at java.nio.file.FileSystems.newFileSystem (FileSystems.java:406) at io.quarkus.maven.ExtensionDescriptorMojo$1.visitEnter (ExtensionDescriptorMojo.java:511) at org.eclipse.aether.graph.DefaultDependencyNode.accept (DefaultDependencyNode.java:343) at org.eclipse.aether.graph.DefaultDependencyNode.accept (DefaultDependencyNode.java:347) at io.quarkus.maven.ExtensionDescriptorMojo.addExtensionDependencies (ExtensionDescriptorMojo.java:536) at io.quarkus.maven.ExtensionDescriptorMojo.execute (ExtensionDescriptorMojo.java:375) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) [ERROR] [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/PluginExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :camel-quarkus-kudu ```
30ee0b715895e741a5c27ed6e5614e3f63ae9cd3
531cfa87dd6dc4521c67f87c1f375eae770a9046
https://github.com/quarkusio/quarkus/compare/30ee0b715895e741a5c27ed6e5614e3f63ae9cd3...531cfa87dd6dc4521c67f87c1f375eae770a9046
diff --git a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java index 6fd82772a2e..f04e504b4d5 100644 --- a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java +++ b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java @@ -18,6 +18,7 @@ import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; +import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace; import io.quarkus.bootstrap.util.DependencyNodeUtils; import io.quarkus.maven.capabilities.CapabilityConfig; import java.io.BufferedReader; @@ -503,11 +504,21 @@ private void addExtensionDependencies(ObjectNode extObject) throws MojoExecution public boolean visitEnter(DependencyNode node) { final org.eclipse.aether.artifact.Artifact a = node.getArtifact(); if (a != null && a.getFile() != null && a.getExtension().equals("jar")) { - final Path p = a.getFile().toPath(); + Path p = a.getFile().toPath(); boolean isExtension = false; if (Files.isDirectory(p)) { isExtension = getExtensionDescriptorOrNull(p) != null; } else { + // in some cases a local dependency might not producing the classes directory + // but assembling the JAR directly using maven plugins + if (!Files.exists(p)) { + final Path workspaceJar = p.getParent().resolve(LocalWorkspace.getFileName(a)); + if (!Files.exists(workspaceJar)) { + getLog().warn("Failed to resolve " + a + ", " + p + " does not exist"); + return true; + } + p = workspaceJar; + } try (FileSystem fs = FileSystems.newFileSystem(p, (ClassLoader) null)) { isExtension = getExtensionDescriptorOrNull(fs.getPath("")) != null; } catch (IOException e) {
['independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java']
{'.java': 1}
1
1
0
0
1
16,327,862
3,175,324
420,964
4,438
840
132
13
1
9,127
395
2,101
121
3
2
2021-05-11T14:13:17
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,762
quarkusio/quarkus/17099/17086
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/17086
https://github.com/quarkusio/quarkus/pull/17099
https://github.com/quarkusio/quarkus/pull/17099
1
fixes
Jacoco Extension does not report on sub projects as of 1.13.3
Describe the bug As of 1.13.3.Final a multi-module project only reports on the code coverage of the project running the Quarkus plugin and not all projects included in the app. Expected behavior Should report on all coverage of modules in the same project Actual behavior As above To Reproduce git clone https://github.com/bcluap/quarkus-examples.git cd quarkus-examples/multi-module mvn clean verify look at ./runnable/target/jacoco-report/index.html If 1.13.2.Final or before is used then the report includes coverage of Module1 and Module2 as well Configuration Nothing abnormal. Screenshots Run the reproducer Environment (please complete the following information): 1.13.3
b9d219c86a527d8126908e4e80f9cc46ebb7b344
9d987abb6464a854e233854d1d4ed7d9a373e5d7
https://github.com/quarkusio/quarkus/compare/b9d219c86a527d8126908e4e80f9cc46ebb7b344...9d987abb6464a854e233854d1d4ed7d9a373e5d7
diff --git a/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java b/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java index bdbc6b480c6..e040fce63c2 100644 --- a/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java +++ b/test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java @@ -14,7 +14,6 @@ import org.codehaus.plexus.util.StringUtils; import org.jacoco.core.instr.Instrumenter; import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator; -import org.jacoco.report.MultiSourceFileLocator; import org.jboss.jandex.ClassInfo; import io.quarkus.bootstrap.model.AppArtifactKey; @@ -103,11 +102,10 @@ public byte[] apply(String className, byte[] bytes) { info.classFiles = classes; Set<String> sources = new HashSet<>(); - MultiSourceFileLocator sourceFileLocator = new MultiSourceFileLocator(4); if (BuildToolHelper.isMavenProject(targetdir.toPath())) { Set<AppArtifactKey> runtimeDeps = new HashSet<>(); for (AppDependency i : curateOutcomeBuildItem.getEffectiveModel().getUserDependencies()) { - runtimeDeps.add(i.getArtifact().getKey()); + runtimeDeps.add(new AppArtifactKey(i.getArtifact().getGroupId(), i.getArtifact().getArtifactId())); } LocalProject project = LocalProject.loadWorkspace(targetdir.toPath()); runtimeDeps.add(project.getKey());
['test-framework/jacoco/deployment/src/main/java/io/quarkus/jacoco/deployment/JacocoProcessor.java']
{'.java': 1}
1
1
0
0
1
16,264,471
3,163,629
419,459
4,427
321
63
4
1
708
91
165
25
1
0
2021-05-10T04:15:44
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,763
quarkusio/quarkus/17026/17020
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/17020
https://github.com/quarkusio/quarkus/pull/17026
https://github.com/quarkusio/quarkus/pull/17026
1
fixes
OIDC does not work with Azure Hosted Keycloak (HTTP Error 411)
## Describe the bug We are hosting our application in Azure, with a Quarkus RESTFul web service using a Keycloak instance via OIDC. When Keycloak is hosted in Azure, we get a 411 error when attempting to retrieve information associated with the logged in user's bearer token. error is as follows: > 2021-04-30 00:15:35,478 DEBUG [io.qua.oid.run.OidcProviderClient] (vert.x-eventloop-thread-10) Request has failed: status: 411, error message: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> > <HTML><HEAD><TITLE>Length Required</TITLE> > <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD> > <BODY><h2>Length Required</h2> > <hr><p>HTTP Error 411. The request must be chunked or have a content length.</p> > </BODY></HTML> The REST call in question fails with a 401 and states not authenticated. The Keycloak instance in question is behind an Azure Front Door (reverse proxy). This issue does not occur with a locally hosted Keycloak, and appears to be related to IIS being a bit strict with RFC compliance. I'm pretty sure this is related to or a similar issue to #16151. Tested with 1.13.2 and 1.13.3, as well as the 2 alpha. ### Expected behavior OIDC should return the user information and acknowledge the user as authenticated. ### Actual behavior Error from the Azure reverse proxy due to missing headers in the HTTP request. ## To Reproduce You need Keycloak or similar deployed in Azure behind a Front Door to make sure you see the behavior which is introduced by that proxy. Not sure how to do a reproducer here. With our existing infrastructure I can run a build to confirm a fix and would be more than happy to assist in any way. ### Configuration ```properties # Relevant Keycloak Configuration (OIDC) quarkus.oidc.enabled=true quarkus.oidc.application-type=service quarkus.oidc.client-id=REDACTED quarkus.oidc.roles.source=accesstoken quarkus.oidc.authentication.user-info-required=true %dev.quarkus.oidc.auth-server-url=https://REDACTED.azurefd.net/auth/realms/REDACTED %dev.quarkus.oidc.credentials.secret=REDACTED ``` ### Screenshots (If applicable, add screenshots to help explain your problem.) ## Environment (please complete the following information): ### Output of `uname -a` or `ver` Microsoft Windows [Version 10.0.19041.928] ### Output of `java -version` openjdk version "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) ### Quarkus version or git rev 1.13.2, 1.13.3 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`) openjdk version "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) ## Additional context (Add any other context about the problem here.)
d0af2ec8774132f129bd167fad5631651c01559f
4be9cefc374f1150ffd2301504d4a95a65e127ec
https://github.com/quarkusio/quarkus/compare/d0af2ec8774132f129bd167fad5631651c01559f...4be9cefc374f1150ffd2301504d4a95a65e127ec
diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java index ce16001bcb4..f6746b6023b 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java @@ -53,7 +53,7 @@ public Uni<JsonWebKeyCache> getJsonWebKeySet() { } public Uni<JsonObject> getUserInfo(String token) { - return client.postAbs(metadata.getUserInfoUri()) + return client.getAbs(metadata.getUserInfoUri()) .putHeader(AUTHORIZATION_HEADER, OidcConstants.BEARER_SCHEME + " " + token) .send().onItem().transform(resp -> getUserInfo(resp)); }
['extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcProviderClient.java']
{'.java': 1}
1
1
0
0
1
16,246,716
3,160,603
419,116
4,428
114
20
2
1
3,037
388
855
66
2
1
2021-05-05T18:06:36
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,764
quarkusio/quarkus/16950/15159
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/15159
https://github.com/quarkusio/quarkus/pull/16950
https://github.com/quarkusio/quarkus/pull/16950
1
resolves
Bean Validation on Vert.x Routes is not automatically mapped to JSON
**Describe the bug** When using constraints on param binding: ``` @Route(produces = "application/json") Person createPerson(@NonNull @Param("id") String primaryKey) { // ... } ``` And calling this route directly from a browser or curl with a wrong value, the output is not mapped to JSON. This is working fine when validating responses: ``` @Route @Valid Uni<Person> createPerson(...) { // ... } ``` If the returned person is not validated, now the output is properly mapped to JSON as expected. Moreover, I didn't need to set the `produces = "application/json"` in the `@Route` annotation. Note that as a workraround, the only way to make this work is to send the HTTP header "ACCEPT: application/json". When using resteasy jackson extension: ``` @Path("/rest-query") public class QueryResource { @GET public Greeting getGreetingWithName(@Pattern(regexp = "ne.*") @NotNull @QueryParam("name") String name) { return new Greeting(name, "hi"); } } ``` This is also working as expected mapping the validation errors into JSON. **Expected behavior** It should map the constraint errors into JSON as done when validating responses and also using other Quarkus extensions like Resteasy. **Actual behavior** The constraint errors are always in HTML format unless you set the HTTP header "ACCEPT: application/json". **Environment (please complete the following information):** - Output of `java -version`: 11 - Quarkus version or git rev: 1.12.0.Final
3d8c3d3d0cb4ea59baf854105383ac056ed221f9
7ad50c63087b5174426cc253c7c3207cf5f6ddfb
https://github.com/quarkusio/quarkus/compare/3d8c3d3d0cb4ea59baf854105383ac056ed221f9...7ad50c63087b5174426cc253c7c3207cf5f6ddfb
diff --git a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java index d75069f9569..02f5bb89f32 100644 --- a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java +++ b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java @@ -180,7 +180,7 @@ class Methods { static final MethodDescriptor VALIDATION_HANDLE_VIOLATION_EXCEPTION = MethodDescriptor .ofMethod(ValidationSupport.class.getName(), "handleViolationException", Void.TYPE.getName(), Methods.VALIDATION_CONSTRAINT_VIOLATION_EXCEPTION, - RoutingContext.class.getName()); + RoutingContext.class.getName(), Boolean.TYPE.getName()); static final MethodDescriptor VALIDATOR_VALIDATE = MethodDescriptor .ofMethod("javax.validation.Validator", "validate", "java.util.Set", diff --git a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java index 5b657ef8a90..d5a94b9e2d9 100644 --- a/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java +++ b/extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java @@ -744,9 +744,11 @@ void implementInvoke(HandlerDescriptor descriptor, BeanInfo bean, MethodInfo met block.assign(res, value); } CatchBlockCreator caught = block.addCatch(Methods.VALIDATION_CONSTRAINT_VIOLATION_EXCEPTION); + boolean forceJsonEncoding = !descriptor.isContentTypeString() && !descriptor.isContentTypeBuffer() + && !descriptor.isContentTypeMutinyBuffer(); caught.invokeStaticMethod( Methods.VALIDATION_HANDLE_VIOLATION_EXCEPTION, - caught.getCaughtException(), invoke.getMethodParam(0)); + caught.getCaughtException(), invoke.getMethodParam(0), invoke.load(forceJsonEncoding)); caught.returnValue(caught.loadNull()); } @@ -1028,7 +1030,7 @@ private ResultHandle getContentToWrite(HandlerDescriptor descriptor, ResultHandl // Encode to Json Methods.setContentTypeToJson(response, writer); // Validate res if needed - if (descriptor.isProducedResponseValidated()) { + if (descriptor.isProducedResponseValidated() && (descriptor.isReturningUni() || descriptor.isReturningMulti())) { return Methods.validateProducedItem(response, writer, res, validatorField, owner); } else { return writer.invokeStaticMethod(Methods.JSON_ENCODE, res); diff --git a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/MultiValidationTest.java b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/MultiValidationTest.java index 07324d60f9d..99c88b953ff 100644 --- a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/MultiValidationTest.java +++ b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/MultiValidationTest.java @@ -49,15 +49,6 @@ public void test() { .body("details", containsString("validation constraint violations")) .body("violations[0].field", containsString("name")) .body("violations[0].message", is(not(emptyString()))); - - // Input parameter violation - HTML - given() - .queryParam("name", "doesNotMatch") - .when() - .get("/query") - .then().statusCode(400) - .body(containsString("ConstraintViolation")) - .body(is(not(emptyString()))); } @ApplicationScoped diff --git a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/SyncValidationTest.java b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/SyncValidationTest.java index ff11ff84bd5..9dd5d07b0bb 100644 --- a/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/SyncValidationTest.java +++ b/extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/SyncValidationTest.java @@ -45,6 +45,25 @@ public void test() { .get("/query") .then().statusCode(200); + // Invalid parameter + given() + .when() + .get("/invalid-param") + .then() + .statusCode(400) + .body("title", containsString("Constraint Violation")) + .body("status", is(400)) + .body("details", containsString("validation constraint violations")) + .body("violations[0].field", containsString("name")) + .body("violations[0].message", is(not(emptyString()))); + + // Invalid parameter - HTML output + get("/invalid-param-html") + .then() + // the return value is ok but the param is invalid + .statusCode(400) + .body(containsString("ConstraintViolation"), is(not(emptyString()))); + // JSON output given() .header("Accept", "application/json") @@ -58,12 +77,6 @@ public void test() { .body("violations[0].field", containsString("name")) .body("violations[0].message", is(not(emptyString()))); - // HTML output - get("/invalid") - .then() - .statusCode(500) - .body(containsString("ConstraintViolation"), is(not(emptyString()))); - given() .header("Accept", "application/json") .when() @@ -89,19 +102,21 @@ public void test() { .body("violations[0].field", containsString("name")) .body("violations[0].message", is(not(emptyString()))); - // Input parameter violation - HTML + // Input parameter violation - JSON given() .queryParam("name", "doesNotMatch") .when() .get("/query") .then().statusCode(400) - .body(containsString("ConstraintViolation")) - .body(is(not(emptyString()))); + .body("title", containsString("Constraint Violation")) + .body("status", is(400)) + .body("details", containsString("validation constraint violations")); } @ApplicationScoped public static class MyRoutes { + @Valid @Route(methods = HttpMethod.GET, path = "/valid") public Greeting getValidGreeting() { return new Greeting("luke", "hello"); @@ -118,11 +133,21 @@ public Greeting getInvalidValidGreeting() { return new Greeting("neo", "hi"); } + @Route + public Greeting invalidParam(@NotNull @Param String name) { + return new Greeting("neo", "hi"); + } + @Route(methods = HttpMethod.GET, path = "/query") public Greeting getGreetingWithName(@Pattern(regexp = "ne.*") @NotNull @Param("name") String name) { return new Greeting(name, "hi"); } + @Route + public String invalidParamHtml(@NotNull @Param String name) { + return "hi"; + } + } public static class Greeting { diff --git a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/ValidationSupport.java b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/ValidationSupport.java index 259568625c4..24217fe968a 100644 --- a/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/ValidationSupport.java +++ b/extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/ValidationSupport.java @@ -64,9 +64,9 @@ private static JsonObject generateJsonResponse(Set<ConstraintViolation<?>> viola return json; } - public static void handleViolationException(ConstraintViolationException ex, RoutingContext rc) { + public static void handleViolationException(ConstraintViolationException ex, RoutingContext rc, boolean forceJsonEncoding) { String accept = rc.request().getHeader(ACCEPT_HEADER); - if (accept != null && accept.contains(APPLICATION_JSON)) { + if (forceJsonEncoding || accept != null && accept.contains(APPLICATION_JSON)) { rc.response().putHeader(RouteHandlers.CONTENT_TYPE, APPLICATION_JSON); JsonObject json = generateJsonResponse(ex.getConstraintViolations(), false); rc.response().setStatusCode(json.getInteger(PROBLEM_STATUS));
['extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/Methods.java', 'extensions/vertx-web/deployment/src/main/java/io/quarkus/vertx/web/deployment/VertxWebProcessor.java', 'extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/SyncValidationTest.java', 'extensions/vertx-web/deployment/src/test/java/io/quarkus/vertx/web/validation/MultiValidationTest.java', 'extensions/vertx-web/runtime/src/main/java/io/quarkus/vertx/web/runtime/ValidationSupport.java']
{'.java': 5}
5
5
0
0
5
16,213,771
3,154,228
418,293
4,421
1,062
187
12
3
1,531
213
341
48
0
3
2021-05-03T14:15: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,766
quarkusio/quarkus/16893/16865
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16865
https://github.com/quarkusio/quarkus/pull/16893
https://github.com/quarkusio/quarkus/pull/16893
1
fixes
Continuous Testing on Windows 10 cmd hang
## Describe the bug When using the new continuous testing features on Windows 10 default terminal (cmd) the terminal hang and you cannot quit it via CTRL-C. ### Expected behavior CTRL-C exit the application. ### Actual behavior CTRL-C has no effect ## To Reproduce Simple project to reproduce the issue [try-continous-testing.zip](https://github.com/quarkusio/quarkus/files/6390500/try-continous-testing.zip) Steps to reproduce the behavior: 1. Start a terminal on Windows 10 via `cmd` 2. Start the application on dev mode : `mvn quarkus:dev` 3. Enable continuous testing : `e` 4. Disable continuous testing: `d` 5. Try to quit the application via CTRL-C ## Environment (please complete the following information): ### Output of `uname -a` or `ver`: Microsoft Windows [version 10.0.19042.867] ### Output of `java -version`: openjdk version "16" 2021-03-16 ### Quarkus version or git rev: 2.0.0.Alpha1 ### Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3
45b205c218112cbd2f47aed4cd8bc3c7dba49aca
f07947ae64df008047197fa95143ad2fab79390e
https://github.com/quarkusio/quarkus/compare/45b205c218112cbd2f47aed4cd8bc3c7dba49aca...f07947ae64df008047197fa95143ad2fab79390e
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java index 8f236cbdc74..5245a2cb912 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java @@ -1,5 +1,9 @@ package io.quarkus.deployment.dev.console; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + import org.aesh.terminal.Attributes; import org.aesh.terminal.Connection; import org.aesh.terminal.tty.Size; @@ -18,6 +22,22 @@ public class AeshConsole extends QuarkusConsole { private String promptMessage; private int totalStatusLines = 0; private int lastWriteCursorX; + /** + * The write queue + * <p> + * Data must be added to this, before it is written out by {@link #deadlockSafeWrite()} + * <p> + * Because Aesh can log deadlocks are possible on windows if a write fails, unless care + * is taken. + */ + private final LinkedBlockingDeque<String> writeQueue = new LinkedBlockingDeque<>(); + private final Lock connectionLock = new ReentrantLock(); + private static final ThreadLocal<Boolean> IN_WRITE = new ThreadLocal<>() { + @Override + protected Boolean initialValue() { + return false; + } + }; public AeshConsole(Connection connection) { INSTANCE = this; @@ -32,28 +52,31 @@ public void run() { }, "Console Shutdown Hoot")); } - private synchronized AeshConsole setStatusMessage(String statusMessage) { - StringBuilder buffer = new StringBuilder(); - clearStatusMessages(buffer); - int newLines = countLines(statusMessage) + countLines(promptMessage); - if (statusMessage == null) { - if (promptMessage != null) { + private AeshConsole setStatusMessage(String statusMessage) { + synchronized (this) { + StringBuilder buffer = new StringBuilder(); + clearStatusMessages(buffer); + int newLines = countLines(statusMessage) + countLines(promptMessage); + if (statusMessage == null) { + if (promptMessage != null) { + newLines += 2; + } + } else if (promptMessage == null) { newLines += 2; + } else { + newLines += 3; } - } else if (promptMessage == null) { - newLines += 2; - } else { - newLines += 3; - } - if (newLines > totalStatusLines) { - for (int i = 0; i < newLines - totalStatusLines; ++i) { - buffer.append("\\n"); + if (newLines > totalStatusLines) { + for (int i = 0; i < newLines - totalStatusLines; ++i) { + buffer.append("\\n"); + } } + this.statusMessage = statusMessage; + this.totalStatusLines = newLines; + printStatusAndPrompt(buffer); + writeQueue.add(buffer.toString()); } - this.statusMessage = statusMessage; - this.totalStatusLines = newLines; - printStatusAndPrompt(buffer); - connection.write(buffer.toString()); + deadlockSafeWrite(); return this; } @@ -61,76 +84,110 @@ public AeshInputHolder createHolder(InputHandler inputHandler) { return new AeshInputHolder(inputHandler); } - private synchronized AeshConsole setPromptMessage(String promptMessage) { - StringBuilder buffer = new StringBuilder(); - clearStatusMessages(buffer); - int newLines = countLines(statusMessage) + countLines(promptMessage); - if (statusMessage == null) { - if (promptMessage != null) { + private AeshConsole setPromptMessage(String promptMessage) { + synchronized (this) { + StringBuilder buffer = new StringBuilder(); + clearStatusMessages(buffer); + int newLines = countLines(statusMessage) + countLines(promptMessage); + if (statusMessage == null) { + if (promptMessage != null) { + newLines += 2; + } + } else if (promptMessage == null) { newLines += 2; + } else { + newLines += 3; } - } else if (promptMessage == null) { - newLines += 2; - } else { - newLines += 3; - } - if (newLines > totalStatusLines) { - for (int i = 0; i < newLines - totalStatusLines; ++i) { - buffer.append("\\n"); + if (newLines > totalStatusLines) { + for (int i = 0; i < newLines - totalStatusLines; ++i) { + buffer.append("\\n"); + } } + this.promptMessage = promptMessage; + this.totalStatusLines = newLines; + printStatusAndPrompt(buffer); + writeQueue.add(buffer.toString()); } - this.promptMessage = promptMessage; - this.totalStatusLines = newLines; - printStatusAndPrompt(buffer); - connection.write(buffer.toString()); + deadlockSafeWrite(); return this; } - private synchronized void end(Connection conn) { - conn.write(ANSI.MAIN_BUFFER); - conn.write(ANSI.CURSOR_SHOW); + private void end(Connection conn) { conn.setAttributes(attributes); - conn.write("\\u001B[0m"); + StringBuilder sb = new StringBuilder(); + sb.append(ANSI.MAIN_BUFFER); + sb.append(ANSI.CURSOR_SHOW); + sb.append("\\u001B[0m"); + writeQueue.add(sb.toString()); + deadlockSafeWrite(); } - private void setup(Connection conn) { - size = conn.size(); - // Ctrl-C ends the game - conn.setSignalHandler(event -> { - switch (event) { - case INT: - //todo: why does async exit not work here - //Quarkus.asyncExit(); - //end(conn); - new Thread(new Runnable() { - @Override - public void run() { - System.exit(0); - } - }).start(); - break; + private void deadlockSafeWrite() { + for (;;) { + //after we have unlocked we always need to check again + //another thread may have added something to the queue after our last write but before + //we unlocked. Checking again makes sure we are safe + if (writeQueue.isEmpty()) { + return; } - }); - // Keyboard handling - conn.setStdinHandler(keys -> { - InputHolder handler = inputHandlers.peek(); - if (handler != null) { - handler.handler.handleInput(keys); + if (connectionLock.tryLock()) { + //we need to guard against Aesh logging something if there is a problem + //it results in an infinite loop otherwise + IN_WRITE.set(true); + try { + while (!writeQueue.isEmpty()) { + String s = writeQueue.poll(); + connection.write(s); + } + } finally { + IN_WRITE.set(false); + connectionLock.unlock(); + } } - }); + } + } - conn.setCloseHandler(close -> end(conn)); - conn.setSizeHandler(size -> setup(conn)); + private void setup(Connection conn) { + synchronized (this) { + size = conn.size(); + // Ctrl-C ends the game + conn.setSignalHandler(event -> { + switch (event) { + case INT: + //todo: why does async exit not work here + //Quarkus.asyncExit(); + //end(conn); + new Thread(new Runnable() { + @Override + public void run() { + System.exit(0); + } + }).start(); + break; + } + }); + // Keyboard handling + conn.setStdinHandler(keys -> { + InputHolder handler = inputHandlers.peek(); + if (handler != null) { + handler.handler.handleInput(keys); + } + }); - //switch to alternate buffer - //conn.write(ANSI.ALTERNATE_BUFFER); - //conn.write(ANSI.CURSOR_HIDE); + conn.setCloseHandler(close -> end(conn)); + conn.setSizeHandler(size -> setup(conn)); - attributes = conn.enterRawMode(); + //switch to alternate buffer + //conn.write(ANSI.ALTERNATE_BUFFER); + //conn.write(ANSI.CURSOR_HIDE); - StringBuilder sb = new StringBuilder(); - printStatusAndPrompt(sb); - conn.write(sb.toString()); + attributes = conn.enterRawMode(); + + StringBuilder sb = new StringBuilder(); + printStatusAndPrompt(sb); + writeQueue.add(sb.toString()); + } + deadlockSafeWrite(); } /** @@ -193,54 +250,59 @@ int countLines(String s, int cursorPos) { return lines; } - public synchronized void write(String s) { - if (outputFilter != null) { - if (!outputFilter.test(s)) { - return; - } + public void write(String s) { + if (IN_WRITE.get()) { + return; } StringBuilder buffer = new StringBuilder(); - clearStatusMessages(buffer); - int cursorPos = lastWriteCursorX; - gotoLine(buffer, size.getHeight()); - String stripped = stripAnsiCodes(s); - int lines = countLines(s, cursorPos); - int trailing = 0; - int index = stripped.lastIndexOf("\\n"); - if (index == -1) { - trailing = stripped.length(); - } else { - trailing = stripped.length() - index - 1; - } + synchronized (this) { + if (outputFilter != null) { + if (!outputFilter.test(s)) { + return; + } + } + clearStatusMessages(buffer); + int cursorPos = lastWriteCursorX; + gotoLine(buffer, size.getHeight()); + String stripped = stripAnsiCodes(s); + int lines = countLines(s, cursorPos); + int trailing = 0; + int index = stripped.lastIndexOf("\\n"); + if (index == -1) { + trailing = stripped.length(); + } else { + trailing = stripped.length() - index - 1; + } - int newCursorPos; - if (lines == 0) { - newCursorPos = trailing + cursorPos; - } else { - newCursorPos = trailing; - } + int newCursorPos; + if (lines == 0) { + newCursorPos = trailing + cursorPos; + } else { + newCursorPos = trailing; + } - if (cursorPos > 1 && lines == 0) { + if (cursorPos > 1 && lines == 0) { + buffer.append(s); + lastWriteCursorX = newCursorPos; + //partial line, just write it + connection.write(buffer.toString()); + return; + } + if (lines == 0) { + lines++; + } + //move the existing content up by the number of lines + int appendLines = cursorPos > 1 ? lines - 1 : lines; + for (int i = 0; i < appendLines; ++i) { + buffer.append("\\n"); + } + buffer.append("\\033[").append(size.getHeight() - totalStatusLines - lines).append(";").append(0).append("H"); buffer.append(s); lastWriteCursorX = newCursorPos; - //partial line, just write it - connection.write(buffer.toString()); - return; - } - if (lines == 0) { - lines++; + printStatusAndPrompt(buffer); + writeQueue.add(buffer.toString()); } - //move the existing content up by the number of lines - int appendLines = cursorPos > 1 ? lines - 1 : lines; - for (int i = 0; i < appendLines; ++i) { - buffer.append("\\n"); - } - buffer.append("\\033[").append(size.getHeight() - totalStatusLines - lines).append(";").append(0).append("H"); - buffer.append(s); - lastWriteCursorX = newCursorPos; - printStatusAndPrompt(buffer); - connection.write(buffer.toString()); - + deadlockSafeWrite(); } public void write(byte[] buf, int off, int len) {
['core/deployment/src/main/java/io/quarkus/deployment/dev/console/AeshConsole.java']
{'.java': 1}
1
1
0
0
1
16,123,312
3,137,038
416,413
4,412
11,552
2,211
288
1
1,035
142
270
32
1
0
2021-04-29T01:59:00
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,767
quarkusio/quarkus/16823/16754
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16754
https://github.com/quarkusio/quarkus/pull/16823
https://github.com/quarkusio/quarkus/pull/16823
1
fixes
404 error from resources declared in javax.ws.rs.core.Application#getClasses
I'm trying to upgrade to **1.13.2.Final** and use the ability to limit the JAX-RS resources introduced by [this](https://github.com/quarkusio/quarkus/pull/14207) feature, but the declared resources in the overriden ``javax.ws.rs.core.Application#getClasses`` method return 404 error. If i do not override ``getClasses`` (or return an empty set, which as far as i understand is equivalent), the endpoints work as expected. #### To Reproduce You can use [this](https://github.com/blxbrgld/jaxrs-application) sample. ``/api/test`` is the endpoint that returns the 404 error.
82477c6476ccf4aa8facdf49f776cb09e185a4be
57bc865baddf7a88e776d8e344d576712ef8954b
https://github.com/quarkusio/quarkus/compare/82477c6476ccf4aa8facdf49f776cb09e185a4be...57bc865baddf7a88e776d8e344d576712ef8954b
diff --git a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java index cf5e28f75f0..c149679b7ab 100755 --- a/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java +++ b/extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java @@ -13,6 +13,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.BiFunction; @@ -236,7 +237,8 @@ public void build( final Collection<AnnotationInstance> allPaths; if (filterClasses) { allPaths = paths.stream().filter( - annotationInstance -> keepEnclosingClass(allowedClasses, excludedClasses, annotationInstance)) + annotationInstance -> keepAnnotation(beanArchiveIndexBuildItem.getIndex(), allowedClasses, excludedClasses, + annotationInstance)) .collect(Collectors.toList()); } else { allPaths = new ArrayList<>(paths); @@ -889,21 +891,32 @@ private static Set<String> getExcludedClasses(List<BuildTimeConditionBuildItem> } /** - * @param allowedClasses the classes returned by the methods {@link Application#getClasses()} and - * {@link Application#getSingletons()} to keep. - * @param excludedClasses the classes that have been annotated wih unsuccessful build time conditions and that + * @param index the Jandex index view from which the class information is extracted. + * @param allowedClasses the classes to keep provided by the methods {@link Application#getClasses()} and + * {@link Application#getSingletons()}. + * @param excludedClasses the classes that have been annotated with unsuccessful build time conditions and that * need to be excluded from the list of paths. - * @param annotationInstance the annotation instance from which the enclosing class will be extracted. - * @return {@code true} if the enclosing class of the annotation is part of the allowed classes if not empty - * or if is not part of the excluded classes, {@code false} otherwise. + * @param annotationInstance the annotation instance to test. + * @return {@code true} if the enclosing class of the annotation is a concrete class and is part of the allowed + * classes, or is an interface and at least one concrete implementation is included, or is an abstract class + * and at least one concrete sub class is included, or is not part of the excluded classes, {@code false} otherwise. */ - private static boolean keepEnclosingClass(Set<String> allowedClasses, Set<String> excludedClasses, + private static boolean keepAnnotation(IndexView index, Set<String> allowedClasses, Set<String> excludedClasses, AnnotationInstance annotationInstance) { - final String className = JandexUtil.getEnclosingClass(annotationInstance).toString(); + final ClassInfo classInfo = JandexUtil.getEnclosingClass(annotationInstance); + final String className = classInfo.toString(); if (allowedClasses.isEmpty()) { // No allowed classes have been set, meaning that only excluded classes have been provided. // Keep the enclosing class only if not excluded return !excludedClasses.contains(className); + } else if (Modifier.isAbstract(classInfo.flags())) { + // Only keep the annotation if a concrete implementation or a sub class has been included + return (Modifier.isInterface(classInfo.flags()) ? index.getAllKnownImplementors(classInfo.name()) + : index.getAllKnownSubclasses(classInfo.name())) + .stream() + .filter(clazz -> !Modifier.isAbstract(clazz.flags())) + .map(Objects::toString) + .anyMatch(allowedClasses::contains); } return allowedClasses.contains(className); } diff --git a/extensions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/root/ApplicationTest.java b/extensions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/root/ApplicationTest.java index a8613bd142b..e00eb8b9058 100644 --- a/extensions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/root/ApplicationTest.java +++ b/extensions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/root/ApplicationTest.java @@ -38,7 +38,10 @@ class ApplicationTest { static QuarkusUnitTest runner = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) .addClasses( - ResourceTest1.class, ResourceTest2.class, ResponseFilter1.class, ResponseFilter2.class, + IResourceTest.class, ResourceInheritedInterfaceTest.class, + AResourceTest.class, ResourceInheritedClassTest.class, + ResourceTest1.class, ResourceTest2.class, + ResponseFilter1.class, ResponseFilter2.class, ResponseFilter3.class, ResponseFilter4.class, ResponseFilter5.class, ResponseFilter6.class, Feature1.class, Feature2.class, DynamicFeature1.class, DynamicFeature2.class, ExceptionMapper1.class, ExceptionMapper2.class, AppTest.class)); @@ -76,6 +79,79 @@ void should_not_call_ok_of_resource_2() { .statusCode(Response.Status.SERVICE_UNAVAILABLE.getStatusCode()); } + @DisplayName("Should access to path inherited from an interface") + @Test + void should_call_inherited_from_interface() { + when() + .get("/rt-i/ok") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .body(Matchers.is("ok-i")); + } + + @DisplayName("Should access to path inherited from a class where method is implemented") + @Test + void should_call_inherited_from_class_implemented() { + when() + .get("/rt-a/ok-1") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .body(Matchers.is("ok-a-1")); + } + + @DisplayName("Should access to path inherited from a class where method is overridden") + @Test + void should_call_inherited_from_class_overridden() { + when() + .get("/rt-a/ok-2") + .then() + .statusCode(Response.Status.OK.getStatusCode()) + .body(Matchers.is("ok-a-2")); + } + + @Path("rt-i") + public interface IResourceTest { + + @GET + @Path("ok") + String ok(); + } + + public static class ResourceInheritedInterfaceTest implements IResourceTest { + + @Override + public String ok() { + return "ok-i"; + } + } + + @Path("rt-a") + public abstract static class AResourceTest { + + @GET + @Path("ok-1") + public abstract String ok1(); + + @GET + @Path("ok-2") + public String ok2() { + return "ok-a"; + } + } + + public static class ResourceInheritedClassTest extends AResourceTest { + + @Override + public String ok1() { + return "ok-a-1"; + } + + @Override + public String ok2() { + return "ok-a-2"; + } + } + @Path("rt-1") public static class ResourceTest1 { @@ -224,6 +300,7 @@ public static class AppTest extends Application { public Set<Class<?>> getClasses() { return new HashSet<>( Arrays.asList( + ResourceInheritedInterfaceTest.class, ResourceInheritedClassTest.class, ResourceTest1.class, Feature1.class, ExceptionMapper1.class)); }
['extensions/resteasy/deployment/src/test/java/io/quarkus/resteasy/test/root/ApplicationTest.java', 'extensions/resteasy-server-common/deployment/src/main/java/io/quarkus/resteasy/server/common/deployment/ResteasyServerCommonProcessor.java']
{'.java': 2}
2
2
0
0
2
15,489,869
3,016,720
400,919
4,279
2,758
504
31
1
575
72
148
4
2
0
2021-04-27T07:26: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,769
quarkusio/quarkus/16798/16721
quarkusio
quarkus
https://github.com/quarkusio/quarkus/issues/16721
https://github.com/quarkusio/quarkus/pull/16798
https://github.com/quarkusio/quarkus/pull/16798
1
fixes
[native] kafka integration tests fail to build with GraalVM 20.3
## Describe the bug The kafka integration tests fail to build with GraalVM 20.3 ### Expected behavior Tests should build ### Actual behavior Tests fail to build with: ``` [quarkus-integration-test-kafka-999-SNAPSHOT-runner:20] classlist: 2,345.80 ms, 1.18 GB [quarkus-integration-test-kafka-999-SNAPSHOT-runner:20] setup: 468.04 ms, 1.18 GB Error: Substitution target for io.quarkus.kafka.client.runtime.graal.SubstituteSnappy is invalid as inner class SnappyConstructors in org.apache.kafka.common.record.CompressionType can not be found. Make sure that the inner class is present. com.oracle.svm.core.util.UserError$UserException: Substitution target for io.quarkus.kafka.client.runtime.graal.SubstituteSnappy is invalid as inner class SnappyConstructors in org.apache.kafka.common.record.CompressionType can not be found. Make sure that the inner class is present. at com.oracle.svm.core.util.UserError.abort(UserError.java:68) at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:918) at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:287) at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:265) at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:919) at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:853) at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:554) at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:469) at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Error: Image build request failed with exit status 1 ``` ## To Reproduce ``` ./mvnw clean verify -Dnative -Dnative.surefire.skip \\ -Dquarkus.native.container-build=true \\ -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.3-java11 \\ -pl integration-tests/kafka ``` ## Environment (please complete the following information): | Key | Value | | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | uname -a | Linux 5.11.14-200.fc33.x86_64 #1 SMP Wed Apr 14 15:25:53 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux<br> | | java -version | openjdk version "11.0.10" 2021-01-19<br>OpenJDK Runtime Environment 18.9 (build 11.0.10+9)<br>OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)<br> | | mvnw --version | Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)<br>Maven home: /home/zakkak/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1<br>Java version: 11.0.10, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-0.fc33.x86_64<br>Default locale: en_IE, platform encoding: UTF-8<br>OS name: "linux", version: "5.11.14-200.fc33.x86_64", arch: "amd64", family: "unix"<br> | | Quarkus version | `main` |
daeeecfff794a6e42f896aa28e05ae981391ebcb
da83146bab1a2330e4b59318bde71f699c9c80d7
https://github.com/quarkusio/quarkus/compare/daeeecfff794a6e42f896aa28e05ae981391ebcb...da83146bab1a2330e4b59318bde71f699c9c80d7
diff --git a/extensions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/graal/SubstituteSnappy.java b/extensions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/graal/SubstituteSnappy.java index e29267a9e71..70c79e11914 100644 --- a/extensions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/graal/SubstituteSnappy.java +++ b/extensions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/graal/SubstituteSnappy.java @@ -3,7 +3,6 @@ import static org.apache.kafka.common.record.CompressionType.GZIP; import static org.apache.kafka.common.record.CompressionType.NONE; -import java.lang.invoke.MethodHandle; import java.util.List; import java.util.Map; import java.util.function.BooleanSupplier; @@ -15,8 +14,6 @@ import org.apache.kafka.common.utils.AppInfoParser; import org.graalvm.home.Version; -import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; @@ -26,19 +23,6 @@ * * Remove JMX */ -@TargetClass(value = CompressionType.class, innerClass = "SnappyConstructors", onlyWith = GraalVM20OrEarlier.class) -final class SubstituteSnappy { - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) - static MethodHandle INPUT = null; - - @Alias - @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) - static MethodHandle OUTPUT = null; - -} - final class GraalVM20OrEarlier implements BooleanSupplier { @Override @@ -48,7 +32,7 @@ public boolean getAsBoolean() { } @TargetClass(value = CompressionType.class, onlyWith = GraalVM20OrEarlier.class) -final class FixEnumAccess { +final class SubstituteSnappy { @Substitute public static CompressionType forName(String name) {
['extensions/kafka-client/runtime/src/main/java/io/quarkus/kafka/client/runtime/graal/SubstituteSnappy.java']
{'.java': 1}
1
1
0
0
1
16,091,218
3,130,956
415,689
4,403
594
128
18
1
5,399
243
1,012
48
0
2
2021-04-26T09:16: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