On Mon, 4 Sep 2023 16:44:24 GMT, Daniel Fuchs <[email protected]> wrote:
>> I don't know the history but it is very old code and just to be on safer
>> side i did the same changes as per getInputStream0(). Looking from out side
>> wrapping the 'RuntimeException' into another 'RuntimeException' not make
>> much sense.
>
> I suspect the wrapping is here to make sure the caller of getInputStream()
> appears in the call stack.
> If you have code that does this:
>
>
> try {
> conn.getInputStream(); <<< rememberedException set here (1)
> } catch (Exception e) { }
> ...
> // retry
> conn.getInputStream(); >>> rememberedException thrown here (2)
>
>
> then the exception will be thrown at (2) but the stack trace will show it
> thrown at (1), which will be confusing when debugging. If you wrap it you
> will see both (1) and (2) in the stack trace. Specifically, you will see an
> exception thrown at (2) that wraps an exception thrown at (1).
Thank you Daniel, that makes sense. Perhaps we could add a comment at the place
where we are rethrowing this.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15483#discussion_r1315414592