ppkarwasz commented on code in PR #779: URL: https://github.com/apache/commons-io/pull/779#discussion_r2329746955
########## src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java: ########## @@ -80,21 +91,75 @@ void testAfterReadConsumer() throws Exception { // @formatter:on } - @SuppressWarnings("resource") - @Test - void testAvailableAfterClose() throws Exception { + static Stream<Arguments> testAvailableAfterClose() throws IOException { + // Case 1: behaves like ByteArrayInputStream — close() is a no-op, available() still returns a value (e.g., 42). + final InputStream noOpClose = mock(InputStream.class); + when(noOpClose.available()).thenReturn(42, 42); + + // Case 2: returns 0 after close (Commons memory-backed streams that ignore close but report 0 when exhausted). + final InputStream returnsZeroAfterClose = mock(InputStream.class); + when(returnsZeroAfterClose.available()).thenReturn(42, 0); + + // Case 3: throws IOException after close (e.g., FileInputStream-like behavior). + final InputStream throwsAfterClose = mock(InputStream.class); + when(throwsAfterClose.available()).thenReturn(42).thenThrow(new IOException("Stream closed")); + + return Stream.of( + Arguments.of("no-op close → still returns 42", noOpClose, 42), Review Comment: Fixed in https://github.com/apache/commons-io/pull/779/commits/403000c3087583c673ab5b6d8b56099394edd703 -- 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