Encountered NotSerializableException
for HttpComponentsHeadersAdapter
when serializing HttpClientErrorException
#31787
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: regression
A bug that is also a regression
Milestone
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 serializingorg.springframework.web.client.HttpClientErrorException
.Which is caused by
org.springframework.web.client.HttpClientErrorException
will store theorg.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 ofClientHttpResponse
isorg.springframework.http.client.HttpComponentsClientHttpResponse
which will return aHttpHeaders
wrapped withorg.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#L69The text was updated successfully, but these errors were encountered: