Affects: 6.1.1
We are upgrading Spring Framework 5.3.x (Apache HttpComponents 4.5.x) to 6.1.1 (Apache HttpComponents 5.2.x) and got the java.io.NotSerializableException: org.springframework.http.support.HttpComponentsHeadersAdapter
when serializing org.springframework.web.client.HttpClientErrorException
.
Which is caused by org.springframework.web.client.HttpClientErrorException
will store the org.springframework.http.HttpHeaders
. When using HttpComponents 5, https://github.com/spring-projects/spring-framework/blob/3b4c7a890608bf006d0424355ad82cf8815c98da/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java#L176C30-L176C30 the concrete class of ClientHttpResponse
is org.springframework.http.client.HttpComponentsClientHttpResponse
which will return a HttpHeaders
wrapped with org.springframework.http.support.HttpComponentsHeadersAdapter
which is not serializable: https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java#L69