Skip to content

Commit

Permalink
Merge pull request #39560 from gsmet/3.9.0-backports-2
Browse files Browse the repository at this point in the history
3.9.0 backports 2
  • Loading branch information
gsmet committed Mar 20, 2024
2 parents e6e4f9d + 7d30d09 commit 6200585
Show file tree
Hide file tree
Showing 22 changed files with 276 additions and 42 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
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.3.0</smallrye-common.version>
<smallrye-config.version>3.6.1</smallrye-config.version>
<smallrye-config.version>3.7.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 @@ -129,7 +129,7 @@
<cronutils.version>9.2.1</cronutils.version>
<quartz.version>2.3.2</quartz.version>
<h2.version>2.2.224</h2.version> <!-- When updating, needs to be matched in io.quarkus.hibernate.orm.runtime.config.DialectVersions -->
<postgresql-jdbc.version>42.7.2</postgresql-jdbc.version>
<postgresql-jdbc.version>42.7.3</postgresql-jdbc.version>
<mariadb-jdbc.version>3.3.3</mariadb-jdbc.version>
<mysql-jdbc.version>8.3.0</mysql-jdbc.version>
<mssql-jdbc.version>12.6.1.jre11</mssql-jdbc.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import jakarta.annotation.Priority;

import org.eclipse.microprofile.config.spi.Converter;
import org.wildfly.common.net.Inet;

import io.smallrye.common.net.Inet;

/**
* A converter which produces values of type {@link InetAddress}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import jakarta.annotation.Priority;

import org.eclipse.microprofile.config.spi.Converter;
import org.wildfly.common.net.Inet;

import io.smallrye.common.net.Inet;

/**
* A converter which converts a socket address in the form of {@code &lt;host-or-address&gt;[:&lt;port&gt;]} into
Expand Down
2 changes: 1 addition & 1 deletion devtools/gradle/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugin-publish = "1.2.1"

# updating Kotlin here makes QuarkusPluginTest > shouldNotFailOnProjectDependenciesWithoutMain(Path) fail
kotlin = "1.9.23"
smallrye-config = "3.6.1"
smallrye-config = "3.7.0"

junit5 = "5.10.2"
assertj = "3.25.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{#include readme-header /}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{#include index-entry path=resource.path/}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# We need this for compat with older CLI versions
name: resteasy-reactive-codestart
ref: resteasy-reactive
type: code
tags: extension-codestart
metadata:
title: REST
description: Easily start your REST Web Services
related-guide-section: https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources
language:
base:
data:
resource:
class-name: GreetingResource
path: "/hello"
response: "Hello from Quarkus REST"
dependencies:
- io.quarkus:quarkus-rest
test-dependencies:
- io.rest-assured:rest-assured
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("{resource.path}")
public class {resource.class-name} {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "{resource.response}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.acme;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
class {resource.class-name}IT extends {resource.class-name}Test {
// Execute the same tests but in packaged mode.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.acme;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
class {resource.class-name}Test {
@Test
void testHelloEndpoint() {
given()
.when().get("{resource.path}")
.then()
.statusCode(200)
.body(is("{resource.response}"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.acme

import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.Produces
import jakarta.ws.rs.core.MediaType

@Path("{resource.path}")
class {resource.class-name} {

@GET
@Produces(MediaType.TEXT_PLAIN)
fun hello() = "{resource.response}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.acme

import io.quarkus.test.junit.QuarkusIntegrationTest

@QuarkusIntegrationTest
class {resource.class-name}IT : {resource.class-name}Test()
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.acme

import io.quarkus.test.junit.QuarkusTest
import io.restassured.RestAssured.given
import org.hamcrest.CoreMatchers.`is`
import org.junit.jupiter.api.Test

@QuarkusTest
class {resource.class-name}Test {

@Test
fun testHelloEndpoint() {
given()
.`when`().get("{resource.path}")
.then()
.statusCode(200)
.body(`is`("{resource.response}"))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.acme

import jakarta.ws.rs.\{GET, Path, Produces}
import jakarta.ws.rs.core.MediaType

@Path("{resource.path}")
class {resource.class-name} {

@GET
@Produces(Array[String](MediaType.TEXT_PLAIN))
def hello() = "{resource.response}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.acme

import io.quarkus.test.junit.QuarkusIntegrationTest

@QuarkusIntegrationTest
class {resource.class-name}IT extends {resource.class-name}Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.acme

import io.quarkus.test.junit.QuarkusTest
import io.restassured.RestAssured.given
import org.hamcrest.CoreMatchers.`is`
import org.junit.jupiter.api.Test

@QuarkusTest
class {resource.class-name}Test {

@Test
def testHelloEndpoint() = {
given()
.`when`().get("{resource.path}")
.then()
.statusCode(200)
.body(`is`("{resource.response}"))
}

}
8 changes: 7 additions & 1 deletion docs/src/main/asciidoc/building-native-image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,20 @@ The native executable for our application will contain the application code, req

image:native-executable-process.png[Creating a native executable]

If you have generated the application from the previous tutorial, you can find in the `pom.xml` the following _profile_:
If you have generated the application from the previous tutorial, you can find in the `pom.xml` the following Maven profile section:

[source,xml]
----
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigDocDefault;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;
Expand Down Expand Up @@ -72,6 +74,11 @@ public interface OtlpExporterTracesConfig {
@WithName("trust-cert")
TrustCert trustCert();

/**
* Set proxy options
*/
ProxyConfig proxyOptions();

interface KeyCert {
/**
* Comma-separated list of the path to the key files (Pem format).
Expand All @@ -91,6 +98,29 @@ interface TrustCert {
Optional<List<String>> certs();
}

interface ProxyConfig {
/**
* Set proxy username.
*/
Optional<String> username();

/**
* Set proxy password.
*/
Optional<String> password();

/**
* Set proxy port.
*/
@ConfigDocDefault("3128")
OptionalInt port();

/**
* Set proxy host.
*/
Optional<String> host();
}

class Protocol {
public static final String GRPC = "grpc";
public static final String HTTP_PROTOBUF = "http/protobuf";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
Expand Down Expand Up @@ -35,6 +36,7 @@
import io.vertx.core.net.KeyCertOptions;
import io.vertx.core.net.PemKeyCertOptions;
import io.vertx.core.net.PemTrustOptions;
import io.vertx.core.net.ProxyOptions;

@SuppressWarnings("deprecation")
@Recorder
Expand Down Expand Up @@ -201,6 +203,7 @@ public HttpClientOptionsConsumer(OtlpExporterTracesConfig tracesConfig, URI base
@Override
public void accept(HttpClientOptions options) {
configureTLS(options);
configureProxyOptions(options);
}

private void configureTLS(HttpClientOptions options) {
Expand All @@ -218,6 +221,54 @@ private void configureTLS(HttpClientOptions options) {
}
}

private void configureProxyOptions(HttpClientOptions options) {
var proxyConfig = tracesConfig.proxyOptions();
Optional<String> proxyHost = proxyConfig.host();
if (proxyHost.isPresent()) {
ProxyOptions proxyOptions = new ProxyOptions()
.setHost(proxyHost.get());
if (proxyConfig.port().isPresent()) {
proxyOptions.setPort(proxyConfig.port().getAsInt());
}
if (proxyConfig.username().isPresent()) {
proxyOptions.setUsername(proxyConfig.username().get());
}
if (proxyConfig.password().isPresent()) {
proxyOptions.setPassword(proxyConfig.password().get());
}
options.setProxyOptions(proxyOptions);
} else {
configureProxyOptionsFromJDKSysProps(options);
}
}

private void configureProxyOptionsFromJDKSysProps(HttpClientOptions options) {
String proxyHost = options.isSsl()
? System.getProperty("https.proxyHost", "none")
: System.getProperty("http.proxyHost", "none");
String proxyPortAsString = options.isSsl()
? System.getProperty("https.proxyPort", "443")
: System.getProperty("http.proxyPort", "80");
int proxyPort = Integer.parseInt(proxyPortAsString);

if (!"none".equals(proxyHost)) {
ProxyOptions proxyOptions = new ProxyOptions().setHost(proxyHost).setPort(proxyPort);
String proxyUser = options.isSsl()
? System.getProperty("https.proxyUser")
: System.getProperty("http.proxyUser");
if (proxyUser != null && !proxyUser.isBlank()) {
proxyOptions.setUsername(proxyUser);
}
String proxyPassword = options.isSsl()
? System.getProperty("https.proxyPassword")
: System.getProperty("http.proxyPassword");
if (proxyPassword != null && !proxyPassword.isBlank()) {
proxyOptions.setPassword(proxyPassword);
}
options.setProxyOptions(proxyOptions);
}
}

private KeyCertOptions toPemKeyCertOptions() {
OtlpExporterTracesConfig.KeyCert keyCert = tracesConfig.keyCert();
if (keyCert.certs().isEmpty() && keyCert.keys().isEmpty()) {
Expand Down
Loading

0 comments on commit 6200585

Please sign in to comment.