Skip to content

Commit

Permalink
Merge pull request quarkusio#42272 from gsmet/3.13.1-backports-1
Browse files Browse the repository at this point in the history
[3.13] 3.13.1 backports 1
  • Loading branch information
gsmet authored Aug 2, 2024
2 parents 5f35abd + 38099d1 commit 4ea2c67
Show file tree
Hide file tree
Showing 65 changed files with 747 additions and 344 deletions.
2 changes: 1 addition & 1 deletion .github/native-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
{
"category": "Windows support",
"timeout": 50,
"test-modules": "resteasy-jackson, qute",
"test-modules": "resteasy-jackson, qute, liquibase",
"os-name": "windows-latest"
},
{
Expand Down
4 changes: 2 additions & 2 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<extension>
<groupId>com.gradle</groupId>
<artifactId>quarkus-build-caching-extension</artifactId>
<version>1.6</version>
<version>1.7</version>
</extension>
<extension>
<groupId>io.quarkus.develocity</groupId>
<artifactId>quarkus-project-develocity-extension</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</extension>
</extensions>
21 changes: 8 additions & 13 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<bouncycastle.tls.fips.version>1.0.19</bouncycastle.tls.fips.version>
<expressly.version>5.0.0</expressly.version>
<findbugs.version>3.0.2</findbugs.version>
<jandex.version>3.2.0</jandex.version>
<jandex.version>3.2.1</jandex.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<javax.inject.version>1</javax.inject.version>
<parsson.version>1.1.6</parsson.version>
<parsson.version>1.1.7</parsson.version>
<resteasy-microprofile.version>2.1.5.Final</resteasy-microprofile.version>
<resteasy-spring-web.version>3.1.3.Final</resteasy-spring-web.version>
<resteasy.version>6.2.9.Final</resteasy.version>
Expand Down Expand Up @@ -51,7 +51,7 @@
<microprofile-lra.version>2.0</microprofile-lra.version>
<microprofile-openapi.version>3.1.1</microprofile-openapi.version>
<smallrye-common.version>2.5.0</smallrye-common.version>
<smallrye-config.version>3.9.0</smallrye-config.version>
<smallrye-config.version>3.9.1</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.10.0</smallrye-open-api.version>
Expand Down Expand Up @@ -6431,16 +6431,11 @@
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>${opentelemetry-semconv.version}</version>
<exclusions>
<exclusion>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-bom</artifactId>
</exclusion>
<exclusion>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv-incubating</artifactId>
<version>${opentelemetry-semconv.version}</version>
</dependency>

<!-- JDK Flight Recorder -->
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<scala-plugin.version>${scala-maven-plugin.version}</scala-plugin.version>

<!-- Jandex versions -->
<jandex.version>3.2.0</jandex.version>
<jandex.version>3.2.1</jandex.version>
<jandex-gradle-plugin.version>1.0.0</jandex-gradle-plugin.version>

<asciidoctorj.version>2.5.13</asciidoctorj.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkus.deployment;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem;

public class SecureRandomProcessor {

@BuildStep
void registerReflectiveMethods(BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods) {
// Called reflectively through java.security.SecureRandom.SecureRandom()
reflectiveMethods.produce(new ReflectiveMethodBuildItem("sun.security.provider.NativePRNG", "<init>",
java.security.SecureRandomParameters.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

Expand Down Expand Up @@ -210,24 +211,20 @@ public int runMainClassBlocking(String... args) throws Exception {
try {
AtomicInteger result = new AtomicInteger();
Class<?> lifecycleManager = Class.forName(ApplicationLifecycleManager.class.getName(), true, runtimeClassLoader);
Method getCurrentApplication = lifecycleManager.getDeclaredMethod("getCurrentApplication");
Object oldApplication = getCurrentApplication.invoke(null);
lifecycleManager.getDeclaredMethod("setDefaultExitCodeHandler", Consumer.class).invoke(null,
new Consumer<Integer>() {
@Override
public void accept(Integer integer) {
result.set(integer);
}
});
// force init here
Class<?> appClass = Class.forName(className, true, runtimeClassLoader);
Method start = appClass.getMethod("main", String[].class);
start.invoke(null, (Object) (args == null ? new String[0] : args));
AtomicBoolean alreadyStarted = new AtomicBoolean();
Method setDefaultExitCodeHandler = lifecycleManager.getDeclaredMethod("setDefaultExitCodeHandler", Consumer.class);
Method setAlreadyStartedCallback = lifecycleManager.getDeclaredMethod("setAlreadyStartedCallback", Consumer.class);

CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
try {
setDefaultExitCodeHandler.invoke(null, (Consumer<Integer>) result::set);
setAlreadyStartedCallback.invoke(null, (Consumer<Boolean>) alreadyStarted::set);
// force init here
Class<?> appClass = Class.forName(className, true, runtimeClassLoader);
Method start = appClass.getMethod("main", String[].class);
start.invoke(null, (Object) (args == null ? new String[0] : args));

CountDownLatch latch = new CountDownLatch(1);
new Thread(() -> {
try {
Class<?> q = Class.forName(Quarkus.class.getName(), true, runtimeClassLoader);
q.getMethod("blockingExit").invoke(null);
Expand All @@ -236,17 +233,19 @@ public void run() {
} finally {
latch.countDown();
}
}).start();
latch.await();

if (alreadyStarted.get()) {
//quarkus was not actually started by the main method
//just return
return 0;
}
}).start();
latch.await();

Object newApplication = getCurrentApplication.invoke(null);
if (oldApplication == newApplication) {
//quarkus was not actually started by the main method
//just return
return 0;
return result.get();
} finally {
setDefaultExitCodeHandler.invoke(null, (Consumer<?>) null);
setAlreadyStartedCallback.invoke(null, (Consumer<?>) null);
}
return result.get();
} finally {
for (var closeTask : runtimeCloseTasks) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
Expand Down Expand Up @@ -51,7 +50,7 @@ public class ApplicationLifecycleManager {

// used by ShutdownEvent to propagate the information about shutdown reason
public static volatile ShutdownEvent.ShutdownReason shutdownReason = ShutdownEvent.ShutdownReason.STANDARD;
private static volatile BiConsumer<Integer, Throwable> defaultExitCodeHandler = new BiConsumer<Integer, Throwable>() {
private static final BiConsumer<Integer, Throwable> MAIN_EXIT_CODE_HANDLER = new BiConsumer<>() {
@Override
public void accept(Integer integer, Throwable cause) {
Logger logger = Logger.getLogger(Application.class);
Expand All @@ -62,6 +61,12 @@ public void accept(Integer integer, Throwable cause) {
System.exit(integer);
}
};
private static final Consumer<Boolean> NOOP_ALREADY_STARTED_CALLBACK = new Consumer<>() {
@Override
public void accept(Boolean t) {
}
};
private static volatile BiConsumer<Integer, Throwable> defaultExitCodeHandler = MAIN_EXIT_CODE_HANDLER;

private ApplicationLifecycleManager() {

Expand All @@ -77,8 +82,9 @@ private ApplicationLifecycleManager() {

private static int exitCode = -1;
private static volatile boolean shutdownRequested;
private static Application currentApplication;
private static volatile Application currentApplication;
private static boolean vmShuttingDown;
private static Consumer<Boolean> alreadyStartedCallback = NOOP_ALREADY_STARTED_CALLBACK;

private static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
private static final boolean IS_MAC = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac");
Expand All @@ -89,17 +95,19 @@ public static void run(Application application, String... args) {

public static void run(Application application, Class<? extends QuarkusApplication> quarkusApplication,
BiConsumer<Integer, Throwable> exitCodeHandler, String... args) {
boolean alreadyStarted;
stateLock.lock();
//in tests, we might pass this method an already started application
//in this case we don't shut it down at the end
boolean alreadyStarted = application.isStarted();
if (shutdownHookThread == null) {
registerHooks(exitCodeHandler == null ? defaultExitCodeHandler : exitCodeHandler);
}
if (currentApplication != null && !shutdownRequested) {
throw new IllegalStateException("Quarkus already running");
}
try {
//in tests, we might pass this method an already started application
//in this case we don't shut it down at the end
alreadyStarted = application.isStarted();
alreadyStartedCallback.accept(alreadyStarted);
if (shutdownHookThread == null) {
registerHooks(exitCodeHandler == null ? defaultExitCodeHandler : exitCodeHandler);
}
if (currentApplication != null && !shutdownRequested) {
throw new IllegalStateException("Quarkus already running");
}
exitCode = -1;
shutdownRequested = false;
currentApplication = application;
Expand Down Expand Up @@ -209,6 +217,7 @@ public static void run(Application application, Class<? extends QuarkusApplicati
int exceptionExitCode = rootCause instanceof PreventFurtherStepsException
? ((PreventFurtherStepsException) rootCause).getExitCode()
: 1;
currentApplication = null;
(exitCodeHandler == null ? defaultExitCodeHandler : exitCodeHandler).accept(exceptionExitCode, e);
return;
} finally {
Expand Down Expand Up @@ -352,7 +361,9 @@ public static boolean isVmShuttingDown() {
* @param defaultExitCodeHandler the new default exit handler
*/
public static void setDefaultExitCodeHandler(BiConsumer<Integer, Throwable> defaultExitCodeHandler) {
Objects.requireNonNull(defaultExitCodeHandler);
if (defaultExitCodeHandler == null) {
defaultExitCodeHandler = MAIN_EXIT_CODE_HANDLER;
}
ApplicationLifecycleManager.defaultExitCodeHandler = defaultExitCodeHandler;
}

Expand All @@ -365,8 +376,18 @@ public static void setDefaultExitCodeHandler(BiConsumer<Integer, Throwable> defa
*
* @param defaultExitCodeHandler the new default exit handler
*/
// Used by StartupActionImpl via reflection
public static void setDefaultExitCodeHandler(Consumer<Integer> defaultExitCodeHandler) {
setDefaultExitCodeHandler((exitCode, cause) -> defaultExitCodeHandler.accept(exitCode));
BiConsumer<Integer, Throwable> biConsumer = defaultExitCodeHandler == null ? null
: (exitCode, cause) -> defaultExitCodeHandler.accept(exitCode);
setDefaultExitCodeHandler(biConsumer);
}

@SuppressWarnings("unused")
// Used by StartupActionImpl via reflection
public static void setAlreadyStartedCallback(Consumer<Boolean> alreadyStartedCallback) {
ApplicationLifecycleManager.alreadyStartedCallback = alreadyStartedCallback != null ? alreadyStartedCallback
: NOOP_ALREADY_STARTED_CALLBACK;
}

/**
Expand Down Expand Up @@ -429,13 +450,15 @@ public void run() {
} finally {
stateLock.unlock();
}
if (currentApplication.isStarted()) {
//take a reliable reference before changing the application state:
final Application app = currentApplication;
if (app.isStarted()) {
// On CLI apps, SIGINT won't call io.quarkus.runtime.Application#stop(),
// making the awaitShutdown() below block the application termination process
// It should be a noop if called twice anyway
currentApplication.stop();
app.stop();
}
currentApplication.awaitShutdown();
app.awaitShutdown();
currentApplication = null;
System.out.flush();
System.err.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

import org.gradle.api.tasks.TaskAction;

import io.quarkus.gradle.dependency.ApplicationDeploymentClasspathBuilder;
import io.quarkus.gradle.tooling.ToolingUtils;
import io.quarkus.runtime.LaunchMode;

public abstract class ImageTask extends QuarkusBuildTask {

private static final String DEPLOYMENT_SUFFIX = "-deployment";
static final String QUARKUS_PREFIX = "quarkus-";
static final String QUARKUS_CONTAINER_IMAGE_PREFIX = "quarkus-container-image-";
static final String QUARKUS_CONTAINER_IMAGE_BUILD = "quarkus.container-image.build";
Expand Down Expand Up @@ -53,10 +58,14 @@ List<Builder> availableBuilders() {
// This will only pickup direct dependencies and not transitives
// This means that extensions like quarkus-container-image-openshift via quarkus-openshift are not picked up
// So, let's relax our filters a bit so that we can pickup quarkus-openshift directly (relax the prefix requirement).
return getProject().getConfigurations().stream().flatMap(c -> c.getDependencies().stream())
return getProject().getConfigurations()
.getByName(ToolingUtils.toDeploymentConfigurationName(
ApplicationDeploymentClasspathBuilder.getFinalRuntimeConfigName(LaunchMode.NORMAL)))
.getDependencies().stream()
.map(d -> d.getName())
.filter(n -> n.startsWith(QUARKUS_CONTAINER_IMAGE_PREFIX) || n.startsWith(QUARKUS_PREFIX))
.map(n -> n.replace(QUARKUS_CONTAINER_IMAGE_PREFIX, "").replace(QUARKUS_PREFIX, ""))
.map(n -> n.replace(QUARKUS_CONTAINER_IMAGE_PREFIX, "").replace(QUARKUS_PREFIX, "").replace(DEPLOYMENT_SUFFIX,
""))
.filter(BUILDERS::containsKey)
.map(BUILDERS::get)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Create a file called `src/main/resources/json-schema.json` with the schema for o
"type": "string",
"description": "The movie's title."
},
"yeay": {
"year": {
"type": "integer",
"description": "The movie's year."
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/mongodb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,14 @@ To set the desired port MongoDB will listen to when it is launched, the followin
[source,java]
----
@QuarkusTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.PORT, value = "27017"))
@WithTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.PORT, value = "27017"))
----
To set the desired MongoDB version that will be launched, the following code should be used:
[source,java]
----
@QuarkusTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.VERSION, value = "V5_0"))
@WithTestResource(value = MongoTestResource.class, initArgs = @ResourceArg(name = MongoTestResource.VERSION, value = "V5_0"))
----
The string value used can be any of one of the `de.flapdoodle.embed.mongo.distribution.Version` or `de.flapdoodle.embed.mongo.distribution.Version.Main` enums.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/native-and-ssl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ which configures our REST client to connect to an SSL REST service.
For the purposes of this guide, we also need to remove the configuration that starts the embedded WireMock server that stubs REST client responses so the tests actually propagate calls to the https://stage.code.quarkus.io/api. Update the test file `src/test/java/org/acme/rest/client/ExtensionsResourceTest.java` and remove the line:
[source,java]
----
@QuarkusTestResource(WireMockExtensions.class)
@WithTestResource(WireMockExtensions.class)
----
from the `ExtensionsResourceTest` class.

Expand Down
28 changes: 28 additions & 0 deletions docs/src/main/asciidoc/rest-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,34 @@ quarkus.rest-client.my-client.url=...

NOTE: MicroProfile REST Client specification does not allow setting proxy credentials. In order to specify proxy user and proxy password programmatically, you need to cast your `RestClientBuilder` to `RestClientBuilderImpl`.

=== Local proxy for dev mode

When using the REST Client in dev mode, Quarkus has the ability to stand up a pass-through proxy which can be used as a target for Wireshark (or similar tools)
in order to capture all the traffic originating from the REST Client (this really makes sense when the REST Client is used against HTTPS services)

To enable this feature, all that needs to be done is set the `enable-local-proxy` configuration option for the configKey corresponding to the client for which proxying is desired.
For example:

[source,properties]
----
quarkus.rest-client.my-client.enable-local-proxy=true
----

When a REST Client does not use a config key (for example when it is created programmatically via `QuarkusRestClientBuilder`) then the class name can be used instead.
For example:

[source,properties]
----
quarkus.rest-client."org.acme.SomeClient".enable-local-proxy=true
----

The port the proxy is listening can be found in startup logs. An example entry is:

[source]
----
Started HTTP proxy server on http://localhost:38227 for REST Client 'org.acme.SomeClient'
----

== Package and run the application

Run the application with:
Expand Down
Loading

0 comments on commit 4ea2c67

Please sign in to comment.