Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered NotSerializableException for HttpComponentsHeadersAdapter when serializing HttpClientErrorException #31787

Closed
sammyhk opened this issue Dec 8, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@sammyhk
Copy link

sammyhk commented Dec 8, 2023

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

@sammyhk sammyhk changed the title encountered java.io.NotSerializableException: org.springframework.http.support.HttpComponentsHeadersAdapter when serializing org.springframework.web.client.HttpClientErrorException Encountered java.io.NotSerializableException: org.springframework.http.support.HttpComponentsHeadersAdapter when serializing org.springframework.web.client.HttpClientErrorException Dec 8, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 8, 2023
@sbrannen sbrannen changed the title Encountered java.io.NotSerializableException: org.springframework.http.support.HttpComponentsHeadersAdapter when serializing org.springframework.web.client.HttpClientErrorException Encountered NotSerializableException for HttpComponentsHeadersAdapter when serializing HttpClientErrorException Dec 8, 2023
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Dec 8, 2023
@poutsma poutsma self-assigned this Dec 11, 2023
@poutsma poutsma added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 11, 2023
@poutsma poutsma added this to the 6.1.2 milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants