This is an automated email from the ASF dual-hosted git repository. ebourg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new 31195ff Capitalized the first word of the exception messages 31195ff is described below commit 31195ffa28f505163d0d66242c89ee467e882127 Author: Emmanuel Bourg <ebo...@apache.org> AuthorDate: Thu May 23 15:00:41 2019 +0200 Capitalized the first word of the exception messages --- .../compress/archivers/ar/ArArchiveInputStream.java | 10 +++++----- .../commons/compress/archivers/cpio/CpioArchiveEntry.java | 2 +- .../compress/archivers/cpio/CpioArchiveInputStream.java | 2 +- .../compress/archivers/cpio/CpioArchiveOutputStream.java | 10 +++++----- .../commons/compress/archivers/dump/TapeInputStream.java | 4 ++-- .../commons/compress/archivers/examples/Archiver.java | 2 +- .../commons/compress/archivers/examples/Expander.java | 8 ++++---- .../org/apache/commons/compress/archivers/sevenz/CLI.java | 2 +- .../commons/compress/archivers/sevenz/CoderBase.java | 2 +- .../commons/compress/archivers/sevenz/SevenZFile.java | 2 +- .../compress/archivers/tar/TarArchiveOutputStream.java | 6 +++--- .../commons/compress/archivers/zip/AsiExtraField.java | 2 +- .../commons/compress/archivers/zip/ExtraFieldUtils.java | 4 ++-- .../archivers/zip/UnsupportedZipFeatureException.java | 6 +++--- .../archivers/zip/Zip64ExtendedInformationExtraField.java | 2 +- .../compress/archivers/zip/Zip64RequiredException.java | 4 ++-- .../commons/compress/archivers/zip/ZipArchiveEntry.java | 2 +- .../compress/archivers/zip/ZipArchiveOutputStream.java | 8 ++++---- .../org/apache/commons/compress/archivers/zip/ZipFile.java | 6 +++--- .../compressors/bzip2/BZip2CompressorInputStream.java | 14 +++++++------- .../compressors/bzip2/BZip2CompressorOutputStream.java | 4 ++-- .../compressors/lz4/BlockLZ4CompressorOutputStream.java | 2 +- .../compressors/lz4/FramedLZ4CompressorInputStream.java | 2 +- .../lz77support/AbstractLZ77CompressorInputStream.java | 2 +- .../compress/compressors/lz77support/LZ77Compressor.java | 2 +- .../commons/compress/compressors/lzw/LZWInputStream.java | 2 +- .../snappy/FramedSnappyCompressorInputStream.java | 8 ++++---- .../java/org/apache/commons/compress/utils/ByteUtils.java | 6 +++--- .../compress/utils/FixedLengthBlockOutputStream.java | 2 +- .../commons/compress/archivers/examples/ExpanderTest.java | 4 ++-- .../commons/compress/archivers/zip/AsiExtraFieldTest.java | 2 +- .../compress/archivers/zip/ExtraFieldUtilsTest.java | 2 +- .../lz4/FramedLZ4CompressorInputStreamTest.java | 2 +- .../snappy/FramedSnappyCompressorInputStreamTest.java | 2 +- 34 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java index 38d13d9..5d74e87 100644 --- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java @@ -104,11 +104,11 @@ public class ArArchiveInputStream extends ArchiveInputStream { final int read = IOUtils.readFully(input, realized); trackReadBytes(read); if (read != expected.length) { - throw new IOException("failed to read header. Occured at byte: " + getBytesRead()); + throw new IOException("Failed to read header. Occured at byte: " + getBytesRead()); } for (int i = 0; i < expected.length; i++) { if (expected[i] != realized[i]) { - throw new IOException("invalid header " + ArchiveUtils.toAsciiString(realized)); + throw new IOException("Invalid header " + ArchiveUtils.toAsciiString(realized)); } } } @@ -128,7 +128,7 @@ public class ArArchiveInputStream extends ArchiveInputStream { return null; } if (read < metaData.length) { - throw new IOException("truncated ar archive"); + throw new IOException("Truncated ar archive"); } } @@ -138,11 +138,11 @@ public class ArArchiveInputStream extends ArchiveInputStream { final int read = IOUtils.readFully(input, realized); trackReadBytes(read); if (read != expected.length) { - throw new IOException("failed to read entry trailer. Occured at byte: " + getBytesRead()); + throw new IOException("Failed to read entry trailer. Occured at byte: " + getBytesRead()); } for (int i = 0; i < expected.length; i++) { if (expected[i] != realized[i]) { - throw new IOException("invalid entry trailer. not read the content? Occured at byte: " + getBytesRead()); + throw new IOException("Invalid entry trailer. not read the content? Occured at byte: " + getBytesRead()); } } } diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java index 79e7542..575b5ee 100644 --- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java @@ -765,7 +765,7 @@ public class CpioArchiveEntry implements CpioConstants, ArchiveEntry { */ public void setSize(final long size) { if (size < 0 || size > 0xFFFFFFFFL) { - throw new IllegalArgumentException("invalid entry size <" + size + throw new IllegalArgumentException("Invalid entry size <" + size + ">"); } this.filesize = size; diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java index 39d479c..d5deb0e 100644 --- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java @@ -478,7 +478,7 @@ public class CpioArchiveInputStream extends ArchiveInputStream implements @Override public long skip(final long n) throws IOException { if (n < 0) { - throw new IllegalArgumentException("negative skip length"); + throw new IllegalArgumentException("Negative skip length"); } ensureOpen(); final int max = (int) Math.min(n, Integer.MAX_VALUE); 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 f317653..e2791d1 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 @@ -238,7 +238,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements } if (this.names.put(e.getName(), e) != null) { - throw new IOException("duplicate entry: " + e.getName()); + throw new IOException("Duplicate entry: " + e.getName()); } writeHeader(e); @@ -269,7 +269,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements writeOldBinaryEntry(e, swapHalfWord); break; default: - throw new IOException("unknown format " + e.getFormat()); + throw new IOException("Unknown format " + e.getFormat()); } } @@ -389,7 +389,7 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements } if (this.entry.getSize() != this.written) { - throw new IOException("invalid entry size (expected " + throw new IOException("Invalid entry size (expected " + this.entry.getSize() + " but got " + this.written + " bytes)"); } @@ -428,10 +428,10 @@ public class CpioArchiveOutputStream extends ArchiveOutputStream implements } if (this.entry == null) { - throw new IOException("no current CPIO entry"); + throw new IOException("No current CPIO entry"); } if (this.written + len > this.entry.getSize()) { - throw new IOException("attempt to write past end of STORED entry"); + throw new IOException("Attempt to write past end of STORED entry"); } out.write(b, off, len); this.written += len; diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java index 5643dec..5d88604 100644 --- a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java @@ -266,7 +266,7 @@ class TapeInputStream extends FilterInputStream { */ private void readBlock(final boolean decompress) throws IOException { if (in == null) { - throw new IOException("input buffer is closed"); + throw new IOException("Input buffer is closed"); } if (!isCompressed || (currBlkIdx == -1)) { @@ -309,7 +309,7 @@ class TapeInputStream extends FilterInputStream { throw new ShortFileException(); } } catch (final DataFormatException e) { - throw new DumpArchiveException("bad data", e); + throw new DumpArchiveException("Bad data", e); } finally { inflator.end(); } diff --git a/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java b/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java index b34d16b..b02c79c 100644 --- a/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java +++ b/src/main/java/org/apache/commons/compress/archivers/examples/Archiver.java @@ -118,7 +118,7 @@ public class Archiver { create(new SevenZOutputFile(target), directory); } else { // never reached as prefersSeekableByteChannel only returns true for ZIP and 7z - throw new ArchiveException("don't know how to handle format " + format); + throw new ArchiveException("Don't know how to handle format " + format); } } diff --git a/src/main/java/org/apache/commons/compress/archivers/examples/Expander.java b/src/main/java/org/apache/commons/compress/archivers/examples/Expander.java index 4922527..e2a3c1c 100644 --- a/src/main/java/org/apache/commons/compress/archivers/examples/Expander.java +++ b/src/main/java/org/apache/commons/compress/archivers/examples/Expander.java @@ -142,7 +142,7 @@ public class Expander { expand(new SevenZFile(archive), targetDirectory); } else { // never reached as prefersSeekableByteChannel only returns true for ZIP and 7z - throw new ArchiveException("don't know how to handle format " + format); + throw new ArchiveException("Don't know how to handle format " + format); } } @@ -244,17 +244,17 @@ public class Expander { while (nextEntry != null) { File f = new File(targetDirectory, nextEntry.getName()); if (!f.getCanonicalPath().startsWith(targetDirPath)) { - throw new IOException("expanding " + nextEntry.getName() + throw new IOException("Expanding " + nextEntry.getName() + " would create file outside of " + targetDirectory); } if (nextEntry.isDirectory()) { if (!f.isDirectory() && !f.mkdirs()) { - throw new IOException("failed to create directory " + f); + throw new IOException("Failed to create directory " + f); } } else { File parent = f.getParentFile(); if (!parent.isDirectory() && !parent.mkdirs()) { - throw new IOException("failed to create directory " + parent); + throw new IOException("Failed to create directory " + parent); } try (OutputStream o = Files.newOutputStream(f.toPath())) { writer.writeEntryDataTo(nextEntry, o); diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java index a40f2b3..18240d3 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/CLI.java @@ -89,7 +89,7 @@ public class CLI { final int toRead = (int) Math.min(total - off, buf.length); final int bytesRead = archive.read(buf, 0, toRead); if (bytesRead < 1) { - throw new IOException("reached end of entry " + throw new IOException("Reached end of entry " + entry.getName() + " after " + off + " bytes, expected " diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/CoderBase.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/CoderBase.java index 92fa1ae..e1f6086 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/CoderBase.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/CoderBase.java @@ -72,7 +72,7 @@ abstract class CoderBase { * @return a stream that writes to out using the given configuration. */ OutputStream encode(final OutputStream out, final Object options) throws IOException { - throw new UnsupportedOperationException("method doesn't support writing"); + throw new UnsupportedOperationException("Method doesn't support writing"); } /** 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 fb6dd5a..15d8bd0 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 @@ -504,7 +504,7 @@ public class SevenZFile implements Closeable { final int nextHeaderSizeInt = (int) startHeader.nextHeaderSize; if (nextHeaderSizeInt != startHeader.nextHeaderSize) { - throw new IOException("cannot handle nextHeaderSize " + startHeader.nextHeaderSize); + throw new IOException("Cannot handle nextHeaderSize " + startHeader.nextHeaderSize); } channel.position(SIGNATURE_HEADER_SIZE + startHeader.nextHeaderOffset); buf = ByteBuffer.allocate(nextHeaderSizeInt).order(ByteOrder.LITTLE_ENDIAN); diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java index c750e22..758f673 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java @@ -418,7 +418,7 @@ public class TarArchiveOutputStream extends ArchiveOutputStream { } out.flushBlock(); if (currBytes < currSize) { - throw new IOException("entry '" + currName + "' closed at '" + throw new IOException("Entry '" + currName + "' closed at '" + currBytes + "' before the '" + currSize + "' bytes specified in the header were written"); @@ -446,7 +446,7 @@ public class TarArchiveOutputStream extends ArchiveOutputStream { throw new IllegalStateException("No current tar entry"); } if (currBytes + numToWrite > currSize) { - throw new IOException("request to write '" + numToWrite + throw new IOException("Request to write '" + numToWrite + "' bytes exceeds size in header of '" + currSize + "' bytes for entry '" + currName + "'"); @@ -559,7 +559,7 @@ public class TarArchiveOutputStream extends ArchiveOutputStream { */ private void writeRecord(final byte[] record) throws IOException { if (record.length != RECORD_SIZE) { - throw new IOException("record to write has length '" + throw new IOException("Record to write has length '" + record.length + "' which is not the record size of '" + RECORD_SIZE + "'"); diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java index e4afa95..9cef2cc 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java @@ -274,7 +274,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { crc.update(tmp); final long realChecksum = crc.getValue(); if (givenChecksum != realChecksum) { - throw new ZipException("bad CRC checksum " + throw new ZipException("Bad CRC checksum " + Long.toHexString(givenChecksum) + " instead of " + Long.toHexString(realChecksum)); diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java index 4a7d94f..304ca38 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java @@ -145,7 +145,7 @@ public class ExtraFieldUtils { if (start + WORD + length > data.length) { switch(onUnparseableData.getKey()) { case UnparseableExtraField.THROW_KEY: - throw new ZipException("bad extra field starting at " + throw new ZipException("Bad extra field starting at " + start + ". Block length of " + length + " bytes exceeds remaining" + " data of " @@ -169,7 +169,7 @@ public class ExtraFieldUtils { // available data break LOOP; default: - throw new ZipException("unknown UnparseableExtraField key: " + throw new ZipException("Unknown UnparseableExtraField key: " + onUnparseableData.getKey()); } } diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java index 66cc0ef..c266971 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java @@ -38,7 +38,7 @@ public class UnsupportedZipFeatureException extends ZipException { */ public UnsupportedZipFeatureException(final Feature reason, final ZipArchiveEntry entry) { - super("unsupported feature " + reason + " used in entry " + super("Unsupported feature " + reason + " used in entry " + entry.getName()); this.reason = reason; this.entry = entry; @@ -53,7 +53,7 @@ public class UnsupportedZipFeatureException extends ZipException { */ public UnsupportedZipFeatureException(final ZipMethod method, final ZipArchiveEntry entry) { - super("unsupported compression method " + entry.getMethod() + super("Unsupported compression method " + entry.getMethod() + " (" + method.name() + ") used in entry " + entry.getName()); this.reason = Feature.METHOD; this.entry = entry; @@ -67,7 +67,7 @@ public class UnsupportedZipFeatureException extends ZipException { * @since 1.5 */ public UnsupportedZipFeatureException(final Feature reason) { - super("unsupported feature " + reason + " used in archive."); + super("Unsupported feature " + reason + " used in archive."); this.reason = reason; this.entry = null; } diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java index 0578e58..2e0b260 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java @@ -232,7 +232,7 @@ public class Zip64ExtendedInformationExtraField implements ZipExtraField { + (hasRelativeHeaderOffset ? DWORD : 0) + (hasDiskStart ? WORD : 0); if (rawCentralDirectoryData.length < expectedLength) { - throw new ZipException("central directory zip64 extended" + throw new ZipException("Central directory zip64 extended" + " information extra field's length" + " doesn't match central directory" + " data. Expected length " diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java index 1ec7e70..625ea64 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java @@ -38,10 +38,10 @@ public class Zip64RequiredException extends ZipException { } static final String ARCHIVE_TOO_BIG_MESSAGE = - "archive's size exceeds the limit of 4GByte."; + "Archive's size exceeds the limit of 4GByte."; static final String TOO_MANY_ENTRIES_MESSAGE = - "archive contains more than 65535 entries."; + "Archive contains more than 65535 entries."; public Zip64RequiredException(final String reason) { super(reason); 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 4a09eac..564e5a7 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 @@ -725,7 +725,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry @Override public void setSize(final long size) { if (size < 0) { - throw new IllegalArgumentException("invalid entry size"); + throw new IllegalArgumentException("Invalid entry size"); } this.size = size; } 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 70c5c2e..32ad710 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 @@ -618,7 +618,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream { } else if (channel == null) { if (entry.entry.getCrc() != crc) { - throw new ZipException("bad CRC checksum for entry " + throw new ZipException("Bad CRC checksum for entry " + entry.entry.getName() + ": " + Long.toHexString(entry.entry.getCrc()) + " instead of " @@ -626,7 +626,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream { } if (entry.entry.getSize() != bytesWritten) { - throw new ZipException("bad size for entry " + throw new ZipException("Bad size for entry " + entry.entry.getName() + ": " + entry.entry.getSize() + " instead of " @@ -812,12 +812,12 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream { // Size/CRC not required if SeekableByteChannel is used if (entry.entry.getMethod() == STORED && channel == null) { if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) { - throw new ZipException("uncompressed size is required for" + throw new ZipException("Uncompressed size is required for" + " STORED method when not writing to a" + " file"); } if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) { - throw new ZipException("crc checksum is required for STORED" + throw new ZipException("CRC checksum is required for STORED" + " method when not writing to a file"); } entry.entry.setCompressedSize(entry.entry.getSize()); 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 f5aee2e..ca6e584 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 @@ -698,7 +698,7 @@ public class ZipFile implements Closeable { long sig = ZipLong.getValue(wordBuf); if (sig != CFH_SIG && startsWithLocalFileHeader()) { - throw new IOException("central directory is empty, can't expand" + throw new IOException("Central directory is empty, can't expand" + " corrupt archive."); } @@ -996,7 +996,7 @@ public class ZipFile implements Closeable { wordBbuf.rewind(); IOUtils.readFully(archive, wordBbuf); if (!Arrays.equals(wordBuf, ZipArchiveOutputStream.ZIP64_EOCD_SIG)) { - throw new ZipException("archive's ZIP64 end of central " + throw new ZipException("Archive's ZIP64 end of central " + "directory locator is corrupt."); } skipBytes(ZIP64_EOCD_CFD_LOCATOR_OFFSET @@ -1030,7 +1030,7 @@ public class ZipFile implements Closeable { final boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE, ZipArchiveOutputStream.EOCD_SIG); if (!found) { - throw new ZipException("archive is not a ZIP archive"); + throw new ZipException("Archive is not a ZIP archive"); } } diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java index 677bbbd..1a5e2ab 100644 --- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java @@ -143,7 +143,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream count(r < 0 ? -1 : 1); return r; } - throw new IOException("stream closed"); + throw new IOException("Stream closed"); } /* @@ -165,7 +165,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream + len + ") > dest.length(" + dest.length + ")."); } if (this.bin == null) { - throw new IOException("stream closed"); + throw new IOException("Stream closed"); } if (len == 0) { return 0; @@ -315,7 +315,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream magic5 != 0x59 // 'Y' ) { this.currentState = EOF; - throw new IOException("bad block header"); + throw new IOException("Bad block header"); } this.storedBlockCRC = bsGetInt(bin); this.blockRandomised = bsR(bin, 1) == 1; @@ -390,7 +390,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream private static int bsR(BitInputStream bin, final int n) throws IOException { long thech = bin.readBits(n); if (thech < 0) { - throw new IOException("unexpected end of stream"); + throw new IOException("Unexpected end of stream"); } return (int) thech; } @@ -661,12 +661,12 @@ public class BZip2CompressorInputStream extends CompressorInputStream Arrays.fill(ll8, from, lastShadow + 1, ch); if (lastShadow >= limitLast) { - throw new IOException("block overrun while expanding RLE in MTF, " + throw new IOException("Block overrun while expanding RLE in MTF, " + lastShadow + " exceeds " + limitLast); } } else { if (++lastShadow >= limitLast) { - throw new IOException("block overrun in MTF, " + throw new IOException("Block overrun in MTF, " + lastShadow + " exceeds " + limitLast); } checkBounds(nextSym, 256 + 1, "nextSym"); @@ -762,7 +762,7 @@ public class BZip2CompressorInputStream extends CompressorInputStream } if ((this.origPtr < 0) || (this.origPtr >= tt.length)) { - throw new IOException("stream corrupted"); + throw new IOException("Stream corrupted"); } this.su_tPos = tt[this.origPtr]; diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java index cccf38d..a402afe 100644 --- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java @@ -396,7 +396,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream if (!closed) { write0(b); } else { - throw new IOException("closed"); + throw new IOException("Closed"); } } @@ -633,7 +633,7 @@ public class BZip2CompressorOutputStream extends CompressorOutputStream + buf.length + ")."); } if (closed) { - throw new IOException("stream closed"); + throw new IOException("Stream closed"); } for (final int hi = offs + len; offs < hi;) { diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java index 7f24300..ea9d195 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java @@ -265,7 +265,7 @@ public class BlockLZ4CompressorOutputStream extends CompressorOutputStream { } if (block == null) { // should not be possible - throw new IllegalStateException("failed to find a block containing offset " + offset); + throw new IllegalStateException("Failed to find a block containing offset " + offset); } copyOffset = blockOffset + block.length - offsetRemaining; copyLen = Math.min(lengthRemaining, block.length - copyOffset); diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java index 6cb66ec..338725e 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStream.java @@ -242,7 +242,7 @@ public class FramedLZ4CompressorInputStream extends CompressorInputStream int expectedHash = (int) ((contentHash.getValue() >> 8) & 0xff); contentHash.reset(); if (headerHash != expectedHash) { - throw new IOException("frame header checksum mismatch."); + throw new IOException("Frame header checksum mismatch"); } } diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStream.java index 8a1371a..31196ef 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStream.java @@ -179,7 +179,7 @@ public abstract class AbstractLZ77CompressorInputStream extends CompressorInputS */ public void prefill(byte[] data) { if (writeIndex != 0) { - throw new IllegalStateException("the stream has already been read from, can't prefill anymore"); + throw new IllegalStateException("The stream has already been read from, can't prefill anymore"); } // we don't need more data than the big offset could refer to, so cap it int len = Math.min(windowSize, data.length); diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java b/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java index 27fec8d..7545e31 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java +++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java @@ -334,7 +334,7 @@ public class LZ77Compressor { */ public void prefill(byte[] data) { if (currentPosition != 0 || lookahead != 0) { - throw new IllegalStateException("the compressor has already started to accept data, can't prefill anymore"); + throw new IllegalStateException("The compressor has already started to accept data, can't prefill anymore"); } // don't need more than windowSize for back-references diff --git a/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java b/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java index a5e512c..624d9e6 100644 --- a/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java @@ -169,7 +169,7 @@ public abstract class LZWInputStream extends CompressorInputStream implements In */ protected int readNextCode() throws IOException { if (codeSize > 31) { - throw new IllegalArgumentException("code size must not be bigger than 31"); + throw new IllegalArgumentException("Code size must not be bigger than 31"); } return (int) in.readBits(codeSize); } diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java index f6dc30c..ff3d63c 100644 --- a/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStream.java @@ -240,7 +240,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream skipBlock(); readNextBlock(); } else if (type >= MIN_UNSKIPPABLE_TYPE && type <= MAX_UNSKIPPABLE_TYPE) { - throw new IOException("unskippable chunk with type " + type + throw new IOException("Unskippable chunk with type " + type + " (hex " + Integer.toHexString(type) + ")" + " detected."); } else if (type == UNCOMPRESSED_CHUNK_TYPE) { @@ -261,7 +261,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream count(currentCompressedChunk.getBytesRead()); } else { // impossible as all potential byte values have been covered - throw new IOException("unknown chunk type " + type + throw new IOException("Unknown chunk type " + type + " detected."); } } @@ -271,7 +271,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream final int read = IOUtils.readFully(in, b); count(read); if (read != 4) { - throw new IOException("premature end of stream"); + throw new IOException("Premature end of stream"); } return ByteUtils.fromLittleEndian(b); } @@ -293,7 +293,7 @@ public class FramedSnappyCompressorInputStream extends CompressorInputStream final long read = IOUtils.skip(in, size); count(read); if (read != size) { - throw new IOException("premature end of stream"); + throw new IOException("Premature end of stream"); } } diff --git a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java index 85b4118..ae3ca69 100644 --- a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java @@ -101,7 +101,7 @@ public final class ByteUtils { for (int i = 0; i < length; i++) { long b = in.read(); if (b == -1) { - throw new IOException("premature end of data"); + throw new IOException("Premature end of data"); } l |= (b << (i * 8)); } @@ -127,7 +127,7 @@ public final class ByteUtils { for (int i = 0; i < length; i++) { long b = supplier.getAsByte(); if (b == -1) { - throw new IOException("premature end of data"); + throw new IOException("Premature end of data"); } l |= (b << (i * 8)); } @@ -255,7 +255,7 @@ public final class ByteUtils { private static final void checkReadLength(int length) { if (length > 8) { - throw new IllegalArgumentException("can't read more than eight bytes into a long value"); + throw new IllegalArgumentException("Can't read more than eight bytes into a long value"); } } } diff --git a/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java b/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java index 360f380..9640dba 100644 --- a/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java +++ b/src/main/java/org/apache/commons/compress/utils/FixedLengthBlockOutputStream.java @@ -235,7 +235,7 @@ public class FixedLengthBlockOutputStream extends OutputStream implements Writab throw new ClosedChannelException(); } if (!buffer.hasArray()) { - throw new IllegalArgumentException("direct buffer somehow written to BufferAtATimeOutputChannel"); + throw new IllegalArgumentException("Direct buffer somehow written to BufferAtATimeOutputChannel"); } try { diff --git a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java index d14a273..15791b6 100644 --- a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java @@ -124,7 +124,7 @@ public class ExpanderTest extends AbstractTestCase { @Test public void fileCantEscapeDoubleDotPath() throws IOException, ArchiveException { thrown.expect(IOException.class); - thrown.expectMessage("expanding ../foo would create file outside of"); + thrown.expectMessage("Expanding ../foo would create file outside of"); setupZip("../foo"); try (ZipFile f = new ZipFile(archive)) { new Expander().expand(f, resultDir); @@ -141,7 +141,7 @@ public class ExpanderTest extends AbstractTestCase { s.deleteOnExit(); try { thrown.expect(IOException.class); - thrown.expectMessage("expanding ../" + sibling + "/a would create file outside of"); + thrown.expectMessage("Expanding ../" + sibling + "/a would create file outside of"); setupZip("../" + sibling + "/a"); try (ZipFile f = new ZipFile(archive)) { new Expander().expand(f, resultDir); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java index 844623c..955576d 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java @@ -136,7 +136,7 @@ public class AsiExtraFieldTest implements UnixStat { a.parseFromLocalFileData(data, 0, data.length); fail("should raise bad CRC exception"); } catch (final Exception e) { - assertEquals("bad CRC checksum 0 instead of ebf018e", + assertEquals("Bad CRC checksum 0 instead of ebf018e", e.getMessage()); } } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java index 56b7d76..7f7c30c 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java @@ -90,7 +90,7 @@ public class ExtraFieldUtilsTest implements UnixStat { fail("data should be invalid"); } catch (final Exception e) { assertEquals("message", - "bad extra field starting at "+(4 + aLocal.length) + "Bad extra field starting at "+(4 + aLocal.length) + ". Block length of 1 bytes exceeds remaining data of 0 bytes.", e.getMessage()); } diff --git a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java index 2fd564b..a57c007 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorInputStreamTest.java @@ -522,7 +522,7 @@ public final class FramedLZ4CompressorInputStreamTest fail("expected exception"); } } catch (IOException ex) { - assertThat(ex.getMessage(), containsString("premature end of data")); + assertThat(ex.getMessage(), containsString("Premature end of data")); } } diff --git a/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java index 879456e..9d26d94 100644 --- a/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/snappy/FramedSnappyCompressorInputStreamTest.java @@ -139,7 +139,7 @@ public final class FramedSnappyCompressorInputStreamTest fail("expected an exception"); in.close(); } catch (final IOException ex) { - assertTrue(ex.getMessage().contains("unskippable chunk")); + assertTrue(ex.getMessage().contains("Unskippable chunk")); } }