garydgregory commented on code in PR #435: URL: https://github.com/apache/commons-compress/pull/435#discussion_r1388413780
########## src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java: ########## @@ -68,4 +70,28 @@ public void testSingleByteReadConsistentlyReturnsMinusOneAtEof() throws IOExcept } } + @Test + public void testInvalidMaxCodeSize() throws IOException { + final File input = getFile("bla.tar.Z"); + try (final InputStream contentStream = Files.newInputStream(input.toPath())) { + final byte[] content = IOUtils.toByteArray(contentStream); + + // Test all possible maxCodeSize values + for (int maxCodeSize = Byte.MIN_VALUE; maxCodeSize <= Byte.MAX_VALUE; maxCodeSize++) { + content[2] = (byte) maxCodeSize; + + // Test that no unexpected exceptions are thrown when initializing and reading the stream, + // since maxCodeSize impacts both initialization and reading. + assertDoesNotThrow(() -> { + try { + final ZCompressorInputStream in = + new ZCompressorInputStream(new ByteArrayInputStream(content), 1024*1024); + IOUtils.toByteArray(in); + } catch(IOException ignore) { Review Comment: Please follow the style from the other files: - Space before `(` - Space around `*` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org