Receiving a NullPointerException on timeout in HttpComponentsClientHttpConnector when using Apache HttpComponents.

HttpComponents (core5) throws exceptions on timeout as follows: stream.reset(new H2StreamResetException(H2Error.NO_ERROR, "Timeout due to inactivity (" + timeout + ")"));

Spring Web HttpComponentsClientHttpConnector handles it as follows;

Throwable t = (ex instanceof HttpStreamResetException hsre ? hsre.getCause() : ex);
this.sink.error(t);

Since hsre.getCause() is null, it produces a NullPointerException when handling upstream in the constructor of WebClientRequestException.

Solution: If HttpStreamResetException cause is null, the exception itself should be returned.

Spring version: 6.0.4 HttpComponents (core5) version: 5.1.5