commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Rosenvold (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-469) "Self-suppression not permitted" while using BrokenOutput and BrokenInput streams with try-with-resource.
Date Fri, 19 Jun 2015 17:29:00 GMT

    [ https://issues.apache.org/jira/browse/IO-469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14593670#comment-14593670
] 

Kristian Rosenvold commented on IO-469:
---------------------------------------

And reverted again in r1686460 due to slight compatibility break

> "Self-suppression not permitted" while using BrokenOutput and BrokenInput streams with
try-with-resource. 
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: IO-469
>                 URL: https://issues.apache.org/jira/browse/IO-469
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Streams/Writers
>    Affects Versions: 2.4
>         Environment: Oracle JVM 1.8_25 (but should be reproducible starting from Java
7).
>            Reporter: Grigory Fadeev
>            Priority: Trivial
>
> Hi,
> First of all thanks a lot for great library :)
>  
> I faced with "Self-suppression not permitted" issue while using BrokenInputStream &
BrokenOutputStream classes with try-with-resources. 
> Root cause of this issue is that these classes always throws same exception instance
for all methods.
> That's how it looks like when javac unfolds try-with-resources: 
> {code:java}
>         InputStream is = new BrokenInputStream();
>         Throwable localThrowable2 = null;
>         try {
>             is.read();
>         } catch (Throwable localThrowable1) {
>             localThrowable2 = localThrowable1;
>             throw localThrowable1;
>         } finally {
>             if (is != null) {
>                 if (localThrowable2 != null) {
>                     try {
>                         is.close();
>                     } catch (Throwable x2) {
>                         localThrowable2.addSuppressed(x2);
>                     }
>                 } else {
>                     is.close();
>                 }
>             }
>         }
> {code}
> So as you can see when close method is invoked resulting exception will be added to itself
(first time thrown during read method), this leads to IllegalArgumentException "Self-suppression
not permitted".
> It can be easily fixed by omitting throwing of same exception instance for close method.

> If you don't mind I would attach patch which will fix this issue.  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message