Skip to content

Commit 57b1089

Browse files
committed
Drop and ban commons-io dependency from quarkus-core-deployment
This also update forbiddenapis to 3.4 and substitute calls to org.apache.commons.io.IOUtils#copy(java.io.InputStream,java.io.OutputStream) and org.apache.commons.compress.utils.IOUtils#copy(java.io.InputStream,java.io.OutputStream) using java.io.InputStream#transferTo(java.io.OutputStream) Signed-off-by: Jorge Solórzano <[email protected]>
1 parent ef5b122 commit 57b1089

File tree

10 files changed

+52
-23
lines changed

10 files changed

+52
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
@defaultMessage Never use Type#toString() as it's almost always the wrong thing to do. Usually org.jboss.jandex.DotName#toString() is what is needed
22
org.jboss.jandex.Type#toString()
3+
4+
@defaultMessage Replace this by using InputStream.transferTo(OutputStream)
5+
org.apache.commons.io.IOUtils#copy(java.io.InputStream,java.io.OutputStream)
6+
org.apache.commons.compress.utils.IOUtils#copy(java.io.InputStream,java.io.OutputStream)

build-parent/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<revapi.buildFailureMessage>Run "jbang revapi-update" to update api-changes.xml file and also add the justification for those changes in that file.</revapi.buildFailureMessage>
160160

161161
<!-- Forbidden API checks -->
162-
<forbiddenapis-maven-plugin.version>3.1</forbiddenapis-maven-plugin.version>
162+
<forbiddenapis-maven-plugin.version>3.4</forbiddenapis-maven-plugin.version>
163163

164164
<!-- platform properties - this is a floating tag -->
165165
<platform.quarkus.native.builder-image>mandrel</platform.quarkus.native.builder-image>

core/deployment/banned-signatures.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@defaultMessage Don't use Maven classes. They won't be available when using Gradle.
22
org.apache.maven.**
33
org.codehaus.plexus.**
4+
45
@defaultMessage Never use Type#toString() as it's almost always the wrong thing to do. Usually org.jboss.jandex.DotName#toString() is what is needed
56
org.jboss.jandex.Type#toString()
7+
8+
org.apache.commons.io.** @ Don't use commons-io dependency

core/deployment/pom.xml

-4
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@
139139
<groupId>org.junit.jupiter</groupId>
140140
<artifactId>junit-jupiter</artifactId>
141141
</dependency>
142-
<dependency>
143-
<groupId>commons-io</groupId>
144-
<artifactId>commons-io</artifactId>
145-
</dependency>
146142
</dependencies>
147143

148144
<build>

core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigGenerationBuildStep.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import java.util.HashSet;
2121
import java.util.List;
2222
import java.util.Map;
23+
import java.util.Objects;
2324
import java.util.Optional;
2425
import java.util.Set;
2526
import java.util.stream.Collectors;
2627

27-
import org.apache.commons.io.FilenameUtils;
2828
import org.eclipse.microprofile.config.Config;
2929
import org.eclipse.microprofile.config.ConfigProvider;
3030
import org.eclipse.microprofile.config.ConfigValue;
@@ -407,7 +407,7 @@ public void watchConfigFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> wa
407407
if (!Files.isDirectory(path)) {
408408
configWatchedFiles.add(path.toString());
409409
for (String profile : config.getProfiles()) {
410-
configWatchedFiles.add(appendProfileToFilename(path.toString(), profile));
410+
configWatchedFiles.add(appendProfileToFilename(path, profile));
411411
}
412412
}
413413
}
@@ -425,9 +425,23 @@ void warnDifferentProfileUsedBetweenBuildAndRunTime(ConfigRecorder configRecorde
425425
configRecorder.handleNativeProfileChange(config.getProfiles());
426426
}
427427

428-
private String appendProfileToFilename(String path, String activeProfile) {
429-
String pathWithoutExtension = FilenameUtils.removeExtension(path);
430-
return String.format("%s-%s.%s", pathWithoutExtension, activeProfile, FilenameUtils.getExtension(path));
428+
private String appendProfileToFilename(Path path, String activeProfile) {
429+
String pathWithoutExtension = getPathWithoutExtension(path);
430+
return String.format("%s-%s.%s", pathWithoutExtension, activeProfile, getFileExtension(path));
431+
}
432+
433+
private static String getFileExtension(Path path) {
434+
Objects.requireNonNull(path, "path should not be null");
435+
String fileName = path.getFileName().toString();
436+
int dotIndex = fileName.lastIndexOf('.');
437+
return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1);
438+
}
439+
440+
private static String getPathWithoutExtension(Path path) {
441+
Objects.requireNonNull(path, "path should not be null");
442+
String fileName = path.toString();
443+
int dotIndex = fileName.lastIndexOf('.');
444+
return (dotIndex == -1) ? fileName : fileName.substring(0, dotIndex);
431445
}
432446

433447
private static void generateDefaultsConfigSource(

extensions/amazon-lambda/common-deployment/src/main/java/io/quarkus/amazon/lambda/deployment/FunctionZipProcessor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
1313
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
1414
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
15-
import org.apache.commons.compress.utils.IOUtils;
1615
import org.jboss.logging.Logger;
1716

1817
import io.quarkus.deployment.IsNormal;
@@ -145,7 +144,7 @@ public void nativeZip(OutputTargetBuildItem target,
145144
private void copyZipEntry(ZipArchiveOutputStream zip, InputStream zinput, ZipArchiveEntry from) throws Exception {
146145
ZipArchiveEntry entry = new ZipArchiveEntry(from);
147146
zip.putArchiveEntry(entry);
148-
IOUtils.copy(zinput, zip);
147+
zinput.transferTo(zip);
149148
zip.closeArchiveEntry();
150149
}
151150

@@ -154,7 +153,7 @@ private void addZipEntry(ZipArchiveOutputStream zip, Path path, String name, int
154153
entry.setUnixMode(mode);
155154
zip.putArchiveEntry(entry);
156155
try (InputStream i = Files.newInputStream(path)) {
157-
IOUtils.copy(i, zip);
156+
i.transferTo(zip);
158157
}
159158
zip.closeArchiveEntry();
160159
}

extensions/hibernate-orm/pom.xml

+17-7
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,31 @@
4444
<!-- The jdk-reflection is not yet something we can avoid -->
4545
<!--<bundledSignature>jdk-reflection</bundledSignature>-->
4646

47-
<!-- All following signatures should be replicated for each target JDK version we intend to support -->
48-
<bundledSignature>jdk-unsafe-11</bundledSignature>
49-
<bundledSignature>jdk-unsafe-12</bundledSignature>
50-
<bundledSignature>jdk-unsafe-13</bundledSignature>
51-
<bundledSignature>jdk-unsafe-14</bundledSignature>
52-
<bundledSignature>jdk-unsafe-15</bundledSignature>
47+
<!-- These signatures can safely be limited to the current JDK;
48+
see https://github.com/policeman-tools/forbidden-apis/issues/197#issuecomment-1080370368
49+
-->
50+
<bundledSignature>jdk-unsafe</bundledSignature>
5351

52+
<!-- All following signatures should be replicated for each target JDK version we intend to support -->
5453
<bundledSignature>jdk-deprecated-11</bundledSignature>
5554
<bundledSignature>jdk-deprecated-12</bundledSignature>
5655
<bundledSignature>jdk-deprecated-13</bundledSignature>
5756
<bundledSignature>jdk-deprecated-14</bundledSignature>
5857
<bundledSignature>jdk-deprecated-15</bundledSignature>
58+
<bundledSignature>jdk-deprecated-16</bundledSignature>
59+
<bundledSignature>jdk-deprecated-17</bundledSignature>
60+
<bundledSignature>jdk-deprecated-18</bundledSignature>
61+
<bundledSignature>jdk-deprecated-19</bundledSignature>
5962

6063
<bundledSignature>jdk-internal-11</bundledSignature>
6164
<bundledSignature>jdk-internal-12</bundledSignature>
6265
<bundledSignature>jdk-internal-13</bundledSignature>
6366
<bundledSignature>jdk-internal-14</bundledSignature>
6467
<bundledSignature>jdk-internal-15</bundledSignature>
68+
<bundledSignature>jdk-internal-16</bundledSignature>
69+
<bundledSignature>jdk-internal-17</bundledSignature>
70+
<bundledSignature>jdk-internal-18</bundledSignature>
71+
<bundledSignature>jdk-internal-19</bundledSignature>
6572
</bundledSignatures>
6673
<signaturesFiles>
6774
<signaturesFile>./banned-signatures.txt</signaturesFile>
@@ -81,7 +88,10 @@
8188
<failOnUnsupportedJava>false</failOnUnsupportedJava>
8289
<ignoreSignaturesOfMissingClasses>true</ignoreSignaturesOfMissingClasses>
8390
<bundledSignatures>
84-
<!-- This will automatically choose the right signatures based on 'targetVersion': -->
91+
<!--
92+
This will automatically choose the right
93+
signatures based on 'maven.compiler.release':
94+
-->
8595
<bundledSignature>jdk-unsafe</bundledSignature>
8696
<bundledSignature>jdk-deprecated</bundledSignature>
8797
<bundledSignature>jdk-non-portable</bundledSignature>

independent-projects/resteasy-reactive/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<smallrye-mutiny-vertx-core.version>2.25.0</smallrye-mutiny-vertx-core.version>
7171

7272
<!-- Forbidden API checks -->
73-
<forbiddenapis-maven-plugin.version>3.1</forbiddenapis-maven-plugin.version>
73+
<forbiddenapis-maven-plugin.version>3.4</forbiddenapis-maven-plugin.version>
7474
</properties>
7575

7676
<modules>

test-framework/common/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<groupId>io.smallrye</groupId>
3131
<artifactId>jandex</artifactId>
3232
</dependency>
33+
<dependency>
34+
<groupId>commons-io</groupId>
35+
<artifactId>commons-io</artifactId>
36+
</dependency>
3337
<!-- Needed for RestAssured -->
3438
<dependency>
3539
<groupId>org.jboss.logging</groupId>

test-framework/common/src/main/java/io/quarkus/test/common/DefaultDockerContainerLauncher.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.concurrent.TimeUnit;
2525
import java.util.function.Function;
2626

27-
import org.apache.commons.io.IOUtils;
2827
import org.apache.commons.io.input.TeeInputStream;
2928
import org.apache.commons.lang3.RandomStringUtils;
3029

@@ -155,7 +154,7 @@ public void start() throws IOException {
155154
// the log itself is written inside the container
156155
Process quarkusProcess = new ProcessBuilder(args).redirectError(PIPE).redirectOutput(PIPE).start();
157156
InputStream tee = new TeeInputStream(quarkusProcess.getInputStream(), new FileOutputStream(logFile.toFile()));
158-
executorService.submit(() -> IOUtils.copy(tee, containerLogOutputStream));
157+
executorService.submit(() -> tee.transferTo(containerLogOutputStream));
159158

160159
if (startedFunction != null) {
161160
IntegrationTestStartedNotifier.Result result = waitForStartedFunction(startedFunction, quarkusProcess,

0 commit comments

Comments
 (0)