You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/01/28 15:22:06 UTC
[commons-compress] branch master updated (574f57e0 -> a70d63d0)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
from 574f57e0 Typos
new f7036015 "ZIP" is in uppercase
new 9980f81e Use try-with-resources
new a70d63d0 Format nits
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../archivers/ar/ArArchiveOutputStream.java | 8 +-
.../archivers/cpio/CpioArchiveOutputStream.java | 8 +-
.../archivers/jar/JarArchiveInputStream.java | 2 +-
.../compress/archivers/sevenz/SevenZFile.java | 2 +-
.../archivers/tar/TarArchiveInputStream.java | 2 +-
.../archivers/zip/AbstractUnicodeExtraField.java | 10 +-
.../archivers/zip/ExtraFieldParsingBehavior.java | 2 +-
.../archivers/zip/ParallelScatterZipCreator.java | 2 +-
.../archivers/zip/ResourceAlignmentExtraField.java | 2 +-
.../archivers/zip/ScatterZipOutputStream.java | 4 +-
.../commons/compress/archivers/zip/X000A_NTFS.java | 36 +-
.../archivers/zip/X5455_ExtendedTimestamp.java | 56 +-
.../compress/archivers/zip/X7875_NewUnix.java | 6 +-
.../compress/archivers/zip/ZipArchiveEntry.java | 10 +-
.../archivers/zip/ZipArchiveEntryRequest.java | 4 +-
.../archivers/zip/ZipArchiveInputStream.java | 12 +-
.../archivers/zip/ZipArchiveOutputStream.java | 40 +-
.../compress/archivers/zip/ZipEncoding.java | 2 +-
.../compress/archivers/zip/ZipEncodingHelper.java | 8 +-
.../commons/compress/archivers/zip/ZipFile.java | 8 +-
.../archivers/zip/ZipSplitOutputStream.java | 24 +-
.../zip/ZipSplitReadOnlySeekableByteChannel.java | 34 +-
.../apache/commons/compress/changes/ChangeSet.java | 2 +-
.../compress/harmony/pack200/BHSDCodec.java | 6 +-
.../commons/compress/harmony/pack200/BandSet.java | 4 +-
.../compress/harmony/unpack200/BandSet.java | 4 +-
.../compress/harmony/unpack200/CpBands.java | 2 +-
.../compress/utils/InputStreamStatistics.java | 2 +-
.../commons/compress/archivers/ZipTestCase.java | 6 +-
.../compress/archivers/sevenz/SevenZFileTest.java | 6 +-
.../archivers/zip/Maven221MultiVolumeTest.java | 2 +-
.../zip/ParallelScatterZipCreatorTest.java | 2 +-
.../archivers/zip/X5455_ExtendedTimestampTest.java | 2 +-
.../compress/archivers/zip/X7875_NewUnixTest.java | 4 +-
.../compress/archivers/zip/Zip64SupportIT.java | 2 +-
.../archivers/zip/ZipArchiveInputStreamTest.java | 10 +-
.../compress/archivers/zip/ZipEncodingTest.java | 2 +-
.../compress/archivers/zip/ZipFileTest.java | 4 +-
.../compress/changes/ChangeSetTestCase.java | 674 +++++----------------
.../compress/compressors/Pack200TestCase.java | 2 +-
40 files changed, 312 insertions(+), 706 deletions(-)
[commons-compress] 03/03: Format nits
Posted by gg...@apache.org.
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
commit a70d63d0c23934fa27a56e22af869ea4ebcbc261
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 28 10:21:59 2023 -0500
Format nits
---
.../compress/archivers/ar/ArArchiveOutputStream.java | 8 ++++----
.../archivers/cpio/CpioArchiveOutputStream.java | 8 ++++----
.../commons/compress/archivers/sevenz/SevenZFile.java | 2 +-
.../compress/archivers/tar/TarArchiveInputStream.java | 2 +-
.../compress/archivers/zip/ZipArchiveOutputStream.java | 18 +++++++++---------
.../org/apache/commons/compress/changes/ChangeSet.java | 2 +-
.../commons/compress/harmony/pack200/BHSDCodec.java | 6 +++---
.../commons/compress/harmony/pack200/BandSet.java | 4 ++--
.../commons/compress/harmony/unpack200/BandSet.java | 4 ++--
.../commons/compress/harmony/unpack200/CpBands.java | 2 +-
.../apache/commons/compress/archivers/ZipTestCase.java | 2 +-
.../compress/archivers/sevenz/SevenZFileTest.java | 6 +++---
.../archivers/zip/ZipArchiveInputStreamTest.java | 6 +++---
.../commons/compress/archivers/zip/ZipFileTest.java | 2 +-
14 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
index bd5bfed3..6084a294 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
@@ -72,7 +72,7 @@ public class ArArchiveOutputStream extends ArchiveOutputStream {
@Override
public void closeArchiveEntry() throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
if (prevEntry == null || !haveUnclosedEntry){
@@ -120,10 +120,10 @@ public class ArArchiveOutputStream extends ArchiveOutputStream {
@Override
public void finish() throws IOException {
- if(haveUnclosedEntry) {
+ if (haveUnclosedEntry) {
throw new IOException("This archive contains unclosed entries.");
}
- if(finished) {
+ if (finished) {
throw new IOException("This archive has already been finished");
}
finished = true;
@@ -131,7 +131,7 @@ public class ArArchiveOutputStream extends ArchiveOutputStream {
@Override
public void putArchiveEntry(final ArchiveEntry pEntry) throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
index aaa777a2..11ab70ea 100644
--- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
@@ -222,7 +222,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements
*/
@Override
public void closeArchiveEntry() throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
@@ -255,7 +255,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements
@Override
public ArchiveEntry createArchiveEntry(final File inputFile, final String entryName)
throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
return new CpioArchiveEntry(inputFile, entryName);
@@ -269,7 +269,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements
@Override
public ArchiveEntry createArchiveEntry(final Path inputPath, final String entryName, final LinkOption... options)
throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
return new CpioArchiveEntry(inputPath, entryName, options);
@@ -357,7 +357,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements
*/
@Override
public void putArchiveEntry(final ArchiveEntry entry) throws IOException {
- if(finished) {
+ if (finished) {
throw new IOException("Stream has already been finished");
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 4ec6b000..f7e51b93 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -635,7 +635,7 @@ public class SevenZFile implements Closeable {
// if this is called in a random access, then the content methods of previous entry may be null
// the content methods should be set to methods of the first entry as it must not be null,
// and the content methods would only be set if the content methods was not set
- if(isRandomAccess && file.getContentMethods() == null) {
+ if (isRandomAccess && file.getContentMethods() == null) {
final int folderFirstFileIndex = archive.streamMap.folderFirstFileIndex[folderIndex];
final SevenZArchiveEntry folderFirstFile = archive.files[folderFirstFileIndex];
file.setContentMethods(folderFirstFile.getContentMethods());
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
index 621a4780..889d1ea4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
@@ -330,7 +330,7 @@ public class TarArchiveInputStream extends ArchiveInputStream {
@Override
public void close() throws IOException {
// Close all the input streams in sparseInputStreams
- if(sparseInputStreams != null) {
+ if (sparseInputStreams != null) {
for (final InputStream inputStream : sparseInputStreams) {
inputStream.close();
}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index b4e76795..e8fc0690 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -783,11 +783,11 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private byte[] createCentralFileHeader(final ZipArchiveEntry ze, final ByteBuffer name,
final EntryMetaData entryMetaData,
final boolean needsZip64Extra) throws IOException {
- if(isSplitZip) {
+ if (isSplitZip) {
// calculate the disk number for every central file header,
// this will be used in writing End Of Central Directory and Zip64 End Of Central Directory
final int currentSplitSegment = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
- if(numberOfCDInDiskData.get(currentSplitSegment) == null) {
+ if (numberOfCDInDiskData.get(currentSplitSegment) == null) {
numberOfCDInDiskData.put(currentSplitSegment, 1);
} else {
final int originalNumberOfCD = numberOfCDInDiskData.get(currentSplitSegment);
@@ -853,7 +853,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
ZipShort.putShort(commentLen, buf, CFH_COMMENT_LENGTH_OFFSET);
// disk number start
- if(isSplitZip) {
+ if (isSplitZip) {
if (ze.getDiskNumberStart() >= ZipConstants.ZIP64_MAGIC_SHORT || zip64Mode == Zip64Mode.Always) {
ZipShort.putShort(ZipConstants.ZIP64_MAGIC_SHORT, buf, CFH_DISK_NUMBER_OFFSET);
} else {
@@ -1603,7 +1603,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
*/
private boolean shouldUseZip64EOCD() {
int numberOfThisDisk = 0;
- if(isSplitZip) {
+ if (isSplitZip) {
numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
}
final int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk);
@@ -1740,7 +1740,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
* and {@link #setUseZip64(Zip64Mode)} is {@link Zip64Mode#Never}.
*/
protected void writeCentralDirectoryEnd() throws IOException {
- if(!hasUsedZip64 && isSplitZip) {
+ if (!hasUsedZip64 && isSplitZip) {
((ZipSplitOutputStream)this.outputStream).prepareToWriteUnsplittableContent(eocdLength);
}
@@ -1750,7 +1750,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
// number of this disk
int numberOfThisDisk = 0;
- if(isSplitZip) {
+ if (isSplitZip) {
numberOfThisDisk = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex();
}
writeCounted(ZipShort.getBytes(numberOfThisDisk));
@@ -1946,7 +1946,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
long offset = streamCompressor.getTotalBytesWritten();
long diskNumberStart = 0L;
- if(isSplitZip) {
+ if (isSplitZip) {
// when creating a split zip, the offset of should be
// the offset to the corresponding segment disk
final ZipSplitOutputStream zipSplitOutputStream = (ZipSplitOutputStream)this.outputStream;
@@ -2000,7 +2000,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
// no "zip64 extensible data sector" for now
- if(isSplitZip) {
+ if (isSplitZip) {
// based on the ZIP specification, the End Of Central Directory record and
// the Zip64 End Of Central Directory locator record must be on the same segment
final int zip64EOCDLOCLength = ZipConstants.WORD /* length of ZIP64_EOCD_LOC_SIG */
@@ -2020,7 +2020,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
// relative offset of ZIP64 EOCD record
writeOut(ZipEightByteInteger.getBytes(offset));
// total number of disks
- if(isSplitZip) {
+ if (isSplitZip) {
// the Zip64 End Of Central Directory Locator and the End Of Central Directory must be
// in the same split disk, it means they must be located in the last disk
final int totalNumberOfDisks = ((ZipSplitOutputStream)this.outputStream).getCurrentSplitSegmentIndex() + 1;
diff --git a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
index 5cd4d4c3..515f9094 100644
--- a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
+++ b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
@@ -84,7 +84,7 @@ public final class ChangeSet {
final ArchiveEntry entry = change.getEntry();
if (entry.equals(pChange.getEntry())) {
- if(pChange.isReplaceMode()) {
+ if (pChange.isReplaceMode()) {
it.remove();
changes.add(pChange);
}
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java b/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
index d7a6f239..029fae99 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/BHSDCodec.java
@@ -253,12 +253,12 @@ public final class BHSDCodec extends Codec {
}
// This algorithm does the same thing, but is probably slower. Leaving
// in for now for readability
- // if(isSigned()) {
+ // if (isSigned()) {
// long u = z;
// long twoPowS = (long)Math.pow(2, s);
// double twoPowSMinusOne = twoPowS-1;
- // if(u % twoPowS < twoPowSMinusOne) {
- // if(cardinality < Math.pow(2, 32)) {
+ // if (u % twoPowS < twoPowSMinusOne) {
+ // if (cardinality < Math.pow(2, 32)) {
// z = (long) (u - (Math.floor(u/ twoPowS)));
// } else {
// z = cast32((long) (u - (Math.floor(u/ twoPowS))));
diff --git a/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
index b5901cdc..053f5812 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java
@@ -354,7 +354,7 @@ public abstract class BandSet {
throws Pack200Exception {
byte[] encodedBand = null;
// Useful for debugging
-// if(ints.length > 0) {
+// if (ints.length > 0) {
// System.out.println("encoding " + name + " " + ints.length);
// }
if (effort > 1 && (ints.length >= effortThresholds[effort])) {
@@ -467,7 +467,7 @@ public abstract class BandSet {
// int specifier = 117;
// byte[] specifierEncoded = defaultCodec.encode(new int[] {specifier});
// int totalLength = firstResults.encodedBand.length + secondResults.encodedBand.length + specifierEncoded.length + 4; // TODO actual
-// if(totalLength < results.encodedBand.length) {
+// if (totalLength < results.encodedBand.length) {
// System.out.println("using run codec");
// results.saved += results.encodedBand.length - totalLength;
// byte[] encodedBand = new byte[specifierEncoded.length + firstResults.encodedBand.length + secondResults.encodedBand.length];
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
index 3b1da874..b5741f48 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BandSet.java
@@ -67,7 +67,7 @@ public abstract class BandSet {
throws IOException, Pack200Exception {
int[] band;
// Useful for debugging
-// if(count > 0) {
+// if (count > 0) {
// System.out.println("decoding " + name + " " + count);
// }
Codec codecUsed = codec;
@@ -92,7 +92,7 @@ public abstract class BandSet {
band = codec.decodeInts(count - 1, in, first);
}
// Useful for debugging -E options:
- // if(!codecUsed.equals(codec)) {
+ // if (!codecUsed.equals(codec)) {
// int bytes = codecUsed.lastBandLength;
// System.out.println(count + " " + name + " encoded with " + codecUsed + " " + bytes);
// }
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
index 6578ff64..a31e97a0 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/CpBands.java
@@ -515,7 +515,7 @@ public class CpBands extends BandSet {
mapSignature.put(signature.toString(), Integer.valueOf(i));
}
// for (int i = 0; i < cpSignatureInts.length; i++) {
-// if(cpSignatureInts[i] == -1) {
+// if (cpSignatureInts[i] == -1) {
// cpSignatureInts[i] = search(cpUTF8, cpSignature[i]);
// }
// }
diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index d6e5e773..2eccf953 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -183,7 +183,7 @@ public final class ZipTestCase extends AbstractTestCase {
assertThrows(IllegalArgumentException.class, () -> new ZipArchiveOutputStream(File.createTempFile("temp", "zip"), 64 * 1024 - 1));
}
private int countNonDirectories(final File file) {
- if(!file.isDirectory()) {
+ if (!file.isDirectory()) {
return 1;
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index 61d52fc8..da51bd0c 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -131,7 +131,7 @@ public class SevenZFileTest extends AbstractTestCase {
"111111111111111111111111111000101011";
for(final SevenZArchiveEntry entry : sevenZFile.getEntries()) {
- if(entry.getName().equals("commons-compress-1.7-src/src/test/resources/test.txt")) {
+ if (entry.getName().equals("commons-compress-1.7-src/src/test/resources/test.txt")) {
final byte[] contents = new byte[(int) entry.getSize()];
int off = 0;
final InputStream inputStream = sevenZFile.getInputStream(entry);
@@ -621,7 +621,7 @@ public class SevenZFileTest extends AbstractTestCase {
for(final SevenZArchiveEntry entry : sevenZFile.getEntries()) {
// commons-compress-1.7-src/src/test/resources/test.txt
- if(entry.getName().equals("commons-compress-1.7-src/src/test/resources/longsymlink/files.txt")) {
+ if (entry.getName().equals("commons-compress-1.7-src/src/test/resources/longsymlink/files.txt")) {
contents = new byte[(int) entry.getSize()];
off = 0;
final InputStream inputStream = sevenZFile.getInputStream(entry);
@@ -671,7 +671,7 @@ public class SevenZFileTest extends AbstractTestCase {
SevenZArchiveEntry entry;
SevenZArchiveEntry testTxtEntry = null;
while((entry = sevenZFile.getNextEntry()) != null ) {
- if(entry.getName().equals("commons-compress-1.7-src/src/test/resources/test.txt")) {
+ if (entry.getName().equals("commons-compress-1.7-src/src/test/resources/test.txt")) {
testTxtEntry = entry;
break;
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index 0688f202..ef8357e9 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -517,7 +517,7 @@ public class ZipArchiveInputStreamTest {
ArchiveEntry entry;
while((entry = splitInputStream.getNextEntry()) != null && inputStreamToCompare.getNextEntry() != null) {
- if(entry.isDirectory()) {
+ if (entry.isDirectory()) {
continue;
}
assertArrayEquals(IOUtils.toByteArray(splitInputStream),
@@ -539,7 +539,7 @@ public class ZipArchiveInputStreamTest {
ArchiveEntry entry;
while((entry = splitInputStream.getNextEntry()) != null && inputStreamToCompare.getNextEntry() != null) {
- if(entry.isDirectory()) {
+ if (entry.isDirectory()) {
continue;
}
assertArrayEquals(IOUtils.toByteArray(splitInputStream),
@@ -561,7 +561,7 @@ public class ZipArchiveInputStreamTest {
ArchiveEntry entry;
while((entry = splitInputStream.getNextEntry()) != null && inputStreamToCompare.getNextEntry() != null) {
- if(entry.isDirectory()) {
+ if (entry.isDirectory()) {
continue;
}
assertArrayEquals(IOUtils.toByteArray(splitInputStream),
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index 27678478..2e6d35ec 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -130,7 +130,7 @@ public class ZipFileTest {
final List<String> linesOfFile1 = Files.readAllLines(Paths.get(file1.getCanonicalPath()), UTF_8);
final List<String> linesOfFile2 = Files.readAllLines(Paths.get(file2.getCanonicalPath()), UTF_8);
- if(linesOfFile1.size() != linesOfFile2.size()) {
+ if (linesOfFile1.size() != linesOfFile2.size()) {
fail("files not equal : " + file1.getName() + " , " + file2.getName());
}
[commons-compress] 01/03: "ZIP" is in uppercase
Posted by gg...@apache.org.
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
commit f7036015a93621def4162e19b0de295f03d7072f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 28 09:26:24 2023 -0500
"ZIP" is in uppercase
---
.../archivers/jar/JarArchiveInputStream.java | 2 +-
.../archivers/zip/AbstractUnicodeExtraField.java | 10 ++--
.../archivers/zip/ExtraFieldParsingBehavior.java | 2 +-
.../archivers/zip/ParallelScatterZipCreator.java | 2 +-
.../archivers/zip/ResourceAlignmentExtraField.java | 2 +-
.../archivers/zip/ScatterZipOutputStream.java | 4 +-
.../commons/compress/archivers/zip/X000A_NTFS.java | 36 +++++++-------
.../archivers/zip/X5455_ExtendedTimestamp.java | 56 +++++++++++-----------
.../compress/archivers/zip/X7875_NewUnix.java | 6 +--
.../compress/archivers/zip/ZipArchiveEntry.java | 10 ++--
.../archivers/zip/ZipArchiveEntryRequest.java | 4 +-
.../archivers/zip/ZipArchiveInputStream.java | 12 ++---
.../archivers/zip/ZipArchiveOutputStream.java | 22 ++++-----
.../compress/archivers/zip/ZipEncoding.java | 2 +-
.../compress/archivers/zip/ZipEncodingHelper.java | 8 ++--
.../commons/compress/archivers/zip/ZipFile.java | 8 ++--
.../archivers/zip/ZipSplitOutputStream.java | 24 +++++-----
.../zip/ZipSplitReadOnlySeekableByteChannel.java | 34 ++++++-------
.../compress/utils/InputStreamStatistics.java | 2 +-
.../commons/compress/archivers/ZipTestCase.java | 4 +-
.../archivers/zip/Maven221MultiVolumeTest.java | 2 +-
.../zip/ParallelScatterZipCreatorTest.java | 2 +-
.../archivers/zip/X5455_ExtendedTimestampTest.java | 2 +-
.../compress/archivers/zip/X7875_NewUnixTest.java | 4 +-
.../compress/archivers/zip/Zip64SupportIT.java | 2 +-
.../archivers/zip/ZipArchiveInputStreamTest.java | 4 +-
.../compress/archivers/zip/ZipEncodingTest.java | 2 +-
.../compress/archivers/zip/ZipFileTest.java | 2 +-
.../compress/changes/ChangeSetTestCase.java | 6 +--
.../compress/compressors/Pack200TestCase.java | 2 +-
30 files changed, 139 insertions(+), 139 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java
index 494f03c6..b317f75a 100644
--- a/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java
@@ -34,7 +34,7 @@ public class JarArchiveInputStream extends ZipArchiveInputStream {
/**
* Checks if the signature matches what is expected for a jar file
- * (in this case it is the same as for a zip file).
+ * (in this case it is the same as for a ZIP file).
*
* @param signature
* the bytes to check
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
index 8e629442..824c1abf 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
@@ -38,7 +38,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* Assemble as unicode extension from the name/comment and
- * encoding of the original zip entry.
+ * encoding of the original ZIP entry.
*
* @param text The file name or comment.
* @param bytes The encoded of the file name or comment in the zip
@@ -50,10 +50,10 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* Assemble as unicode extension from the name/comment and
- * encoding of the original zip entry.
+ * encoding of the original ZIP entry.
*
* @param text The file name or comment.
- * @param bytes The encoded of the file name or comment in the zip
+ * @param bytes The encoded of the file name or comment in the ZIP
* file.
* @param off The offset of the encoded file name or comment in
* {@code bytes}.
@@ -112,7 +112,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* @return The CRC32 checksum of the file name or comment as
- * encoded in the central directory of the zip file.
+ * encoded in the central directory of the ZIP file.
*/
public long getNameCRC32() {
return nameCRC32;
@@ -159,7 +159,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* @param nameCRC32 The CRC32 checksum of the file name as encoded
- * in the central directory of the zip file to set.
+ * in the central directory of the ZIP file to set.
*/
public void setNameCRC32(final long nameCRC32) {
this.nameCRC32 = nameCRC32;
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldParsingBehavior.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldParsingBehavior.java
index 4857b0c8..3e831bde 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldParsingBehavior.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldParsingBehavior.java
@@ -20,7 +20,7 @@ package org.apache.commons.compress.archivers.zip;
import java.util.zip.ZipException;
/**
- * Controls details of parsing zip extra fields.
+ * Controls details of parsing ZIP extra fields.
*
* @since 1.19
*/
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java b/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
index b46fb0bf..94ea5f87 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreator.java
@@ -36,7 +36,7 @@ import org.apache.commons.compress.parallel.ScatterGatherBackingStore;
import org.apache.commons.compress.parallel.ScatterGatherBackingStoreSupplier;
/**
- * Creates a zip in parallel by using multiple threadlocal {@link ScatterZipOutputStream} instances.
+ * Creates a ZIP in parallel by using multiple threadlocal {@link ScatterZipOutputStream} instances.
* <p>
* Note that until 1.18, this class generally made no guarantees about the order of things written to the output file. Things that needed to come in a specific
* order (manifests, directories) had to be handled by the client of this class, usually by writing these things to the {@link ZipArchiveOutputStream}
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
index 985d171d..c2a233c1 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
@@ -76,7 +76,7 @@ public class ResourceAlignmentExtraField implements ZipExtraField {
}
/**
- * Indicates whether method change is allowed when re-compressing the zip file.
+ * Indicates whether method change is allowed when re-compressing the ZIP file.
*
* @return
* true if method change is allowed, false otherwise.
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStream.java
index 7a30df6f..22140378 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStream.java
@@ -35,7 +35,7 @@ import org.apache.commons.compress.parallel.ScatterGatherBackingStore;
import org.apache.commons.compress.utils.BoundedInputStream;
/**
- * A zip output stream that is optimized for multi-threaded scatter/gather construction of zip files.
+ * A ZIP output stream that is optimized for multi-threaded scatter/gather construction of ZIP files.
* <p>
* The internal data format of the entries used by this class are entirely private to this class and are not part of any public api whatsoever.
* </p>
@@ -223,7 +223,7 @@ public class ScatterZipOutputStream implements Closeable {
}
/**
- * Gets a zip entry writer for this scatter stream.
+ * Gets a ZIP entry writer for this scatter stream.
* @throws IOException If getting scatter stream input stream
* @return the ZipEntryWriter created on first call of the method
*/
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
index 9b4594ef..54274f77 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
@@ -125,7 +125,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the access time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
*
* @return access time as a {@link FileTime} or null.
* @since 1.23
@@ -136,7 +136,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the access time as a java.util.Date
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
*
* @return access time as java.util.Date or null.
*/
@@ -145,9 +145,9 @@ public class X000A_NTFS implements ZipExtraField {
}
/**
- * Gets the "File last access time" of this zip entry as a
+ * Gets the "File last access time" of this ZIP entry as a
* ZipEightByteInteger object, or {@link ZipEightByteInteger#ZERO}
- * if no such timestamp exists in the zip entry.
+ * if no such timestamp exists in the ZIP entry.
*
* @return File last access time
*/
@@ -181,7 +181,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the create time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
*
* @return create time as a {@link FileTime} or null.
* @since 1.23
@@ -192,7 +192,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the create time as a java.util.Date of this zip
- * entry, or null if no such timestamp exists in the zip entry.
+ * entry, or null if no such timestamp exists in the ZIP entry.
*
* @return create time as java.util.Date or null.
*/
@@ -201,9 +201,9 @@ public class X000A_NTFS implements ZipExtraField {
}
/**
- * Gets the "File creation time" of this zip entry as a
+ * Gets the "File creation time" of this ZIP entry as a
* ZipEightByteInteger object, or {@link ZipEightByteInteger#ZERO}
- * if no such timestamp exists in the zip entry.
+ * if no such timestamp exists in the ZIP entry.
*
* @return File creation time
*/
@@ -257,7 +257,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the modify time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
*
* @return modify time as a {@link FileTime} or null.
* @since 1.23
@@ -268,7 +268,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Gets the modify time as a java.util.Date
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
*
* @return modify time as java.util.Date or null.
*/
@@ -277,10 +277,10 @@ public class X000A_NTFS implements ZipExtraField {
}
/**
- * Gets the "File last modification time" of this zip entry as
+ * Gets the "File last modification time" of this ZIP entry as
* a ZipEightByteInteger object, or {@link
* ZipEightByteInteger#ZERO} if no such timestamp exists in the
- * zip entry.
+ * ZIP entry.
*
* @return File last modification time
*/
@@ -380,14 +380,14 @@ public class X000A_NTFS implements ZipExtraField {
/**
* Sets the access time as a java.util.Date
- * of this zip entry.
+ * of this ZIP entry.
*
* @param d access time as java.util.Date
*/
public void setAccessJavaTime(final Date d) { setAccessTime(dateToZip(d)); }
/**
- * Sets the File last access time of this zip entry using a
+ * Sets the File last access time of this ZIP entry using a
* ZipEightByteInteger object.
*
* @param t ZipEightByteInteger of the access time
@@ -409,7 +409,7 @@ public class X000A_NTFS implements ZipExtraField {
/**
* <p>
* Sets the create time as a java.util.Date
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -422,7 +422,7 @@ public class X000A_NTFS implements ZipExtraField {
public void setCreateJavaTime(final Date d) { setCreateTime(dateToZip(d)); }
/**
- * Sets the File creation time of this zip entry using a
+ * Sets the File creation time of this ZIP entry using a
* ZipEightByteInteger object.
*
* @param t ZipEightByteInteger of the create time
@@ -442,14 +442,14 @@ public class X000A_NTFS implements ZipExtraField {
}
/**
- * Sets the modify time as a java.util.Date of this zip entry.
+ * Sets the modify time as a java.util.Date of this ZIP entry.
*
* @param d modify time as java.util.Date
*/
public void setModifyJavaTime(final Date d) { setModifyTime(dateToZip(d)); }
/**
- * Sets the File last modification time of this zip entry using a
+ * Sets the File last modification time of this ZIP entry using a
* ZipEightByteInteger object.
*
* @param t ZipEightByteInteger of the modify time
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
index 130def55..693805d4 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
@@ -29,7 +29,7 @@ import org.apache.commons.compress.utils.TimeUtils;
/**
* <p>An extra field that stores additional file and directory timestamp data
- * for zip entries. Each zip entry can include up to three timestamps
+ * for ZIP entries. Each ZIP entry can include up to three timestamps
* (modify, access, create*). The timestamps are stored as 32 bit signed
* integers representing seconds since UNIX epoch (Jan 1st, 1970, UTC).
* This field improves on zip's default timestamp granularity, since it
@@ -57,7 +57,7 @@ import org.apache.commons.compress.utils.TimeUtils;
* <li><b>*createTime:</b>
* modern Linux file systems (e.g., ext2 and newer)
* do not appear to store a value like this, and so
- * it's usually omitted altogether in the zip extra
+ * it's usually omitted altogether in the ZIP extra
* field. Perhaps other Unix systems track this.
* </li></ul>
* <p>
@@ -201,7 +201,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Gets the access time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
*
@@ -214,7 +214,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Gets the access time as a java.util.Date
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
*
@@ -225,9 +225,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
}
/**
- * Gets the access time (seconds since epoch) of this zip entry
+ * Gets the access time (seconds since epoch) of this ZIP entry
* as a ZipLong object, or null if no such timestamp exists in the
- * zip entry.
+ * ZIP entry.
*
* @return access time (seconds since epoch) or null.
*/
@@ -265,7 +265,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Gets the create time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
*
@@ -279,14 +279,14 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Gets the create time as a java.util.Date
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
* </p>
* <p>
* Note: modern Linux file systems (e.g., ext2)
* do not appear to store a "create time" value, and so
- * it's usually omitted altogether in the zip extra
+ * it's usually omitted altogether in the ZIP extra
* field. Perhaps other Unix systems track this.
* </p>
*
@@ -298,14 +298,14 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
- * Gets the create time (seconds since epoch) of this zip entry
+ * Gets the create time (seconds since epoch) of this ZIP entry
* as a ZipLong object, or null if no such timestamp exists in the
- * zip entry.
+ * ZIP entry.
* </p>
* <p>
* Note: modern Linux file systems (e.g., ext2)
* do not appear to store a "create time" value, and so
- * it's usually omitted altogether in the zip extra
+ * it's usually omitted altogether in the ZIP extra
* field. Perhaps other Unix systems track this.
* </p>
*
@@ -387,7 +387,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Gets the modify time as a {@link FileTime}
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
*
@@ -400,7 +400,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Gets the modify time as a java.util.Date
- * of this zip entry, or null if no such timestamp exists in the zip entry.
+ * of this ZIP entry, or null if no such timestamp exists in the ZIP entry.
* The milliseconds are always zeroed out, since the underlying data
* offers only per-second precision.
*
@@ -411,9 +411,9 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
}
/**
- * Gets the modify time (seconds since epoch) of this zip entry
+ * Gets the modify time (seconds since epoch) of this ZIP entry
* as a ZipLong object, or null if no such timestamp exists in the
- * zip entry.
+ * ZIP entry.
*
* @return modify time (seconds since epoch) or null.
*/
@@ -439,7 +439,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Tests whether bit0 of the flags byte is set or not,
* which should correspond to the presence or absence of
- * a modify timestamp in this particular zip entry.
+ * a modify timestamp in this particular ZIP entry.
*
* @return true if bit0 of the flags byte is set.
*/
@@ -450,7 +450,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Tests whether bit1 of the flags byte is set or not,
* which should correspond to the presence or absence of
- * a "last access" timestamp in this particular zip entry.
+ * a "last access" timestamp in this particular ZIP entry.
*
* @return true if bit1 of the flags byte is set.
*/
@@ -461,7 +461,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* Tests whether bit2 of the flags byte is set or not,
* which should correspond to the presence or absence of
- * a create timestamp in this particular zip entry.
+ * a create timestamp in this particular ZIP entry.
*
* @return true if bit2 of the flags byte is set.
*/
@@ -529,7 +529,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the acccess time as a {@link FileTime}
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -547,7 +547,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the access time as a java.util.Date
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -563,7 +563,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
- * Sets the access time (seconds since epoch) of this zip entry
+ * Sets the access time (seconds since epoch) of this ZIP entry
* using a ZipLong object
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -582,7 +582,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the create time as a {@link FileTime}
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -600,7 +600,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the create time as a java.util.Date
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -614,7 +614,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
- * Sets the create time (seconds since epoch) of this zip entry
+ * Sets the create time (seconds since epoch) of this ZIP entry
* using a ZipLong object
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -654,7 +654,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the modify time as a {@link FileTime}
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -672,7 +672,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
* Sets the modify time as a java.util.Date
- * of this zip entry. Supplied value is truncated to per-second
+ * of this ZIP entry. Supplied value is truncated to per-second
* precision (milliseconds zeroed-out).
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
@@ -688,7 +688,7 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable, Serial
/**
* <p>
- * Sets the modify time (seconds since epoch) of this zip entry
+ * Sets the modify time (seconds since epoch) of this ZIP entry
* using a ZipLong object.
* </p><p>
* Note: the setters for flags and timestamps are decoupled.
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java b/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java
index b4601d48..00b96df7 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java
@@ -31,7 +31,7 @@ import org.apache.commons.compress.utils.ByteUtils;
/**
* An extra field that stores UNIX UID/GID data (owner & group ownership) for a given
- * zip entry. We're using the field definition given in Info-Zip's source archive:
+ * ZIP entry. We're using the field definition given in Info-Zip's source archive:
* zip-3.0.tar.gz/proginfo/extrafld.txt
*
* <pre>
@@ -98,10 +98,10 @@ public class X7875_NewUnix implements ZipExtraField, Cloneable, Serializable {
1.) We are adhering to the spec as far as I can tell, and so
a consumer that cannot parse this is broken.
- 2.) Fundamentally, zip files are about shrinking things, so
+ 2.) Fundamentally, ZIP files are about shrinking things, so
let's save a few bytes per entry while we can.
- 3.) Of all the people creating zip files using commons-
+ 3.) Of all the people creating ZIP files using commons-
compress, how many care about UNIX UID/GID attributes
of the files they store? (e.g., I am probably thinking
way too hard about this and no one cares!)
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
index bc7c9080..6ee2ce25 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
@@ -298,7 +298,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEn
}
/**
- * Creates a new zip entry taking some information from the given
+ * Creates a new ZIP entry taking some information from the given
* file and using the provided name.
*
* <p>The name will be adjusted to end with a forward slash "/" if
@@ -322,7 +322,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEn
}
/**
- * Creates a new zip entry with fields taken from the specified zip entry.
+ * Creates a new ZIP entry with fields taken from the specified ZIP entry.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
@@ -345,7 +345,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEn
}
/**
- * Creates a new zip entry taking some information from the given
+ * Creates a new ZIP entry taking some information from the given
* path and using the provided name.
*
* <p>The name will be adjusted to end with a forward slash "/" if
@@ -365,7 +365,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEn
}
/**
- * Creates a new zip entry with the specified name.
+ * Creates a new ZIP entry with the specified name.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
@@ -378,7 +378,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEn
}
/**
- * Creates a new zip entry with fields taken from the specified zip entry.
+ * Creates a new ZIP entry with fields taken from the specified ZIP entry.
*
* <p>Assumes the entry represents a directory if and only if the
* name ends with a forward slash "/".</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
index bc088650..7133480e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryRequest.java
@@ -30,7 +30,7 @@ public class ZipArchiveEntryRequest {
/**
* Create a ZipArchiveEntryRequest
* @param zipArchiveEntry The entry to use
- * @param payloadSupplier The payload that will be added to the zip entry.
+ * @param payloadSupplier The payload that will be added to the ZIP entry.
* @return The newly created request
*/
public static ZipArchiveEntryRequest createZipArchiveEntryRequest(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier payloadSupplier) {
@@ -63,7 +63,7 @@ public class ZipArchiveEntryRequest {
}
/**
- * The payload that will be added to this zip entry
+ * The payload that will be added to this ZIP entry
* @return The input stream.
*/
public InputStream getPayloadStream() {
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 18faaf01..6d788e61 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -280,13 +280,13 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
}
/**
- * Checks if the signature matches what is expected for a zip file.
+ * Checks if the signature matches what is expected for a ZIP file.
* Does not currently handle self-extracting zips which may have arbitrary
* leading content.
*
* @param signature the bytes to check
* @param length the number of bytes to check
- * @return true, if this stream is a zip archive stream, false otherwise
+ * @return true, if this stream is a ZIP archive stream, false otherwise
*/
public static boolean matches(final byte[] signature, final int length) {
if (length < ZipArchiveOutputStream.LFH_SIG.length) {
@@ -299,7 +299,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
|| checksig(signature, ZipLong.SINGLE_SEGMENT_SPLIT_MARKER.getBytes());
}
- /** The zip encoding to use for file names and the file comment. */
+ /** The ZIP encoding to use for file names and the file comment. */
private final ZipEncoding zipEncoding;
// the provided encoding (for unit tests)
@@ -345,7 +345,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
/** Count decompressed bytes for current entry */
private long uncompressedCount;
- /** Whether the stream will try to skip the zip split signature(08074B50) at the beginning **/
+ /** Whether the stream will try to skip the ZIP split signature(08074B50) at the beginning **/
private final boolean skipSplitSig;
// cached buffers - must only be used locally in the class (COMPRESS-172 - reduce garbage collection)
@@ -951,7 +951,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
if (z64 != null // same as current.usesZip64 but avoids NPE warning
&& (ZipLong.ZIP64_MAGIC.equals(cSize) || ZipLong.ZIP64_MAGIC.equals(size)) ) {
if (z64.getCompressedSize() == null || z64.getSize() == null) {
- // avoid NPE if it's a corrupted zip archive
+ // avoid NPE if it's a corrupted ZIP archive
throw new ZipException("archive contains corrupted zip64 extra field");
}
long s = z64.getCompressedSize().getLongValue();
@@ -1114,7 +1114,7 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
throw new UnsupportedZipFeatureException(UnsupportedZipFeatureException.Feature.SPLITTING);
}
- // the split zip signature(08074B50) should only be skipped when the skipSplitSig is set
+ // the split ZIP signature(08074B50) should only be skipped when the skipSplitSig is set
if (sig.equals(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER) || sig.equals(ZipLong.DD_SIG)) {
// Just skip over the marker.
final byte[] missedLfhBytes = new byte[4];
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index 336dbd99..b4e76795 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -340,7 +340,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
private String encoding = DEFAULT_ENCODING;
/**
- * The zip encoding to use for file names and the file comment.
+ * The ZIP encoding to use for file names and the file comment.
*
* This field is of internal use and will be set in {@link
* #setEncoding(String)}.
@@ -401,7 +401,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
/**
* Creates a new ZIP OutputStream writing to a File. Will use
* random access if possible.
- * @param file the file to zip to
+ * @param file the file to ZIP to
* @throws IOException on error
*/
public ZipArchiveOutputStream(final File file) throws IOException {
@@ -472,7 +472,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
/**
* Creates a new ZIP OutputStream writing to a Path. Will use
* random access if possible.
- * @param file the file to zip to
+ * @param file the file to ZIP to
* @param options options specifying how the file is opened.
* @throws IOException on error
* @since 1.21
@@ -509,7 +509,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
* allows you to write to an in-memory archive using random
* access.</p>
*
- * @param channel the channel to zip to
+ * @param channel the channel to ZIP to
* @since 1.13
*/
public ZipArchiveOutputStream(final SeekableByteChannel channel) {
@@ -539,7 +539,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
if (hasZip64Extra(ae)) {
// Will be re-added as required. this may make the file generated with this method
// somewhat smaller than standard mode,
- // since standard mode is unable to remove the zip 64 header.
+ // since standard mode is unable to remove the ZIP 64 header.
ae.removeExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
}
final boolean is2PhaseSource = ae.getCrc() != ZipArchiveEntry.CRC_UNKNOWN
@@ -662,7 +662,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
/**
* Writes all necessary data for this entry.
*
- * @param phased This entry is second phase of a 2-phase zip creation, size, compressed size and crc
+ * @param phased This entry is second phase of a 2-phase ZIP creation, size, compressed size and crc
* are known in ZipArchiveEntry
* @throws IOException on error
* @throws Zip64RequiredException if the entry's uncompressed or
@@ -703,7 +703,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
/**
- * Creates a new zip entry taking some information from the given
+ * Creates a new ZIP entry taking some information from the given
* file and using the provided name.
*
* <p>The name will be adjusted to end with a forward slash "/" if
@@ -723,7 +723,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
}
/**
- * Creates a new zip entry taking some information from the given
+ * Creates a new ZIP entry taking some information from the given
* file and using the provided name.
*
* <p>The name will be adjusted to end with a forward slash "/" if
@@ -1042,8 +1042,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
+ ZipConstants.SHORT /* total number of entries */
+ ZipConstants.WORD /* size of central directory */
+ ZipConstants.WORD /* offset of start of central directory */
- + ZipConstants.SHORT /* zip comment length */
- + commentLength /* zip comment */;
+ + ZipConstants.SHORT /* ZIP comment length */
+ + commentLength /* ZIP comment */;
writeZip64CentralDirectory();
writeCentralDirectoryEnd();
@@ -2001,7 +2001,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
// no "zip64 extensible data sector" for now
if(isSplitZip) {
- // based on the zip specification, the End Of Central Directory record and
+ // based on the ZIP specification, the End Of Central Directory record and
// the Zip64 End Of Central Directory locator record must be on the same segment
final int zip64EOCDLOCLength = ZipConstants.WORD /* length of ZIP64_EOCD_LOC_SIG */
+ ZipConstants.WORD /* disk number of ZIP64_EOCD_SIG */
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncoding.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncoding.java
index 548d6b12..88936188 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncoding.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncoding.java
@@ -60,7 +60,7 @@ public interface ZipEncoding {
/**
* Encode a file name or a comment to a byte array suitable for
- * storing it to a serialized zip entry.
+ * storing it to a serialized ZIP entry.
*
* <p>Examples for CP 437 (in pseudo-notation, right hand side is
* C-style notation):</p>
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
index f86117a8..db3aeb87 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
@@ -25,7 +25,7 @@ import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
/**
- * Static helper functions for robustly encoding file names in zip files.
+ * Static helper functions for robustly encoding file names in ZIP files.
*/
public abstract class ZipEncodingHelper {
@@ -41,16 +41,16 @@ public abstract class ZipEncodingHelper {
static final ZipEncoding UTF8_ZIP_ENCODING = getZipEncoding(UTF8);
/**
- * Instantiates a zip encoding. An NIO based character set encoder/decoder will be returned.
+ * Instantiates a ZIP encoding. An NIO based character set encoder/decoder will be returned.
* As a special case, if the character set is UTF-8, the nio encoder will be configured replace malformed and
* unmappable characters with '?'. This matches existing behavior from the older fallback encoder.
* <p>
* If the requested character set cannot be found, the platform default will
* be used instead.
* </p>
- * @param name The name of the zip encoding. Specify {@code null} for
+ * @param name The name of the ZIP encoding. Specify {@code null} for
* the platform's default encoding.
- * @return A zip encoding for the given encoding name.
+ * @return A ZIP encoding for the given encoding name.
*/
public static ZipEncoding getZipEncoding(final String name) {
Charset cs = Charset.defaultCharset();
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 9a42ea53..86fc3599 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -56,7 +56,7 @@ import org.apache.commons.compress.utils.InputStreamStatistics;
* Replacement for {@code java.util.ZipFile}.
*
* <p>This class adds support for file name encodings other than UTF-8
- * (which is required to work on ZIP files created by native zip tools
+ * (which is required to work on ZIP files created by native ZIP tools
* and is able to skip a preamble like the one found in self
* extracting archives. Furthermore it returns instances of
* {@code org.apache.commons.compress.archivers.zip.ZipArchiveEntry}
@@ -374,7 +374,7 @@ public class ZipFile implements Closeable {
private final String encoding;
/**
- * The zip encoding to use for file names and the file comment.
+ * The ZIP encoding to use for file names and the file comment.
*/
private final ZipEncoding zipEncoding;
@@ -399,7 +399,7 @@ public class ZipFile implements Closeable {
private volatile boolean closed = true;
/**
- * Whether the zip archive is a split zip archive
+ * Whether the ZIP archive is a split ZIP archive
*/
private final boolean isSplitZipArchive;
@@ -760,7 +760,7 @@ public class ZipFile implements Closeable {
/**
* Transfer selected entries from this zipfile to a given #ZipArchiveOutputStream.
* Compression and all other attributes will be as in this file.
- * <p>This method transfers entries based on the central directory of the zip file.</p>
+ * <p>This method transfers entries based on the central directory of the ZIP file.</p>
*
* @param target The zipArchiveOutputStream to write the entries to
* @param predicate A predicate that selects which entries to write
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
index 811c6fdc..62b80704 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitOutputStream.java
@@ -53,10 +53,10 @@ class ZipSplitOutputStream extends OutputStream {
private final byte[] singleByte = new byte[1];
/**
- * Create a split zip. If the zip file is smaller than the split size,
+ * Create a split zip. If the ZIP file is smaller than the split size,
* then there will only be one split zip, and its suffix is .zip,
* otherwise the split segments should be like .z01, .z02, ... .z(N-1), .zip
- * @param zipFile the zip file to write to
+ * @param zipFile the ZIP file to write to
* @param splitSize the split size
*/
public ZipSplitOutputStream(final File zipFile, final long splitSize) throws IllegalArgumentException, IOException {
@@ -64,10 +64,10 @@ class ZipSplitOutputStream extends OutputStream {
}
/**
- * Create a split zip. If the zip file is smaller than the split size,
+ * Create a split zip. If the ZIP file is smaller than the split size,
* then there will only be one split zip, and its suffix is .zip,
* otherwise the split segments should be like .z01, .z02, ... .z(N-1), .zip
- * @param zipFile the path to zip file to write to
+ * @param zipFile the path to ZIP file to write to
* @param splitSize the split size
* @since 1.22
*/
@@ -78,7 +78,7 @@ class ZipSplitOutputStream extends OutputStream {
this.zipFile = zipFile;
this.splitSize = splitSize;
this.outputStream = Files.newOutputStream(zipFile);
- // write the zip split signature 0x08074B50 to the zip file
+ // write the ZIP split signature 0x08074B50 to the ZIP file
writeZipSplitSignature();
}
@@ -90,7 +90,7 @@ class ZipSplitOutputStream extends OutputStream {
}
/**
- * Create the new zip split segment, the last zip segment should be .zip, and the zip split segments' suffix should be
+ * Create the new ZIP split segment, the last ZIP segment should be .zip, and the ZIP split segments' suffix should be
* like .z01, .z02, .z03, ... .z99, .z100, ..., .z(N-1), .zip
* <p>
* 8.3.3 Split ZIP files are typically written to the same location
@@ -104,7 +104,7 @@ class ZipSplitOutputStream extends OutputStream {
* Segment n = filename.zip
* <p>
* NOTE:
- * The zip split segment begin from 1,2,3,... , and we're creating a new segment,
+ * The ZIP split segment begin from 1,2,3,... , and we're creating a new segment,
* so the new segment suffix should be (currentSplitSegmentIndex + 2)
*
* @param zipSplitSegmentSuffixIndex
@@ -126,13 +126,13 @@ class ZipSplitOutputStream extends OutputStream {
final Path newFile = zipFile.getFileSystem().getPath(dir, baseName + extension);
if (Files.exists(newFile)) {
- throw new IOException("split zip segment " + baseName + extension + " already exists");
+ throw new IOException("split ZIP segment " + baseName + extension + " already exists");
}
return newFile;
}
/**
- * The last zip split segment's suffix should be .zip
+ * The last ZIP split segment's suffix should be .zip
*
* @throws IOException
*/
@@ -156,7 +156,7 @@ class ZipSplitOutputStream extends OutputStream {
}
/**
- * Create a new zip split segment and prepare to write to the new segment
+ * Create a new ZIP split segment and prepare to write to the new segment
*
* @throws IOException
*/
@@ -206,7 +206,7 @@ class ZipSplitOutputStream extends OutputStream {
}
/**
- * Write the data to zip split segments, if the remaining space of current split segment
+ * Write the data to ZIP split segments, if the remaining space of current split segment
* is not enough, then a new split segment should be created
*
* @param b data to write
@@ -241,7 +241,7 @@ class ZipSplitOutputStream extends OutputStream {
}
/**
- * Write the zip split signature (0x08074B50) to the head of the first zip split segment
+ * Write the ZIP split signature (0x08074B50) to the head of the first ZIP split segment
*
* @throws IOException
*/
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java
index d03e9243..956887d6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipSplitReadOnlySeekableByteChannel.java
@@ -75,10 +75,10 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
private static final int ZIP_SPLIT_SIGNATURE_LENGTH = 4;
/**
- * Concatenates zip split files from the last segment(the extension SHOULD be .zip)
+ * Concatenates ZIP split files from the last segment(the extension SHOULD be .zip)
*
- * @param lastSegmentFile the last segment of zip split files, note that the extension SHOULD be .zip
- * @return SeekableByteChannel that concatenates all zip split files
+ * @param lastSegmentFile the last segment of ZIP split files, note that the extension SHOULD be .zip
+ * @return SeekableByteChannel that concatenates all ZIP split files
* @throws IllegalArgumentException if the lastSegmentFile's extension is NOT .zip
* @throws IOException if the first channel doesn't seem to hold
* the beginning of a split archive
@@ -88,9 +88,9 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
}
/**
- * Concatenates zip split files from the last segment (the extension MUST be .zip)
- * @param lastSegmentPath the last segment of zip split files, note that the extension MUST be .zip
- * @return SeekableByteChannel that concatenates all zip split files
+ * Concatenates ZIP split files from the last segment (the extension MUST be .zip)
+ * @param lastSegmentPath the last segment of ZIP split files, note that the extension MUST be .zip
+ * @return SeekableByteChannel that concatenates all ZIP split files
* @throws IllegalArgumentException if the lastSegmentPath's extension is NOT .zip
* @throws IOException if the first channel doesn't seem to hold
* the beginning of a split archive
@@ -99,7 +99,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
public static SeekableByteChannel buildFromLastSplitSegment(final Path lastSegmentPath) throws IOException {
final String extension = FileNameUtils.getExtension(lastSegmentPath);
if (!extension.equalsIgnoreCase(ArchiveStreamFactory.ZIP)) {
- throw new IllegalArgumentException("The extension of last zip split segment should be .zip");
+ throw new IllegalArgumentException("The extension of last ZIP split segment should be .zip");
}
final Path parent = Objects.nonNull(lastSegmentPath.getParent()) ? lastSegmentPath.getParent()
@@ -107,7 +107,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
final String fileBaseName = FileNameUtils.getBaseName(lastSegmentPath);
final ArrayList<Path> splitZipSegments;
- // zip split segments should be like z01,z02....z(n-1) based on the zip specification
+ // ZIP split segments should be like z01,z02....z(n-1) based on the ZIP specification
final Pattern pattern = Pattern.compile(Pattern.quote(fileBaseName) + ".[zZ][0-9]+");
try (Stream<Path> walk = Files.walk(parent, 1)) {
splitZipSegments = walk
@@ -143,7 +143,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
/**
* Concatenates the given files.
*
- * @param lastSegmentFile the last segment of split zip segments, its extension should be .zip
+ * @param lastSegmentFile the last segment of split ZIP segments, its extension should be .zip
* @param files the files to concatenate except for the last segment,
* note theses files should be added in correct order (e.g. .z01, .z02... .z99)
* @return SeekableByteChannel that concatenates all provided files
@@ -180,7 +180,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
/**
* Concatenates the given channels.
*
- * @param lastSegmentChannel channel of the last segment of split zip segments, its extension should be .zip
+ * @param lastSegmentChannel channel of the last segment of split ZIP segments, its extension should be .zip
* @param channels the channels to concatenate except for the last segment,
* note theses channels should be added in correct order (e.g. .z01, .z02... .z99)
* @return SeekableByteChannel that concatenates all provided channels
@@ -224,7 +224,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
/**
* Concatenates the given file paths.
- * @param lastSegmentPath the last segment path of split zip segments, its extension must be .zip
+ * @param lastSegmentPath the last segment path of split ZIP segments, its extension must be .zip
* @param paths the file paths to concatenate except for the last segment,
* note these files should be added in correct order (e.g.: .z01, .z02... .z99)
* @return SeekableByteChannel that concatenates all provided files
@@ -251,7 +251,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
* Concatenates the given channels.
*
* <p>The channels should be add in ascending order, e.g. z01,
- * z02, ... z99, zip please note that the .zip file is the last
+ * z02, ... z99, ZIP please note that the .zip file is the last
* segment and should be added as the last one in the channels</p>
*
* @param channels the channels to concatenate
@@ -263,12 +263,12 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
throws IOException {
super(channels);
- // the first split zip segment should begin with zip split signature
+ // the first split ZIP segment should begin with ZIP split signature
assertSplitSignature(channels);
}
/**
- * Based on the zip specification:
+ * Based on the ZIP specification:
*
* <p>
* 8.5.3 Spanned/Split archives created using PKZIP for Windows
@@ -280,7 +280,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
* the first file in the archive.
*
* <p>
- * the first 4 bytes of the first zip split segment should be the zip split signature(0x08074B50)
+ * the first 4 bytes of the first ZIP split segment should be the ZIP split signature(0x08074B50)
*
* @param channels channels to be validated
* @throws IOException
@@ -288,7 +288,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
private void assertSplitSignature(final List<SeekableByteChannel> channels)
throws IOException {
final SeekableByteChannel channel = channels.get(0);
- // the zip split file signature is at the beginning of the first split segment
+ // the ZIP split file signature is at the beginning of the first split segment
channel.position(0L);
zipSplitSignatureByteBuffer.rewind();
@@ -296,7 +296,7 @@ public class ZipSplitReadOnlySeekableByteChannel extends MultiReadOnlySeekableBy
final ZipLong signature = new ZipLong(zipSplitSignatureByteBuffer.array());
if (!signature.equals(ZipLong.DD_SIG)) {
channel.position(0L);
- throw new IOException("The first zip split segment does not begin with split zip file signature");
+ throw new IOException("The first ZIP split segment does not begin with split ZIP file signature");
}
channel.position(0L);
diff --git a/src/main/java/org/apache/commons/compress/utils/InputStreamStatistics.java b/src/main/java/org/apache/commons/compress/utils/InputStreamStatistics.java
index 569ab368..8899c9e3 100644
--- a/src/main/java/org/apache/commons/compress/utils/InputStreamStatistics.java
+++ b/src/main/java/org/apache/commons/compress/utils/InputStreamStatistics.java
@@ -21,7 +21,7 @@ package org.apache.commons.compress.utils;
/**
* This interface provides statistics on the current decompression stream.
* The stream consumer can use that statistics to handle abnormal
- * compression ratios, i.e. to prevent zip bombs.
+ * compression ratios, i.e. to prevent ZIP bombs.
*
* @since 1.17
*/
diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index 9345c971..d6e5e773 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -351,7 +351,7 @@ public final class ZipTestCase extends AbstractTestCase {
zipFile1.copyRawEntries(zos2, allFilesPredicate);
zipFile2.copyRawEntries(zos2, allFilesPredicate);
}
- // copyRawEntries does not add superfluous zip64 header like regular zip output stream
+ // copyRawEntries does not add superfluous zip64 header like regular ZIP output stream
// does when using Zip64Mode.AsNeeded so all the source material has to be Zip64Mode.Never,
// if exact binary equality is to be achieved
assertSameFileContents(reference, fileResult);
@@ -649,7 +649,7 @@ public final class ZipTestCase extends AbstractTestCase {
assertEquals("README", entry.getName());
assertFalse(zip.canReadEntryData(entry));
assertDoesNotThrow(() -> assertNull(zip.getNextZipEntry()),
- "COMPRESS-93: Unable to skip an unsupported zip entry");
+ "COMPRESS-93: Unable to skip an unsupported ZIP entry");
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
index 2baa60c8..bd26ad20 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
@@ -30,7 +30,7 @@ import org.apache.commons.compress.archivers.ArchiveEntry;
import org.junit.jupiter.api.Test;
/**
- * JUnit test for a multi-volume zip file.
+ * JUnit test for a multi-volume ZIP file.
*
* Some tools (like 7-zip) allow users to split a large archives into 'volumes'
* with a given size to fit them into multiple cds, usb drives, or emails with
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 cb01e573..791f0772 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
@@ -218,7 +218,7 @@ public class ParallelScatterZipCreatorTest {
final byte[] expected = entries.remove(zipArchiveEntry.getName());
assertArrayEquals(expected, actual, "For " + zipArchiveEntry.getName());
}
- // check order of zip entries vs order of order of addition to the parallel zip creator
+ // check order of ZIP entries vs order of order of addition to the parallel ZIP creator
assertEquals("file" + i++, zipArchiveEntry.getName(), "For " + zipArchiveEntry.getName());
}
}
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
index 90a80c28..3c2abad7 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
@@ -513,7 +513,7 @@ public class X5455_ExtendedTimestampTest {
try (ZipFile zf = new ZipFile(archive)) {
final Enumeration<ZipArchiveEntry> en = zf.getEntries();
- // We expect EVERY entry of this zip file
+ // We expect EVERY entry of this ZIP file
// to contain extra field 0x5455.
while (en.hasMoreElements()) {
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
index 6921beae..4ecfdfad 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java
@@ -179,7 +179,7 @@ public class X7875_NewUnixTest {
try (ZipFile zf = new ZipFile(archive)) {
final Enumeration<ZipArchiveEntry> en = zf.getEntries();
- // We expect EVERY entry of this zip file (dir & file) to
+ // We expect EVERY entry of this ZIP file (dir & file) to
// contain extra field 0x7875.
while (en.hasMoreElements()) {
@@ -187,7 +187,7 @@ public class X7875_NewUnixTest {
final String name = zae.getName();
final X7875_NewUnix xf = (X7875_NewUnix) zae.getExtraField(X7875);
- // The directory entry in the test zip file is uid/gid 1000.
+ // The directory entry in the test ZIP file is uid/gid 1000.
long expected = 1000;
if (name.contains("uid555_gid555")) {
expected = 555;
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
index df4d110d..a29ef606 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
@@ -2309,7 +2309,7 @@ public class Zip64SupportIT {
@Test
public void write3EntriesCreatingManySplitArchiveFileModeAlways()
throws Throwable {
- // about 76,293 zip split segments will be created
+ // about 76,293 ZIP split segments will be created
withTemporaryArchive("write3EntriesCreatingManySplitArchiveFileModeAlways",
write3EntriesCreatingBigArchive(Zip64Mode.Always, true),
true, 65536L);
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index 8f4ed6a5..0688f202 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -87,7 +87,7 @@ public class ZipArchiveInputStreamTest {
}
/**
- * Forge a zip archive in memory, using STORED and
+ * Forge a ZIP archive in memory, using STORED and
* Data Descriptor, and without signature of Data
* Descriptor.
*
@@ -118,7 +118,7 @@ public class ZipArchiveInputStreamTest {
// copy the crc-32, compressed size and uncompressed size to the data descriptor
System.arraycopy(zipContent, 14, zipContentWithDataDescriptor, 37, 12);
- // and copy the rest of the zip content
+ // and copy the rest of the ZIP content
System.arraycopy(zipContent, 37, zipContentWithDataDescriptor, 49, zipContent.length - 37);
return new ByteArrayInputStream(zipContentWithDataDescriptor);
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java
index d834d6f2..6f477a9d 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
- * Test zip encodings.
+ * Test ZIP encodings.
*/
public class ZipEncodingTest {
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index 4e158e32..27678478 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -919,7 +919,7 @@ public class ZipFileTest {
expectedVals.put(entryPrefix + "link5", "../COMPRESS-214_unix_symlinks/././a/b");
expectedVals.put(entryPrefix + "link6", "../COMPRESS-214_unix_symlinks/././a/b/");
- // I looked into creating a test with hard links, but zip does not appear to
+ // I looked into creating a test with hard links, but ZIP does not appear to
// support hard links, so nevermind.
final File archive = getFile("COMPRESS-214_unix_symlinks.zip");
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 741160ba..eb41b528 100644
--- a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
+++ b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
@@ -896,7 +896,7 @@ public final class ChangeSetTestCase extends AbstractTestCase {
}
/**
- * Adds a file to a zip archive. Deletes an other file.
+ * Adds a file to a ZIP archive. Deletes an other file.
*
* @throws Exception
*/
@@ -943,7 +943,7 @@ public final class ChangeSetTestCase extends AbstractTestCase {
}
/**
- * Adds a file to a zip archive. Deletes an other file.
+ * Adds a file to a ZIP archive. Deletes an other file.
*
* @throws Exception
*/
@@ -1106,7 +1106,7 @@ public final class ChangeSetTestCase extends AbstractTestCase {
}
/**
- * Simple Delete from a zip file.
+ * Simple Delete from a ZIP file.
*
* @throws Exception
*/
diff --git a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
index f686adac..2e9a82aa 100644
--- a/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
@@ -158,7 +158,7 @@ public final class Pack200TestCase extends AbstractTestCase {
m.put("foo", "bar");
try (InputStream is = new Pack200CompressorInputStream(Files.newInputStream(getFile("bla.jar").toPath()),
m)) {
- // packed file is a jar, which is a zip so it starts with
+ // packed file is a jar, which is a ZIP so it starts with
// a local file header
assertTrue(is.markSupported());
is.mark(5);
[commons-compress] 02/03: Use try-with-resources
Posted by gg...@apache.org.
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
commit 9980f81eb32ab49e5b22fbe722a9aee369eeeac5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 28 10:09:44 2023 -0500
Use try-with-resources
---
.../compress/changes/ChangeSetTestCase.java | 668 +++++----------------
1 file changed, 137 insertions(+), 531 deletions(-)
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 eb41b528..d926c177 100644
--- a/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
+++ b/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
@@ -69,16 +69,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -91,15 +86,7 @@ public final class ChangeSetTestCase extends AbstractTestCase {
assertTrue(results.getAddedFromStream().contains("testdata/test1.xml"));
assertTrue(results.getAddedFromChangeSet().isEmpty());
assertTrue(results.getDeleted().isEmpty());
- is.close();
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -116,16 +103,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (final InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -136,15 +118,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
final ChangeSetResults results = performer.perform(ais, out);
assertTrue(results.getAddedFromChangeSet().contains("testdata/test1.xml"));
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -159,11 +132,8 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testAddChangeTwice() throws Exception {
- InputStream in = null;
- InputStream in2 = null;
- try {
- in = Files.newInputStream(getFile("test.txt").toPath());
- in2 = Files.newInputStream(getFile("test2.xml").toPath());
+ try (InputStream in = Files.newInputStream(getFile("test.txt").toPath());
+ InputStream in2 = Files.newInputStream(getFile("test2.xml").toPath())) {
final ArchiveEntry e = new ZipArchiveEntry("test.txt");
final ArchiveEntry e2 = new ZipArchiveEntry("test.txt");
@@ -175,13 +145,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
assertEquals(1, changes.getChanges().size());
final Change c = changes.getChanges().iterator().next();
assertEquals(in2, c.getInput());
- } finally {
- if (in != null) {
- in.close();
- }
- if (in2 != null) {
- in2.close();
- }
}
}
@@ -194,11 +157,8 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testAddChangeTwiceWithoutReplace() throws Exception {
- InputStream in = null;
- InputStream in2 = null;
- try {
- in = Files.newInputStream(getFile("test.txt").toPath());
- in2 = Files.newInputStream(getFile("test2.xml").toPath());
+ try (InputStream in = Files.newInputStream(getFile("test.txt").toPath());
+ InputStream in2 = Files.newInputStream(getFile("test2.xml").toPath())) {
final ArchiveEntry e = new ZipArchiveEntry("test.txt");
final ArchiveEntry e2 = new ZipArchiveEntry("test.txt");
@@ -210,13 +170,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
assertEquals(1, changes.getChanges().size());
final Change c = changes.getChanges().iterator().next();
assertEquals(in, c.getInput());
- } finally {
- if (in != null) {
- in.close();
- }
- if (in2 != null) {
- in2.close();
- }
}
}
@@ -231,16 +184,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -254,16 +202,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -279,21 +217,14 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = this.createSingleEntryArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- InputStream is = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
final ChangeSet changes = new ChangeSet();
- try {
-
- is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final File file = getFile("test.txt");
- final ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt");
+ final ArchiveEntry entry = out.createArchiveEntry(file, "bla/test.txt");
changes.add(entry, Files.newInputStream(file.toPath()));
archiveList.add("bla/test.txt");
@@ -303,16 +234,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close(); // will close is
- } else if (is != null){
- is.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -342,19 +263,12 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createEmptyArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- InputStream is = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
final ChangeSet changes = new ChangeSet();
- try {
-
- is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final File file1 = getFile("test.txt");
final ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt");
@@ -363,16 +277,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close(); // will close is
- } else if (is != null){
- is.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -388,16 +292,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.deleteDir("bla");
@@ -414,9 +313,9 @@ public final class ChangeSetTestCase extends AbstractTestCase {
is.close();
// Checks
- assertEquals(1,results.getAddedFromChangeSet().size());
- assertEquals("bla/test.txt",results.getAddedFromChangeSet().iterator().next());
- assertEquals(3,results.getDeleted().size());
+ assertEquals(1, results.getAddedFromChangeSet().size());
+ assertEquals("bla/test.txt", results.getAddedFromChangeSet().iterator().next());
+ assertEquals(3, results.getDeleted().size());
assertTrue(results.getDeleted().contains("bla/test4.xml"));
assertTrue(results.getDeleted().contains("bla/test5.xml"));
assertTrue(results.getDeleted().contains("bla/blubber/test6.xml"));
@@ -427,14 +326,7 @@ public final class ChangeSetTestCase extends AbstractTestCase {
assertTrue(results.getAddedFromStream().contains("test.txt"));
assertTrue(results.getAddedFromStream().contains("something/bla"));
assertTrue(results.getAddedFromStream().contains("test with spaces.txt"));
- assertEquals(6,results.getAddedFromStream().size());
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
+ assertEquals(6, results.getAddedFromStream().size());
}
this.checkArchiveContent(result, archiveList);
@@ -451,16 +343,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -476,16 +363,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -501,40 +378,22 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createSingleEntryArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- InputStream is = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
final ChangeSet changes = new ChangeSet();
- try {
-
- is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
changes.delete("test1.xml");
archiveListDelete("test1.xml");
final File file = getFile("test.txt");
- final ArchiveEntry entry = out.createArchiveEntry(file,"bla/test.txt");
+ final ArchiveEntry entry = out.createArchiveEntry(file, "bla/test.txt");
changes.add(entry, Files.newInputStream(file.toPath()));
archiveList.add("bla/test.txt");
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close(); // will close is
- } else if (is != null){
- is.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -553,32 +412,16 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
-
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.deleteDir("bla");
archiveListDeleteDir("bla");
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -595,32 +438,17 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.deleteDir("la");
archiveListDeleteDir("la");
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -637,32 +465,16 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
-
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.deleteDir("test.txt");
archiveListDeleteDir("test.txt");
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -679,17 +491,11 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.delete("bla/test5.xml");
@@ -697,15 +503,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -722,33 +519,18 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
-
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (final InputStream is = Files.newInputStream(input);
+ ArchiveInputStream ais = factory.createArchiveInputStream(archivename, is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.delete("bla");
- //archiveListDelete("bla");
+ // archiveListDelete("bla");
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -761,38 +543,22 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromAndAddToAr() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
-
- final File file1 = getFile("test.txt");
-
- final ArArchiveEntry entry = new ArArchiveEntry("test.txt", file1
- .length());
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
- changes.add(entry, Files.newInputStream(file1.toPath()));
+ final File file1 = getFile("test.txt");
- final File input = getFile("bla.ar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("ar", is);
+ final ArArchiveEntry entry = new ArArchiveEntry("test.txt", file1.length());
- temp = new File(dir, "bla.ar");
- out = factory.createArchiveOutputStream("ar",
- Files.newOutputStream(temp.toPath()));
+ changes.add(entry, Files.newInputStream(file1.toPath()));
+ final File input = getFile("bla.ar");
+ final InputStream is = Files.newInputStream(input.toPath());
+ final File temp = new File(dir, "bla.ar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("ar", is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream("ar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
expected.add("test1.xml");
@@ -807,38 +573,24 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromAndAddToJar() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
- changes.deleteDir("META-INF");
- changes.delete(".classpath");
- changes.delete(".project");
-
- final File file1 = getFile("test.txt");
- final JarArchiveEntry entry = new JarArchiveEntry("testdata/test.txt");
- changes.add(entry, Files.newInputStream(file1.toPath()));
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
+ changes.deleteDir("META-INF");
+ changes.delete(".classpath");
+ changes.delete(".project");
- final File input = getFile("bla.jar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("jar", is);
+ final File file1 = getFile("test.txt");
+ final JarArchiveEntry entry = new JarArchiveEntry("testdata/test.txt");
+ changes.add(entry, Files.newInputStream(file1.toPath()));
- temp = new File(dir, "bla.jar");
- out = factory.createArchiveOutputStream("jar",
- Files.newOutputStream(temp.toPath()));
+ final File input = getFile("bla.jar");
+ final InputStream is = Files.newInputStream(input.toPath());
+ final File temp = new File(dir, "bla.jar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("jar", is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream("jar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
expected.add("test1.xml");
@@ -848,45 +600,28 @@ public final class ChangeSetTestCase extends AbstractTestCase {
@Test
public void testDeleteFromAndAddToTar() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
-
- final File file1 = getFile("test.txt");
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
- final TarArchiveEntry entry = new TarArchiveEntry(
- "testdata/test.txt");
- entry.setModTime(0);
- entry.setSize(file1.length());
- entry.setUserId(0);
- entry.setGroupId(0);
- entry.setUserName("avalon");
- entry.setGroupName("excalibur");
- entry.setMode(0100000);
+ final File file1 = getFile("test.txt");
- changes.add(entry, Files.newInputStream(file1.toPath()));
+ final TarArchiveEntry entry = new TarArchiveEntry("testdata/test.txt");
+ entry.setModTime(0);
+ entry.setSize(file1.length());
+ entry.setUserId(0);
+ entry.setGroupId(0);
+ entry.setUserName("avalon");
+ entry.setGroupName("excalibur");
+ entry.setMode(0100000);
- final File input = getFile("bla.tar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("tar", is);
-
- temp = new File(dir, "bla.tar");
- out = factory.createArchiveOutputStream("tar",
- Files.newOutputStream(temp.toPath()));
+ changes.add(entry, Files.newInputStream(file1.toPath()));
+ final File input = getFile("bla.tar");
+ File temp = new File(dir, "bla.tar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("tar", Files.newInputStream(input.toPath()));
+ ArchiveOutputStream out = factory.createArchiveOutputStream("tar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
expected.add("test1.xml");
@@ -904,17 +639,10 @@ public final class ChangeSetTestCase extends AbstractTestCase {
public void testDeleteFromAndAddToZip() throws Exception {
final String archivename = "zip";
final Path input = createArchive(archivename);
-
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (ArchiveInputStream ais = factory.createArchiveInputStream(archivename, Files.newInputStream(input));
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -928,15 +656,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -952,15 +671,10 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ZipFile ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- ais = new ZipFile(input);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (ZipFile ais = new ZipFile(input);
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
@@ -974,14 +688,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -994,31 +700,15 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromAr() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
-
- final File input = getFile("bla.ar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("ar", is);
-
- temp = new File(dir, "bla.ar");
- out = factory.createArchiveOutputStream("ar",
- Files.newOutputStream(temp.toPath()));
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
+ final File input = getFile("bla.ar");
+ final File temp = new File(dir, "bla.ar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("ar", Files.newInputStream(input.toPath()));
+ ArchiveOutputStream out = factory.createArchiveOutputStream("ar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
@@ -1033,34 +723,18 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromJar() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
- changes.deleteDir("META-INF");
- changes.delete(".classpath");
- changes.delete(".project");
-
- final File input = getFile("bla.jar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("jar", is);
-
- temp = new File(dir, "bla.jar");
- out = factory.createArchiveOutputStream("jar",
- Files.newOutputStream(temp.toPath()));
-
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
+ changes.deleteDir("META-INF");
+ changes.delete(".classpath");
+ changes.delete(".project");
+
+ final File input = getFile("bla.jar");
+ final File temp = new File(dir, "bla.jar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("jar", Files.newInputStream(input.toPath()));
+ ArchiveOutputStream out = factory.createArchiveOutputStream("jar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
expected.add("test1.xml");
@@ -1074,31 +748,16 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromTar() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
-
- final File input = getFile("bla.tar");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("tar", is);
-
- temp = new File(dir, "bla.tar");
- out = factory.createArchiveOutputStream("tar",
- Files.newOutputStream(temp.toPath()));
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
+ final File input = getFile("bla.tar");
+ final InputStream is = Files.newInputStream(input.toPath());
+ final File temp = new File(dir, "bla.tar");
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("tar", is);
+ ArchiveOutputStream out = factory.createArchiveOutputStream("tar", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
expected.add("test1.xml");
@@ -1112,32 +771,17 @@ public final class ChangeSetTestCase extends AbstractTestCase {
*/
@Test
public void testDeleteFromZip() throws Exception {
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
- File temp = null;
- try {
- final ChangeSet changes = new ChangeSet();
- changes.delete("test2.xml");
-
- final File input = getFile("bla.zip");
- final InputStream is = Files.newInputStream(input.toPath());
- ais = factory.createArchiveInputStream("zip", is);
+ final ChangeSet changes = new ChangeSet();
+ changes.delete("test2.xml");
- temp = File.createTempFile("test", ".zip");
- temp.deleteOnExit();
- out = factory.createArchiveOutputStream("zip",
- Files.newOutputStream(temp.toPath()));
+ final File input = getFile("bla.zip");
+ final File temp = File.createTempFile("test", ".zip");
+ temp.deleteOnExit();
+ try (ArchiveInputStream ais = factory.createArchiveInputStream("zip", Files.newInputStream(input.toPath()));
+ ArchiveOutputStream out = factory.createArchiveOutputStream("zip", Files.newOutputStream(temp.toPath()))) {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
final List<String> expected = new ArrayList<>();
@@ -1158,17 +802,10 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "cpio";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
-
+ try (ArchiveInputStream ais = factory.createArchiveInputStream(archivename, Files.newInputStream(input));
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.deleteDir("bla");
archiveListDeleteDir("bla");
@@ -1181,15 +818,6 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
this.checkArchiveContent(result, archiveList);
@@ -1207,18 +835,12 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final String archivename = "zip";
final Path input = createArchive(archivename);
- ArchiveOutputStream out = null;
- ArchiveInputStream ais = null;
final File result = File.createTempFile("test", "." + archivename);
result.deleteOnExit();
File testtxt = null;
- try {
-
- final InputStream is = Files.newInputStream(input);
- ais = factory.createArchiveInputStream(archivename, is);
- out = factory.createArchiveOutputStream(archivename,
- Files.newOutputStream(result.toPath()));
+ try (ArchiveInputStream ais = factory.createArchiveInputStream(archivename, Files.newInputStream(input));
+ ArchiveOutputStream out = factory.createArchiveOutputStream(archivename, Files.newOutputStream(result.toPath()))) {
final ChangeSet changes = new ChangeSet();
changes.delete("test/test3.xml");
@@ -1232,41 +854,25 @@ public final class ChangeSetTestCase extends AbstractTestCase {
final ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
- is.close();
-
- } finally {
- if (out != null) {
- out.close();
- }
- if (ais != null) {
- ais.close();
- }
}
// Checks
- ArchiveInputStream in = null;
File check = null;
- try {
- final InputStream is = Files.newInputStream(result.toPath());
- final BufferedInputStream buf = new BufferedInputStream(is);
- in = factory.createArchiveInputStream(buf);
+ try (BufferedInputStream buf = new BufferedInputStream(Files.newInputStream(result.toPath()));
+ ArchiveInputStream in = factory.createArchiveInputStream(buf)) {
check = this.checkArchiveContent(in, archiveList, false);
- final File test3xml = new File(check,"result/test/test3.xml");
+ final File test3xml = new File(check, "result/test/test3.xml");
assertEquals(testtxt.length(), test3xml.length());
- final BufferedReader reader = new BufferedReader(Files.newBufferedReader(test3xml.toPath()));
- String str;
- while ((str = reader.readLine()) != null) {
- // All lines look like this
- "111111111111111111111111111000101011".equals(str);
- }
- reader.close();
- } finally {
- if (in != null) {
- in.close();
+ try (BufferedReader reader = new BufferedReader(Files.newBufferedReader(test3xml.toPath()))) {
+ String str;
+ while ((str = reader.readLine()) != null) {
+ // All lines look like this
+ "111111111111111111111111111000101011".equals(str);
+ }
}
- rmdir(check);
}
+ rmdir(check);
}
/**