On Thu, 21 Apr 2022 22:10:36 GMT, Pavel Rappo <[email protected]> wrote:
> The changes for the `UncheckedIOException` wrappers look OK, but might be
> even better if the code properly unwrapped the wrapper and simply rethrew the
> underlying cause. For example,
>
> replace
>
> ```
> } catch (UncheckedIOException ex) {
> throw new IOException(ex.getMessage(), ex);
> ```
>
> with
>
> ```
> } catch (UncheckedIOException ex) {
> throw ex.getCause();
> ```
Thanks for directing my attention to these two exceptions! I think I lost my
marbles for a good few minutes when decided to change them like that. I must've
been thinking about something else.
Those two exceptions are used as intended: for exceptional circumstances. So
their stacktraces have diagnostic value. I don't think we should re-throw the
cause, because the stacktrace might look confusing.
The only thing we could improve here is to replace ad-hoc
`UncheckedIOException` with standard `java.io.UncheckedIOException`, which
appeared much later in the codebase. Please have a look at
a42a66268f9d2175d212e6a5cba52fd11ec5332b and tell me what you think.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8347