Current implementation of LoggingResponseDecorator may log uninitialized headers
Closed this issue · 2 comments
ygreyeb commented
During instantiation of the LoggingResponseDecorator
, you are logging the headers of the response.
At that point the headers may not be initialized or fully committed. Besides, if I wanted to log the status code of the response, that would also be undefined at that stage. I have only tested this on the Java version of this code, but invoking the beforeCommit
delegate method worked for me:
public LoggingResponseDecorator(ServerHttpResponse delegate) {
super(delegate);
beforeCommit(() -> Mono.fromRunnable(() -> {
if (log.isDebugEnabled()) {
log.debug("{} {}", getStatusCode(), getHeaders());
}
}));
}
Sorry to create an issue of this, but the blog entry has the comments disabled.