Skip to content

Commit

Permalink
Merge pull request #40125 from gsmet/3.9.4-backports-1
Browse files Browse the repository at this point in the history
[3.9] 3.9.4 backports 1
  • Loading branch information
gsmet authored Apr 18, 2024
2 parents 1337c28 + 1485e97 commit 5be480e
Show file tree
Hide file tree
Showing 49 changed files with 1,119 additions and 420 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
<rest-assured.version>5.4.0</rest-assured.version>
<hamcrest.version>2.2</hamcrest.version><!-- The version needs to be compatible with both REST Assured and Awaitility -->
<junit.jupiter.version>5.10.2</junit.jupiter.version>
<infinispan.version>15.0.0.Final</infinispan.version>
<infinispan.protostream.version>5.0.1.Final</infinispan.protostream.version>
<infinispan.version>15.0.1.Final</infinispan.version>
<infinispan.protostream.version>5.0.2.Final</infinispan.protostream.version>
<caffeine.version>3.1.5</caffeine.version>
<netty.version>4.1.108.Final</netty.version>
<brotli4j.version>1.16.0</brotli4j.version>
Expand Down
24 changes: 24 additions & 0 deletions core/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@

<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>download-signed-jar</id>
<phase>generate-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
<version>6.9.0.202403050737-r</version>
<type>jar</type>
<destFileName>signed.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
Expand Down Expand Up @@ -42,12 +41,12 @@
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import org.jboss.logging.Logger;

Expand Down Expand Up @@ -92,14 +91,14 @@

/**
* This build step builds both the thin jars and uber jars.
*
* <p>
* The way this is built is a bit convoluted. In general, we only want a single one built,
* as determined by the {@link PackageConfig} (unless the config explicitly asks for both of them)
*
* <p>
* However, we still need an extension to be able to ask for a specific one of these despite the config,
* e.g. if a serverless environment needs an uberjar to build its deployment package then we need
* to be able to provide this.
*
* <p>
* To enable this we have two build steps that strongly produce the respective artifact type build
* items, but not a {@link ArtifactResultBuildItem}. We then
* have another two build steps that only run if they are configured to consume these explicit
Expand Down Expand Up @@ -931,7 +930,7 @@ private void copyDependency(Set<ArtifactKey> parentFirstArtifacts, OutputTargetB
} else {
// we copy jars for which we remove entries to the same directory
// which seems a bit odd to me
filterZipFile(resolvedDep, targetPath, removedFromThisArchive);
filterJarFile(resolvedDep, targetPath, removedFromThisArchive);
}
}
}
Expand Down Expand Up @@ -1125,7 +1124,7 @@ private void copyLibraryJars(FileSystem runnerZipFs, OutputTargetBuildItem outpu
+ resolvedDep.getFileName();
final Path targetPath = libDir.resolve(fileName);
classPath.append(" lib/").append(fileName);
filterZipFile(resolvedDep, targetPath, transformedFromThisArchive);
filterJarFile(resolvedDep, targetPath, transformedFromThisArchive);
}
} else {
// This case can happen when we are building a jar from inside the Quarkus repository
Expand Down Expand Up @@ -1240,16 +1239,26 @@ private void handleParent(FileSystem runnerZipFs, String fileName, Map<String, S
}
}

private void filterZipFile(Path resolvedDep, Path targetPath, Set<String> transformedFromThisArchive) {

static void filterJarFile(Path resolvedDep, Path targetPath, Set<String> transformedFromThisArchive) {
try {
byte[] buffer = new byte[10000];
try (ZipFile in = new ZipFile(resolvedDep.toFile())) {
try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetPath.toFile()))) {
Enumeration<? extends ZipEntry> entries = in.entries();
try (JarFile in = new JarFile(resolvedDep.toFile(), false)) {
Manifest manifest = in.getManifest();
if (manifest != null) {
// Remove signature entries
manifest.getEntries().clear();
} else {
manifest = new Manifest();
}
try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(targetPath), manifest)) {
Enumeration<JarEntry> entries = in.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!transformedFromThisArchive.contains(entry.getName())) {
JarEntry entry = entries.nextElement();
String entryName = entry.getName();
if (!transformedFromThisArchive.contains(entryName)
&& !entryName.equals(JarFile.MANIFEST_NAME)
&& !entryName.equals("META-INF/INDEX.LIST")
&& !isSignatureFile(entryName)) {
entry.setCompressedSize(-1);
out.putNextEntry(entry);
try (InputStream inStream = in.getInputStream(entry)) {
Expand All @@ -1258,17 +1267,30 @@ private void filterZipFile(Path resolvedDep, Path targetPath, Set<String> transf
out.write(buffer, 0, r);
}
}
} else {
log.debugf("Removed %s from %s", entryName, resolvedDep);
}
}
}
// let's make sure we keep the original timestamp
Files.setLastModifiedTime(targetPath, Files.getLastModifiedTime(resolvedDep));
}
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}

private static boolean isSignatureFile(String entry) {
entry = entry.toUpperCase();
if (entry.startsWith("META-INF/") && entry.indexOf('/', "META-INF/".length()) == -1) {
return entry.endsWith(".SF")
|| entry.endsWith(".DSA")
|| entry.endsWith(".RSA")
|| entry.endsWith(".EC");
}
return false;
}

/**
* Manifest generation is quite simple : we just have to push some attributes in manifest.
* However, it gets a little more complex if the manifest preexists.
Expand Down Expand Up @@ -1612,12 +1634,8 @@ public boolean downloadIfNecessary() {
"https://repo.maven.apache.org/maven2/org/vineflower/vineflower/%s/vineflower-%s.jar",
context.versionStr, context.versionStr);
try (BufferedInputStream in = new BufferedInputStream(new URL(downloadURL).openStream());
FileOutputStream fileOutputStream = new FileOutputStream(decompilerJar.toFile())) {
byte[] dataBuffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
OutputStream fileOutputStream = Files.newOutputStream(decompilerJar)) {
in.transferTo(fileOutputStream);
return true;
} catch (IOException e) {
log.error("Unable to download Vineflower from " + downloadURL, e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.deployment.pkg.steps;

import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Path;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Test for {@link JarResultBuildStep}
*/
class JarResultBuildStepTest {

@Test
void should_unsign_jar_when_filtered(@TempDir Path tempDir) throws Exception {
Path signedJarFilePath = Path.of(getClass().getClassLoader().getResource("signed.jar").toURI());
Path jarFilePath = tempDir.resolve("unsigned.jar");
JarResultBuildStep.filterJarFile(signedJarFilePath, jarFilePath,
Set.of("org/eclipse/jgit/transport/sshd/SshdSessionFactory.class"));
try (JarFile jarFile = new JarFile(jarFilePath.toFile())) {
assertThat(jarFile.stream().map(JarEntry::getName)).doesNotContain("META-INF/ECLIPSE_.RSA", "META-INF/ECLIPSE_.SF");
// Check that the manifest is still present
Manifest manifest = jarFile.getManifest();
assertThat(manifest.getMainAttributes()).isNotEmpty();
assertThat(manifest.getEntries()).isEmpty();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -687,6 +688,24 @@ private static Handler configureSyslogHandler(final SyslogConfig config, final E
handler.setTruncate(config.truncate);
handler.setUseCountingFraming(config.useCountingFraming);
handler.setLevel(config.level);
if (config.maxLength.isPresent()) {
BigInteger maxLen = config.maxLength.get().asBigInteger();
if (maxLen.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0) {
errorManager.error(
"Using 2GB as the value of maxLength for SyslogHandler as it is the maximum allowed value", null,
ErrorManager.GENERIC_FAILURE);
maxLen = BigInteger.valueOf(Integer.MAX_VALUE);
} else {
BigInteger minimumAllowedMaxLength = BigInteger.valueOf(128);
if (maxLen.compareTo(minimumAllowedMaxLength) < 0) {
errorManager.error(
"Using 128 as the value of maxLength for SyslogHandler as using a smaller value is not allowed",
null, ErrorManager.GENERIC_FAILURE);
maxLen = minimumAllowedMaxLength;
}
}
handler.setMaxLength(maxLen.intValue());
}

Formatter formatter = null;
boolean formatterWarning = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.configuration.MemorySize;

@ConfigGroup
public class SyslogConfig {
Expand Down Expand Up @@ -95,6 +96,15 @@ public class SyslogConfig {
@ConfigItem
Optional<String> filter;

/**
* The maximum length, in bytes, of the message allowed to be sent. The length includes the header and the message.
* <p>
* If not set, the default value is {@code 2048} when {@code sys-log-type} is {@code rfc5424} (which is the default)
* and {@code 1024} when {@code sys-log-type} is {@code rfc3164}
*/
@ConfigItem
Optional<MemorySize> maxLength;

/**
* Syslog async logging config
*/
Expand Down
29 changes: 24 additions & 5 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ public class DevMojo extends AbstractMojo {
private static final String ORG_JETBRAINS_KOTLIN = "org.jetbrains.kotlin";
private static final String KOTLIN_MAVEN_PLUGIN = "kotlin-maven-plugin";

private static final String IO_SMALLRYE = "io.smallrye";
private static final String ORG_JBOSS_JANDEX = "org.jboss.jandex";
private static final String JANDEX_MAVEN_PLUGIN = "jandex-maven-plugin";
private static final String JANDEX = "jandex";

private static final String BOOTSTRAP_ID = "DevMojo";

/**
Expand Down Expand Up @@ -367,6 +362,17 @@ public class DevMojo extends AbstractMojo {
@Component
BuildAnalyticsProvider analyticsProvider;

/**
* A comma-separated list of Maven plugin keys in {@code groupId:artifactId} format
* (for example {@code org.codehaus.mojo:flatten-maven-plugin} and/or goal prefixes,
* (for example {@code flatten}) that should be skipped when {@code quarkus:dev} identifies
* Maven plugin goals that should be executed before the application is launched in dev mode.
* <p>
* Only the {@code flatten} Maven plugin is skipped by default.
*/
@Parameter(defaultValue = "org.codehaus.mojo:flatten-maven-plugin")
Set<String> skipPlugins;

/**
* console attributes, used to restore the console state
*/
Expand Down Expand Up @@ -587,6 +593,12 @@ private String handleAutoCompile() throws MojoExecutionException {
if (p.getExecutions().isEmpty()) {
continue;
}
if (skipPlugins.contains(p.getKey())) {
if (getLog().isDebugEnabled()) {
getLog().debug("Skipping " + p.getId() + " execution according to skipPlugins value");
}
continue;
}
for (PluginExecution e : p.getExecutions()) {
if (e.getPhase() != null && !PRE_DEV_MODE_PHASES.contains(e.getPhase())) {
// skip executions with phases post quarkus:dev, such as install, deploy, site, etc
Expand All @@ -598,6 +610,13 @@ private String handleAutoCompile() throws MojoExecutionException {
String goalPrefix = null;
if (!e.getGoals().isEmpty()) {
goalPrefix = getMojoDescriptor(p, e.getGoals().get(0)).getPluginDescriptor().getGoalPrefix();
if (skipPlugins.contains(goalPrefix)) {
if (getLog().isDebugEnabled()) {
getLog().debug("Skipping " + goalPrefix + " execution according to skipPlugins value");
continue;
}
continue;
}
pluginPrefixes.put(goalPrefix, p);
pluginPrefixes.put(p.getId(), p);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/aws-lambda-http.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Do not change the Lambda handler name.
----
Properties:
Handler: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
Runtime: java11
Runtime: java17
----

This handler is a bridge between the lambda runtime and the Quarkus HTTP framework you are using (Jakarta REST, Servlet, etc.)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/cassandra.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public class FruitDto {

The translation to and from JSON is done automatically by the Quarkus REST (formerly RESTEasy Reactive) extension, which is
included in this guide's pom.xml file. If you want to add it manually to your application, add the
below snippet to your application's ppm.xml file:
below snippet to your application's pom.xml file:

[source,xml]
----
Expand Down
3 changes: 2 additions & 1 deletion docs/src/main/asciidoc/config-yaml.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ quarkus:
----
quarkus:
datasource:
url: jdbc:postgresql://localhost:5432/quarkus_test
jdbc:
url: jdbc:postgresql://localhost:5432/quarkus_test
hibernate-orm:
database:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/deploying-to-openshift.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ You can trigger a build and deployment in a single step or build the container i

To trigger a build and deployment in a single step:

:build-additional-parameters: -Dquarkus.kubernetes.deploy=true
:build-additional-parameters: -Dquarkus.openshift.deploy=true
include::{includes}/devtools/build.adoc[]
:!build-additional-parameters:

Expand Down
Loading

0 comments on commit 5be480e

Please sign in to comment.