Skip to content

Commit

Permalink
Merge pull request #36898 from gsmet/3.5.1-backports-2
Browse files Browse the repository at this point in the history
3.5.1 backports 2
  • Loading branch information
gsmet authored Nov 7, 2023
2 parents 40ef88a + 17c3e0b commit 6968eff
Show file tree
Hide file tree
Showing 135 changed files with 8,240 additions and 206 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<smallrye-config.version>3.4.1</smallrye-config.version>
<smallrye-health.version>4.0.4</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.6.2</smallrye-open-api.version>
<smallrye-open-api.version>3.7.0</smallrye-open-api.version>
<smallrye-graphql.version>2.5.1</smallrye-graphql.version>
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>6.2.6</smallrye-fault-tolerance.version>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<!-- These 2 properties are used by CreateProjectMojo to add the Maven Wrapper -->
<proposed-maven-version>3.9.5</proposed-maven-version>
<maven-wrapper.version>3.2.0</maven-wrapper.version>
<gradle-wrapper.version>8.3</gradle-wrapper.version>
<gradle-wrapper.version>8.4</gradle-wrapper.version>
<quarkus-gradle-plugin.version>${project.version}</quarkus-gradle-plugin.version>
<quarkus-maven-plugin.version>${project.version}</quarkus-maven-plugin.version>
<maven-plugin-plugin.version>3.8.1</maven-plugin-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,39 +346,36 @@ public static <T> T readConfig(ApplicationModel appModel, LaunchMode launchMode,
private static Map<String, List<String>> getUnavailableConfigServices(ResolvedDependency dep, ClassLoader classLoader)
throws CodeGenException {
try (OpenPathTree openTree = dep.getContentTree().open()) {
return openTree.apply(META_INF_SERVICES, visit -> {
var unavailableServices = new HashMap<String, List<String>>();
openTree.apply(META_INF_SERVICES, visit -> {
if (visit == null) {
// the application module does not include META-INF/services entry
return Map.of();
// the application module does not include META-INF/services entry. Return `null` here, to let
// MultiRootPathTree.apply() look into all roots.
return null;
}
Map<String, List<String>> unavailableServices = Map.of();
var servicesDir = visit.getPath();
for (String serviceClass : CONFIG_SERVICES) {
var serviceFile = servicesDir.resolve(serviceClass);
if (!Files.exists(serviceFile)) {
continue;
}
final List<String> implList;
var unavailableList = unavailableServices.computeIfAbsent(META_INF_SERVICES + serviceClass,
k -> new ArrayList<>());
try {
implList = Files.readAllLines(serviceFile);
Files.readAllLines(serviceFile).stream()
.map(String::trim)
// skip comments and empty lines
.filter(line -> !line.startsWith("#") && !line.isEmpty())
.filter(className -> classLoader.getResource(className.replace('.', '/') + ".class") == null)
.forEach(unavailableList::add);
} catch (IOException e) {
throw new UncheckedIOException("Failed to read " + serviceFile, e);
}
final List<String> unavailableList = new ArrayList<>(implList.size());
for (String impl : implList) {
if (classLoader.getResource(impl.replace('.', '/') + ".class") == null) {
unavailableList.add(impl);
}
}
if (!unavailableList.isEmpty()) {
if (unavailableServices.isEmpty()) {
unavailableServices = new HashMap<>();
}
unavailableServices.put(META_INF_SERVICES + serviceClass, unavailableList);
}
}
return unavailableServices;
// Always return null to let MultiRootPathTree.apply() look into all roots.
return null;
});
return unavailableServices;
} catch (IOException e) {
throw new CodeGenException("Failed to read " + dep.getResolvedPaths(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -139,21 +141,26 @@ List<URL> applicationPropsSources() {

static void configSourcesForApplicationProperties(Set<File> sourceDirectories, Consumer<URL> sourceUrls,
Consumer<ConfigSource> configSourceConsumer, int ordinal, String[] fileExtensions) {
URL[] resourceUrls = sourceDirectories.stream().map(File::toURI)
.map(u -> {
try {
return u.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
})
.toArray(URL[]::new);

for (URL resourceUrl : resourceUrls) {
URLClassLoader classLoader = new URLClassLoader(new URL[] { resourceUrl });
CombinedConfigSourceProvider configSourceProvider = new CombinedConfigSourceProvider(sourceUrls, ordinal,
fileExtensions);
configSourceProvider.getConfigSources(classLoader).forEach(configSourceConsumer);
for (var sourceDir : sourceDirectories) {
var sourceDirPath = sourceDir.toPath();
var locations = new ArrayList<String>();
for (String file : fileExtensions) {
Path resolved = sourceDirPath.resolve(file);
if (Files.exists(resolved)) {
locations.add(resolved.toUri().toString());
}
}
if (!locations.isEmpty()) {
URLClassLoader classLoader;
try {
classLoader = new URLClassLoader(new URL[] { sourceDir.toURI().toURL() });
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
CombinedConfigSourceProvider configSourceProvider = new CombinedConfigSourceProvider(sourceUrls, ordinal,
fileExtensions, locations);
configSourceProvider.getConfigSources(classLoader).forEach(configSourceConsumer);
}
}
}

Expand Down Expand Up @@ -204,11 +211,13 @@ static final class CombinedConfigSourceProvider extends AbstractLocationConfigSo
private final Consumer<URL> sourceUrls;
private final int ordinal;
private final String[] fileExtensions;
private final List<String> locations;

CombinedConfigSourceProvider(Consumer<URL> sourceUrls, int ordinal, String[] fileExtensions) {
CombinedConfigSourceProvider(Consumer<URL> sourceUrls, int ordinal, String[] fileExtensions, List<String> locations) {
this.sourceUrls = sourceUrls;
this.ordinal = ordinal;
this.fileExtensions = fileExtensions;
this.locations = locations;
}

@Override
Expand All @@ -225,8 +234,7 @@ protected ConfigSource loadConfigSource(final URL url, final int ordinal) throws

@Override
public List<ConfigSource> getConfigSources(final ClassLoader classLoader) {
// Note:
return loadConfigSources(getFileExtensions(), ordinal, classLoader);
return loadConfigSources(locations.toArray(new String[0]), ordinal, classLoader);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void generateCode() {

File outputPath = getGeneratedOutputDirectory().get().getAsFile();

getLogger().debug("Will trigger preparing sources for source directory: {} buildDir: {}",
getLogger().debug("Will trigger preparing sources for source directories: {} buildDir: {}",
sourcesDirectories, buildDir.getAbsolutePath());

WorkQueue workQueue = workQueue(configMap, () -> extension().codeGenForkOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
import org.gradle.api.GradleException;
import org.gradle.api.file.FileCollection;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;

import io.quarkus.bootstrap.BootstrapException;
import io.quarkus.bootstrap.app.AugmentAction;
Expand All @@ -36,6 +39,7 @@
public abstract class QuarkusRun extends QuarkusBuildTask {
private final Property<File> workingDirectory;
private final SourceSet mainSourceSet;
private final ListProperty<String> jvmArgs;

@Inject
public QuarkusRun() {
Expand All @@ -50,6 +54,8 @@ public QuarkusRun(String description) {

workingDirectory = objectFactory.property(File.class);
workingDirectory.convention(getProject().provider(() -> QuarkusPluginExtension.getLastFile(getCompilationOutput())));

jvmArgs = objectFactory.listProperty(String.class);
}

/**
Expand All @@ -75,6 +81,22 @@ public void setWorkingDir(String workingDir) {
workingDirectory.set(getProject().file(workingDir));
}

@Input
public ListProperty<String> getJvmArguments() {
return jvmArgs;
}

@Internal
public List<String> getJvmArgs() {
return jvmArgs.get();
}

@SuppressWarnings("unused")
@Option(description = "Set JVM arguments", option = "jvm-args")
public void setJvmArgs(List<String> jvmArgs) {
this.jvmArgs.set(jvmArgs);
}

@TaskAction
public void runQuarkus() {
ApplicationModel appModel = resolveAppModelForBuild();
Expand Down Expand Up @@ -122,6 +144,10 @@ public void accept(Map<String, List> cmds) {
throw new RuntimeException("Should never reach this!");
}
List<String> args = (List<String>) cmd.get(0);
if (getJvmArguments().isPresent() && !getJvmArguments().get().isEmpty()) {
args.addAll(1, getJvmArgs());
}

getProject().getLogger().info("Executing \"" + String.join(" ", args) + "\"");
Path wd = (Path) cmd.get(1);
File wdir = wd != null ? wd.toFile() : workingDirectory.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public void execute() {
} catch (BootstrapException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
// Gradle "abbreviates" the stacktrace to something human-readable, but here the underlying cause might
// get lost in the error output, so add 'e' to the message.
throw new GradleException("Failed to generate sources in the QuarkusPrepare task for " + gav + " due to " + e, e);
throw new GradleException("Failed to generate sources in the QuarkusGenerateCode task for " + gav + " due to " + e,
e);
}
}
}
4 changes: 2 additions & 2 deletions devtools/gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
# https://gradle.org/release-checksums/
distributionSha256Sum=bb09982fdf52718e4c7b25023d10df6d35a5fff969860bdf5a5bd27a3ab27a9e
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion docs/src/main/asciidoc/cache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
////
= Application Data Caching
:extension-status: preview
include::_attributes.adoc[]
:categories: data
:summary: This guide explains how to cache expensive method calls of your CDI beans using simple annotations.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/datasource.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ When using one of the built-in datasource kinds, the JDBC and Reactive drivers a

|`db2`
|`quarkus-jdbc-db2`
a|* JDBC: `com.ibm.db2.jcc.DBDriver`
a|* JDBC: `com.ibm.db2.jcc.DB2Driver`

* XA: `com.ibm.db2.jcc.DB2XADataSource`

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/reactive-event-bus.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ However, it is limited to single-event behavior (no stream) and to local message
== Installing

This mechanism uses the Vert.x EventBus, so you need to enable the `vertx` extension to use this feature.
If you are creating a new project, set the `extensions` parameter are follows:
If you are creating a new project, set the `extensions` parameter as follows:

:create-app-artifact-id: vertx-quickstart
:create-app-extensions: vertx,resteasy-reactive
Expand Down
10 changes: 7 additions & 3 deletions docs/src/main/asciidoc/vertx-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ So use SockJS, you need to configure the bridge, especially the addresses that w

[source, java]
----
package org.acme.vertx;
package org.acme;
import io.vertx.core.Vertx;
import io.vertx.ext.bridge.PermittedOptions;
Expand All @@ -873,9 +873,13 @@ public class SockJsExample {
public void init(@Observes Router router) {
SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
sockJSHandler.bridge(new SockJSBridgeOptions()
Router bridge = sockJSHandler.bridge(new SockJSBridgeOptions()
.addOutboundPermitted(new PermittedOptions().setAddress("ticks")));
router.route("/eventbus/*").handler(sockJSHandler);
router.route("/eventbus/*").subRouter(bridge);
AtomicInteger counter = new AtomicInteger();
vertx.setPeriodic(1000,
ignored -> vertx.eventBus().publish("ticks", counter.getAndIncrement()));
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/writing-extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,7 @@ One of the main things an extension is likely to do is completely separate the c
Frameworks often do parsing/load of configuration on startup that can be done during build time to both reduce the runtime dependencies on frameworks like xml parsers as well as reducing the startup time the parsing incurs.

An example of parsing an XML config file using JAXB is shown in the `TestProcessor#parseServiceXmlConfig` method:

.Parsing an XML Configuration into Runtime XmlConfig Instance
[source,java]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private boolean canReuseObjectMapper(InstanceHandle<ObjectMapper> objectMapperIn
}
// if any Jackson properties were configured, disallow reuse - this is done in order to provide forward compatibility with new Jackson configuration options
for (String propertyName : ConfigProvider.getConfig().getPropertyNames()) {
if (propertyName.startsWith("io.quarkus.jackson")) {
if (propertyName.startsWith("quarkus.jackson")) {
return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions extensions/narayana-lra/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
<artifactId>lra-proxy-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.narayana.rts</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected String getClientName() {

public void propagateToken(ResteasyReactiveClientRequestContext requestContext, String accessToken) {
if (accessToken != null) {
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + accessToken);
requestContext.getHeaders().putSingle(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + accessToken);
} else {
LOG.debugf("Access token is null, aborting the request with HTTP 401 error");
abortRequest(requestContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class AbstractTokenRequestFilter implements ClientRequestFilter

public void propagateToken(ClientRequestContext requestContext, String token) throws IOException {
if (token != null) {
requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + token);
requestContext.getHeaders().putSingle(HttpHeaders.AUTHORIZATION, BEARER_SCHEME_WITH_SPACE + token);
} else {
LOG.debugf("Injected access token is null, aborting the request with HTTP 401 error");
abortRequest(requestContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class JsonWebKeySet {

private Map<String, Key> keysWithKeyId = new HashMap<>();
private Map<String, Key> keysWithThumbprints = new HashMap<>();
private Map<String, Key> keysWithS256Thumbprints = new HashMap<>();
private Map<String, List<Key>> keysWithoutKeyIdAndThumbprint = new HashMap<>();

public JsonWebKeySet(String json) {
Expand All @@ -48,7 +49,12 @@ private void initKeys(String json) {
if (x5t != null && jwkKey.getKey() != null) {
keysWithThumbprints.put(x5t, jwkKey.getKey());
}
if (jwkKey.getKeyId() == null && x5t == null && jwkKey.getKeyType() != null) {
String x5tS256 = ((PublicJsonWebKey) jwkKey)
.getX509CertificateSha256Thumbprint(calculateThumbprintIfMissing);
if (x5tS256 != null && jwkKey.getKey() != null) {
keysWithS256Thumbprints.put(x5tS256, jwkKey.getKey());
}
if (jwkKey.getKeyId() == null && x5t == null && x5tS256 == null && jwkKey.getKeyType() != null) {
List<Key> keys = keysWithoutKeyIdAndThumbprint.get(jwkKey.getKeyType());
if (keys == null) {
keys = new ArrayList<>();
Expand Down Expand Up @@ -76,6 +82,10 @@ public Key getKeyWithThumbprint(String x5t) {
return keysWithThumbprints.get(x5t);
}

public Key getKeyWithS256Thumbprint(String x5tS256) {
return keysWithS256Thumbprints.get(x5tS256);
}

public Key getKeyWithoutKeyIdAndThumbprint(JsonWebSignature jws) {
try {
List<Key> keys = keysWithoutKeyIdAndThumbprint.get(jws.getKeyType());
Expand Down
Loading

0 comments on commit 6968eff

Please sign in to comment.