You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the async http client, as zalando/riptide is now doing as of version 2.x, we're failing with an exception when logging responses:
java.lang.IllegalStateException: Content has not been provided
I found this post from an old mailing list (2013, not sure if it still applies) and it states:
HTTP messages passed to async message consumers contain full message
head (status line or request line plus all headers) and an HttpEntity
which is not attached to any data stream and is merely a descriptor.
It doesn't directly refer to interceptors, but it makes sense that it also applies.
After reading the docs of HttpResponseInterceptor it should be possible to delay the logging until someone provides the content:
Interceptors can also manipulate content entities enclosed with messages.
Usually this is accomplished by using the 'Decorator' pattern where a wrapper
entity class is used to decorate the original entity.
Unfortunately the method interface is not making it obvious how to do that:
I guess this one could do the trick, although we need to be careful not to consume the underlying stream:
/** * Associates a response entity with this response. * <p> * Please note that if an entity has already been set for this response and it depends on * an input stream ({@link HttpEntity#isStreaming()} returns {@code true}), * it must be fully consumed in order to ensure release of resources. * * @param entity the entity to associate with this response, or * {@code null} to unset * * @see HttpEntity#isStreaming() * @see org.apache.http.util.EntityUtils#updateEntity(HttpResponse, HttpEntity) */voidsetEntity(HttpEntityentity);
The text was updated successfully, but these errors were encountered:
When using the async http client, as zalando/riptide is now doing as of version 2.x, we're failing with an exception when logging responses:
I found this post from an old mailing list (2013, not sure if it still applies) and it states:
It doesn't directly refer to interceptors, but it makes sense that it also applies.
After reading the docs of HttpResponseInterceptor it should be possible to delay the logging until someone provides the content:
Unfortunately the method interface is not making it obvious how to do that:
I guess this one could do the trick, although we need to be careful not to consume the underlying stream:
The text was updated successfully, but these errors were encountered: