Skip to content

Fix integration between Logbook and HttpClient5 #1368

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

mikhail-putilov
Copy link

@mikhail-putilov mikhail-putilov commented Jul 19, 2023

Background information

I recently migrated a project I am working on from Spring Boot 2 to 3.
After it, I noticed that Logbook stopped logging formatted XML.

After debugging, the main issue I found is the integration between Apache HttpClient5, Zalando Logbook and Spring-WS.

Logbook works well with JSON (Spring-Web) and does not have this issue.

Root cause of the issue

Logbook expects to find a non-blank Content Type from HttpEntity during his execution of org.zalando.logbook.BodyFilter chain.

Solution

I did, basically, the same what is already written for JSON in Spring-Web:
https://github.com/spring-projects/spring-framework/blob/v6.0.8/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java#L90

I copied the code from version 6.0.8 because that's what I had in my classpath. While I was creating this pull request I noticed that Spring team already refactored the above mentioned class: https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequest.java#L141

Logbook expects to find a non-blank Content Type from HttpEntity during
his execution of org.zalando.logbook.BodyFilter chain.
@mikhail-putilov
Copy link
Author

mikhail-putilov commented Jul 20, 2023

I am sorry for the import mess, I could not figure out how to set up the spring code style in Intellij IDEA in a reasonable time. If it is important, may I ask somebody to reformat import statements for me? Or point me in the right direction how to set up code style, please 🙂

@mikhail-putilov
Copy link
Author

Hi @gregturn
is there anything I can help to merge my PR? It is a small bug fix and I am sure it will help to a lot of people who use Spring-WS together with Logbook and HttpClient5

@gregturn gregturn closed this in 3aaa77e Sep 7, 2023
gregturn added a commit that referenced this pull request Sep 7, 2023
@gregturn gregturn self-assigned this Sep 7, 2023
@gregturn gregturn added in: messaging type: enhancement A general enhancement labels Sep 7, 2023
@gregturn gregturn added this to the 4.0.6 milestone Sep 7, 2023
@gregturn
Copy link
Contributor

gregturn commented Sep 7, 2023

Thanks @mikhail-putilov !

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants