Hi Damjan,

Damjan Jovanovic wrote:

[snip]

Thanks for explanation.

> We would be able to adapt that for Java < 1.7 by swallowing the close
> exception instead of calling addSuppressed() on the primary exception,
> but the show stopper is catching and rethrowing the primary exception
> (Throwable), which javac < 1.7 refuses to compile because it doesn't
> do "Rethrowing Exceptions with More Inclusive Type Checking"
> (http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html).
> 
> But this would work and always sets succeeded correctly without
> catch/re-throw:
> 
> final InputStream is = factoryMethodThatCanThrow();
> boolean succeeded = false;
> try {
>     try {
>         is.methodThatCanThrow();
>     } finally {
>     }
>     succeeded = true;
> } finally {
>     closeSafely(!succeeded, is);
> }

I guess the nested try was unintentionally ;-)

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to