Skip to content

Commit ca21600

Browse files
committed
Use Framework's StreamUtils instead of Commons Compress's IOUtils
Closes gh-45911
1 parent aa7e2fc commit ca21600

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/EphemeralBuilderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
import org.apache.commons.compress.archivers.ArchiveEntry;
3737
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
38-
import org.apache.commons.compress.utils.IOUtils;
3938
import org.junit.jupiter.api.BeforeEach;
4039
import org.junit.jupiter.api.Test;
4140
import org.junit.jupiter.api.io.TempDir;
@@ -46,6 +45,7 @@
4645
import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
4746
import org.springframework.boot.buildpack.platform.json.AbstractJsonTests;
4847
import org.springframework.util.FileCopyUtils;
48+
import org.springframework.util.StreamUtils;
4949

5050
import static org.assertj.core.api.Assertions.assertThat;
5151
import static org.assertj.core.api.Assertions.entry;
@@ -202,7 +202,7 @@ private File unpack(TarArchiveInputStream archive, String name) throws Exception
202202
else {
203203
file.getParentFile().mkdirs();
204204
try (OutputStream out = new FileOutputStream(file)) {
205-
IOUtils.copy(archive, out);
205+
StreamUtils.copy(archive, out);
206206
}
207207
}
208208
entry = archive.getNextEntry();

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/TestTarGzip.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,9 +31,9 @@
3131
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
3232
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
3333
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
34-
import org.apache.commons.compress.utils.IOUtils;
3534

3635
import org.springframework.util.FileCopyUtils;
36+
import org.springframework.util.StreamUtils;
3737

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

@@ -110,7 +110,7 @@ private void writeEntry(TarArchiveOutputStream tar, String entryName, String con
110110
TarArchiveEntry entry = new TarArchiveEntry(entryName);
111111
entry.setSize(content.length());
112112
tar.putArchiveEntry(entry);
113-
IOUtils.copy(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), tar);
113+
StreamUtils.copy(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), tar);
114114
tar.closeArchiveEntry();
115115
}
116116

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/dockerTest/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@
3333
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
3434
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
3535
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
36-
import org.apache.commons.compress.utils.IOUtils;
3736
import org.gradle.testkit.runner.BuildResult;
3837
import org.gradle.testkit.runner.TaskOutcome;
3938
import org.junit.jupiter.api.TestTemplate;
@@ -52,6 +51,7 @@
5251
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
5352
import org.springframework.boot.testsupport.junit.DisabledOnOs;
5453
import org.springframework.util.FileSystemUtils;
54+
import org.springframework.util.StreamUtils;
5555

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

@@ -547,7 +547,7 @@ private void writeTarEntry(TarArchiveOutputStream tar, File file, String name, i
547547
TarArchiveEntry entry = new TarArchiveEntry(file, name);
548548
entry.setMode(mode);
549549
tar.putArchiveEntry(entry);
550-
IOUtils.copy(Files.newInputStream(file.toPath()), tar);
550+
StreamUtils.copy(Files.newInputStream(file.toPath()), tar);
551551
tar.closeArchiveEntry();
552552
}
553553

spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/assertions/ImageAssert.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626

2727
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
2828
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
29-
import org.apache.commons.compress.utils.IOUtils;
3029
import org.assertj.core.api.AbstractAssert;
3130
import org.assertj.core.api.Assertions;
3231
import org.assertj.core.api.ListAssert;
@@ -35,6 +34,7 @@
3534
import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
3635
import org.springframework.boot.buildpack.platform.docker.type.Layer;
3736
import org.springframework.boot.test.json.JsonContentAssert;
37+
import org.springframework.util.StreamUtils;
3838

3939
/**
4040
* AssertJ {@link org.assertj.core.api.Assert} for Docker image contents.
@@ -105,7 +105,7 @@ public void jsonEntry(String name, Consumer<JsonContentAssert> assertConsumer) {
105105
while (entry != null) {
106106
if (entry.getName().equals(name)) {
107107
ByteArrayOutputStream entryOut = new ByteArrayOutputStream();
108-
IOUtils.copy(in, entryOut);
108+
StreamUtils.copy(in, entryOut);
109109
assertConsumer.accept(new JsonContentAssert(LayerContentAssert.class, entryOut.toString()));
110110
return;
111111
}

src/checkstyle/checkstyle.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
1515
<property name="regexp" value="true" />
1616
<property name="illegalPkgs"
17-
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.core\.lang.*, ^io\.micrometer\.shaded.*, ^org\.jetbrains\.annotations.*, ^org\.testcontainers\.shaded.*" />
17+
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.core\.lang.*, ^io\.micrometer\.shaded.*, ^org\.jetbrains\.annotations.*, ^org\.testcontainers\.shaded.*,
18+
^org\.apache\.commons\.compress\.utils" />
1819
<property name="illegalClasses"
1920
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^org.springframework.context.annotation.ScannedGenericBeanDefinition, , ^(?!org\.springframework\.core\.).*ResolvableType, ^(?!org\.springframework\.util\.).*ReflectionUtils, ^reactor\.core\.support\.Assert"/>
2021
</module>

0 commit comments

Comments
 (0)