This is an automated email from the ASF dual-hosted git repository.
ggregory 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 4c54e104 [COMPRESS-639] The Javadoc for ZipArchiveOutputStream
documents the class as @NotThreadSafe.
4c54e104 is described below
commit 4c54e104da14dbec7c64115bb64d77e2a62ce3c3
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jan 23 06:50:59 2023 -0500
[COMPRESS-639] The Javadoc for ZipArchiveOutputStream documents the
class as @NotThreadSafe.
Add and disable
org.apache.commons.compress.archivers.zip.ParallelScatterZipCreatorTest.sameZipArchiveEntryNotThreadSafe()
---
.../zip/ParallelScatterZipCreatorTest.java | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
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 172f2864..89e46676 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
@@ -26,16 +26,20 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
@@ -48,6 +52,7 @@ import
org.apache.commons.compress.parallel.InputStreamSupplier;
import org.apache.commons.compress.parallel.ScatterGatherBackingStoreSupplier;
import org.apache.commons.compress.utils.IOUtils;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class ParallelScatterZipCreatorTest {
@@ -104,6 +109,7 @@ public class ParallelScatterZipCreatorTest {
callableApi(zipCreator -> zipCreator::submitStreamAwareCallable);
}
+
@Test
public void callableApiWithHighestLevelUsingSubmitStreamAwareCallable()
throws Exception {
result = File.createTempFile("parallelScatterGather5", "");
@@ -218,6 +224,32 @@ public class ParallelScatterZipCreatorTest {
}
}
+ @Test
+ @Disabled("[COMPRESS-639] The Javadoc for ZipArchiveOutputStream documents
the class as @NotThreadSafe.")
+ public void sameZipArchiveEntryNotThreadSafe() throws IOException,
ExecutionException, InterruptedException {
+ final ByteArrayOutputStream testOutputStream = new
ByteArrayOutputStream();
+
+ final String fileContent = "A";
+ final int NUM_OF_FILES = 100;
+ final LinkedList<InputStream> inputStreams = new LinkedList<>();
+ for (int i = 0; i < NUM_OF_FILES; i++) {
+ inputStreams.add(new
ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
+ }
+
+ final ParallelScatterZipCreator zipCreator = new
ParallelScatterZipCreator();
+ try (ZipArchiveOutputStream zipArchiveOutputStream = new
ZipArchiveOutputStream(testOutputStream)) {
+ zipArchiveOutputStream.setUseZip64(Zip64Mode.Always);
+
+ for (final InputStream inputStream : inputStreams) {
+ final ZipArchiveEntry zipArchiveEntry = new
ZipArchiveEntry("./dir/myfile.txt");
+ zipArchiveEntry.setMethod(ZipEntry.DEFLATED);
+ zipCreator.addArchiveEntry(zipArchiveEntry, () -> inputStream);
+ }
+
+ zipCreator.writeTo(zipArchiveOutputStream);
+ } // it will throw NullPointerException here
+ }
+
@Test
public void throwsExceptionWithCompressionLevelTooBig() {
final int compressLevelTooBig = Deflater.BEST_COMPRESSION + 1;