ppkarwasz commented on code in PR #784:
URL: https://github.com/apache/commons-io/pull/784#discussion_r2366396316


##########
src/test/java/org/apache/commons/io/build/ByteArrayOriginTest.java:
##########
@@ -82,11 +75,24 @@ void testGetRandomAccessFile(final OpenOption openOption) {
         assertThrows(UnsupportedOperationException.class, () -> 
super.testGetRandomAccessFile(openOption));
     }
 
+    @Override
+    @Test
+    void testGetOutputStream() {
+        // Cannot convert a byte[] to an OutputStream.
+        assertThrows(UnsupportedOperationException.class, 
super::testGetOutputStream);

Review Comment:
   A plain `byte[]` is not a reliable backing store for an `OutputStream`.
   
   * With `ByteArrayOutputStream` (and similar classes), the underlying array 
is replaced whenever it needs to grow and the original byte array will not 
longer receive any updates after that.
   * If we were to expose an `OutputStream` directly over a fixed `byte[]`, 
we’d have to either throw once the array’s capacity is exceeded or silently 
ignore extra writes. Neither option seems broadly useful.
   
   That’s why `ByteArrayOrigin#getOutputStream` is expected to throw.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to