ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ant] bodewig commented on a change in pull request #145: Override ZipOutputStream.write(int)
Date Sat, 13 Mar 2021 11:52:34 GMT

bodewig commented on a change in pull request #145:
URL: https://github.com/apache/ant/pull/145#discussion_r593741717



##########
File path: src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java
##########
@@ -70,4 +76,17 @@ public void testAdjustToLong() {
                      ZipUtil.adjustToLong(2 * Integer.MAX_VALUE));
     }
 
+    @Test
+    public void testWriteAndReadManifest() throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ZipOutputStream zos = new ZipOutputStream(baos);
+        zos.putNextEntry(new ZipEntry(JarFile.MANIFEST_NAME));
+        new Manifest().write(zos);
+        zos.close();
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+        ZipInputStream zis = new ZipInputStream(bais);
+        zis.getNextEntry();
+        zis.closeEntry();
+        zis.close();
+    }

Review comment:
       please use try-with-resources for all streams even though we are only writing to memory.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message