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 2021/09/27 16:06:57 UTC

[GitHub] [commons-io] robtimus opened a new pull request #278: BrokenInputStream/Reader/OutputStream/Writer use a supplier …

robtimus opened a new pull request #278:
URL: https://github.com/apache/commons-io/pull/278


   …to prevent IllegalArgumentExceptions in try-with-resources


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



[GitHub] [commons-io] garydgregory commented on pull request #278: BrokenInputStream/Reader/OutputStream/Writer use a supplier …

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #278:
URL: https://github.com/apache/commons-io/pull/278#issuecomment-929417264


   https://issues.apache.org/jira/browse/IO-729


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



[GitHub] [commons-io] robtimus commented on pull request #278: Prevent IllegalArgumentExceptions in BrokenInputStream/Reader/OutputStream/Writer

Posted by GitBox <gi...@apache.org>.
robtimus commented on pull request #278:
URL: https://github.com/apache/commons-io/pull/278#issuecomment-929499159


   @garydgregory I've added periods and made all new variables in the tests final.


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



[GitHub] [commons-io] garydgregory merged pull request #278: Prevent IllegalArgumentExceptions in BrokenInputStream/Reader/OutputStream/Writer

Posted by GitBox <gi...@apache.org>.
garydgregory merged pull request #278:
URL: https://github.com/apache/commons-io/pull/278


   


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



[GitHub] [commons-io] garydgregory commented on pull request #278: BrokenInputStream/Reader/OutputStream/Writer use a supplier …

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #278:
URL: https://github.com/apache/commons-io/pull/278#issuecomment-929417264


   https://issues.apache.org/jira/browse/IO-729


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



[GitHub] [commons-io] garydgregory commented on a change in pull request #278: BrokenInputStream/Reader/OutputStream/Writer use a supplier …

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #278:
URL: https://github.com/apache/commons-io/pull/278#discussion_r717135976



##########
File path: src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
##########
@@ -67,4 +67,18 @@ public void testSkip() {
         assertEquals(exception, assertThrows(IOException.class, () -> stream.skip(1)));
     }
 
+    @Test
+    public void testTryWithResources() {
+        IOException thrown = assertThrows(IOException.class, () -> {

Review comment:
       Use final where you can.

##########
File path: src/test/java/org/apache/commons/io/input/BrokenReaderTest.java
##########
@@ -86,4 +86,19 @@ public void testSkip() {
         assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.skip(1)));
     }
 
+    @Test
+    public void testTryWithResources() {
+        IOException thrown = assertThrows(IOException.class, () -> {
+            try (Reader newReader = new BrokenReader()) {
+                newReader.read();
+            }
+        });
+        assertEquals("Broken reader", thrown.getMessage());
+
+        Throwable[] suppressed = thrown.getSuppressed();

Review comment:
       Use final where you can.

##########
File path: src/main/java/org/apache/commons/io/output/BrokenWriter.java
##########
@@ -54,7 +55,17 @@ public BrokenWriter() {
      * @param exception the exception to be thrown
      */
     public BrokenWriter(final IOException exception) {
-        this.exception = exception;
+        this(() -> exception);
+    }
+
+    /**
+     * Creates a new writer that always throws an {@link IOException}.
+     *
+     * @param exceptionSupplier a supplier for the exception to be thrown

Review comment:
       End sentences in a period.
   




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



[GitHub] [commons-io] robtimus commented on pull request #278: Prevent IllegalArgumentExceptions in BrokenInputStream/Reader/OutputStream/Writer

Posted by GitBox <gi...@apache.org>.
robtimus commented on pull request #278:
URL: https://github.com/apache/commons-io/pull/278#issuecomment-929499159


   @garydgregory I've added periods and made all new variables in the tests final.


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



[GitHub] [commons-io] garydgregory commented on a change in pull request #278: BrokenInputStream/Reader/OutputStream/Writer use a supplier …

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #278:
URL: https://github.com/apache/commons-io/pull/278#discussion_r717135976



##########
File path: src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
##########
@@ -67,4 +67,18 @@ public void testSkip() {
         assertEquals(exception, assertThrows(IOException.class, () -> stream.skip(1)));
     }
 
+    @Test
+    public void testTryWithResources() {
+        IOException thrown = assertThrows(IOException.class, () -> {

Review comment:
       Use final where you can.

##########
File path: src/test/java/org/apache/commons/io/input/BrokenReaderTest.java
##########
@@ -86,4 +86,19 @@ public void testSkip() {
         assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.skip(1)));
     }
 
+    @Test
+    public void testTryWithResources() {
+        IOException thrown = assertThrows(IOException.class, () -> {
+            try (Reader newReader = new BrokenReader()) {
+                newReader.read();
+            }
+        });
+        assertEquals("Broken reader", thrown.getMessage());
+
+        Throwable[] suppressed = thrown.getSuppressed();

Review comment:
       Use final where you can.

##########
File path: src/main/java/org/apache/commons/io/output/BrokenWriter.java
##########
@@ -54,7 +55,17 @@ public BrokenWriter() {
      * @param exception the exception to be thrown
      */
     public BrokenWriter(final IOException exception) {
-        this.exception = exception;
+        this(() -> exception);
+    }
+
+    /**
+     * Creates a new writer that always throws an {@link IOException}.
+     *
+     * @param exceptionSupplier a supplier for the exception to be thrown

Review comment:
       End sentences in a period.
   




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



[GitHub] [commons-io] garydgregory merged pull request #278: Prevent IllegalArgumentExceptions in BrokenInputStream/Reader/OutputStream/Writer

Posted by GitBox <gi...@apache.org>.
garydgregory merged pull request #278:
URL: https://github.com/apache/commons-io/pull/278


   


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