You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/08/25 19:17:40 UTC

[GitHub] [commons-io] garydgregory commented on a diff in pull request #374: IOUtils.byteArray(int size) add the verification to assure that the size is legal(size > 0), the illegal(size <=0) should throw IllegalArgumentException.

garydgregory commented on code in PR #374:
URL: https://github.com/apache/commons-io/pull/374#discussion_r955334081


##########
src/test/java/org/apache/commons/io/IOUtilsTest.java:
##########
@@ -1716,4 +1716,18 @@ public void testWriteLittleString() throws IOException {
         }
     }
 
+    @Test
+    public void testByteArrayWithIllegalSize() {
+        try {
+            int size = -1;
+            byte[] bytes = IOUtils.byteArray(size);
+
+            size = 0;
+            bytes = IOUtils.byteArray(size);
+        }catch (Exception e) {
+            assertEquals(e.getClass().getName(), IllegalArgumentException.class.getName());
+        }

Review Comment:
   Why would we trade a more vague exception for the more precise and quite specific one already thrown by the VM? Maybe this issue can be simplified with better Javadoc?



-- 
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-unsubscribe@commons.apache.org

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