Skip to content

Commit

Permalink
Reduce 3rd party IOUtil usage
Browse files Browse the repository at this point in the history
Java provides API which is most likely more optimized too.
  • Loading branch information
akurtakov committed Jan 26, 2023
1 parent 0ffc8f7 commit 3db882d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.concurrent.atomic.LongAdder;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
Expand Down Expand Up @@ -99,7 +98,7 @@ public IStatus download(URI toDownload, OutputStream target, IProgressMonitor mo
try {
DownloadStatusOutputStream statusOutputStream = new DownloadStatusOutputStream(target,
"Download of " + toDownload);
IOUtils.copy(stream(toDownload, monitor), statusOutputStream);
stream(toDownload, monitor).transferTo(statusOutputStream);
DownloadStatus downloadStatus = statusOutputStream.getStatus();
if (cacheConfig.isInteractive()) {
logger.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import java.nio.charset.Charset;
import java.util.Arrays;

import org.apache.commons.io.IOUtils;

/**
* Input stream to carry some important information for comparison and allows direct access to the
* underlying buffer.
Expand All @@ -32,7 +30,7 @@ public class ComparatorInputStream extends ByteArrayInputStream {
private final byte[] content;

public ComparatorInputStream(InputStream stream) throws IOException {
this(IOUtils.toByteArray(stream));
this(stream.readAllBytes());
}

public ComparatorInputStream(byte[] content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Set;

import org.apache.maven.it.Verifier;
import org.codehaus.plexus.util.IOUtil;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
import org.eclipse.tycho.test.util.ArchiveContentUtil;
Expand Down Expand Up @@ -258,8 +257,7 @@ static private void assertTotalZipArtifacts(final Verifier verifier, final int e

public static Properties openPropertiesFromZip(File zipFile, String propertyFile) throws Exception {
Properties configIni = new Properties();
configIni.load(
new ByteArrayInputStream(IOUtil.toByteArray(ArchiveContentUtil.getFileContent(zipFile, propertyFile))));
configIni.load(new ByteArrayInputStream(ArchiveContentUtil.getFileContent(zipFile, propertyFile).getBytes()));
return configIni;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;

Expand Down Expand Up @@ -163,7 +162,7 @@ private PosixFileAttributes getAttributes(File source) {

private static void copyFileContentToTarStream(File source, TarArchiveOutputStream tarStream) throws IOException {
try (BufferedInputStream sourceStream = new BufferedInputStream(new FileInputStream(source))) {
IOUtils.copy(sourceStream, tarStream);
sourceStream.transferTo(tarStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -226,7 +225,7 @@ private byte[] getTarEntry(String name) throws IOException {
while ((tarEntry = tarStream.getNextTarEntry()) != null) {
if (name.equals(tarEntry.getName())) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(tarStream, baos);
tarStream.transferTo(baos);
return baos.toByteArray();
}
}
Expand Down

0 comments on commit 3db882d

Please sign in to comment.