Skip to content

Conversation

@kasmarian
Copy link
Member

@kasmarian kasmarian commented Dec 19, 2025

Description

Implement eager buffering by immediately buffering the request body when withBody() is called, before the stream closes. This ensures the body is cached and available to both:

  • The downstream controller (via wrapped/buffered streams)
  • The Logbook sink (for logging)

Motivation and Context

#2194

When using postponed logging strategies like body-only-if-status-at-least, request bodies were not reaching the controller. The issue was that:

  • Logbook deferred body buffering until later in the request lifecycle
  • By that time, the servlet container had already closed the input stream
  • The controller received an empty request body

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All commits are signed

@ChristianLohmann
Copy link
Member

👍

@lukasniemeier-zalando
Copy link
Member

Warning:  Rule violated for class org.zalando.logbook.servlet.RemoteRequest.Offering: lines covered ratio is 0.9, but expected minimum is 1.0

…ged despite the strategy, when the decision for this is made after the with() call.
@kasmarian
Copy link
Member Author

@lukasniemeier-zalando fixed the build, but had to re-do the changes. Please have another look

@kasmarian
Copy link
Member Author

@ChristianLohmann sorry, didn't ping you in the previous message, but since the changeset that you've approved is changed significantly, now, please have another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes and patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants