This is an automated email from the ASF dual-hosted git repository. bodewig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new 7072023 COMPRESS-578 - Java 8 improvements new 8225539 Merge pull request #194 from arturobernalg/feature/COMPRESS-578 7072023 is described below commit 70720232b973bce00d395e0c5449564aec1d8eea Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Sat May 22 14:05:27 2021 +0200 COMPRESS-578 - Java 8 improvements --- .../archivers/zip/ParallelScatterZipCreatorTest.java | 8 ++++---- .../commons/compress/changes/ChangeSetTestCase.java | 17 +++-------------- .../utils/FixedLengthBlockOutputStreamTest.java | 13 +++++-------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java index 0bf8f4d..588f5fc 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java @@ -79,13 +79,13 @@ public class ParallelScatterZipCreatorTest { @Test public void callableApiUsingSubmit() throws Exception { result = File.createTempFile("parallelScatterGather2", ""); - callableApi(zipCreator -> c -> zipCreator.submit(c)); + callableApi(zipCreator -> zipCreator::submit); } @Test public void callableApiUsingSubmitStreamAwareCallable() throws Exception { result = File.createTempFile("parallelScatterGather3", ""); - callableApi(zipCreator -> c -> zipCreator.submitStreamAwareCallable(c)); + callableApi(zipCreator -> zipCreator::submitStreamAwareCallable); } @Test(expected = IllegalArgumentException.class) @@ -109,13 +109,13 @@ public class ParallelScatterZipCreatorTest { @Test public void callableWithLowestLevelApiUsingSubmit() throws Exception { result = File.createTempFile("parallelScatterGather4", ""); - callableApiWithTestFiles(zipCreator -> c -> zipCreator.submit(c), Deflater.NO_COMPRESSION); + callableApiWithTestFiles(zipCreator -> zipCreator::submit, Deflater.NO_COMPRESSION); } @Test public void callableApiWithHighestLevelUsingSubmitStreamAwareCallable() throws Exception { result = File.createTempFile("parallelScatterGather5", ""); - callableApiWithTestFiles(zipCreator -> c -> zipCreator.submitStreamAwareCallable(c), Deflater.BEST_COMPRESSION); + callableApiWithTestFiles(zipCreator -> zipCreator::submitStreamAwareCallable, Deflater.BEST_COMPRESSION); } private void callableApi(final CallableConsumerSupplier consumerSupplier) throws Exception { diff --git a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java index 0b3fb71..68be4b1 100644 --- a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java +++ b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java @@ -49,24 +49,13 @@ public final class ChangeSetTestCase extends AbstractTestCase { // Delete a directory tree private void archiveListDeleteDir(final String prefix){ - final Iterator<String> it = archiveList.iterator(); - while(it.hasNext()){ - final String entry = it.next(); - if (entry.startsWith(prefix+"/")){ // TODO won't work with folders - it.remove(); - } - } + // TODO won't work with folders + archiveList.removeIf(entry -> entry.startsWith(prefix + "/")); } // Delete a single file private void archiveListDelete(final String prefix){ - final Iterator<String> it = archiveList.iterator(); - while(it.hasNext()){ - final String entry = it.next(); - if (entry.equals(prefix)){ - it.remove(); - } - } + archiveList.removeIf(entry -> entry.equals(prefix)); } /** diff --git a/src/test/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStreamTest.java index 6752ff3..4f83bc0 100644 --- a/src/test/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStreamTest.java @@ -192,15 +192,12 @@ public class FixedLengthBlockOutputStreamTest { @Test public void testWithFileOutputStream() throws IOException { final Path tempFile = Files.createTempFile("xxx", "yyy"); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - Files.deleteIfExists(tempFile); - } catch (final IOException e) { - } + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try { + Files.deleteIfExists(tempFile); + } catch (final IOException e) { } - }); + })); final int blockSize = 512; final int reps = 1000; final OutputStream os = Files.newOutputStream(tempFile.toFile().toPath());