zalando/logbook

mark/reset not supported after adding LogbookClientHttpRequestInterceptor with TRACE logging level

HaniBikdeli opened this issue · 3 comments

Hi
Whenever I use rest template and adding LogbookClientHttpRequestInterceptor as an interceptor to my RestTemplate bean and setting the log level to TRACE i run into this exception: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://example.com": mark/reset not supported;

Description

I added the logbook-spring-boot-starter dependency in order to log the request and response of the third-party web services i consume using RestTemplate. Therefore I changed my RestTemplate bean to add the interceptor to it like this:

    @Bean
    public RestTemplate restTemplate(LogbookClientHttpRequestInterceptor interceptor) {
        RestTemplate restTemplate = new RestTemplate();
        List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
        interceptors.add(interceptor);
        restTemplate.setInterceptors(interceptors);
        return restTemplate;
    }

I also set the logging level to TRACE: org.zalando.logbook: TRACE.

When I try to call a web service using rest template the logging of the request works but just after that i get this exception:

org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://example.com": mark/reset not supported; nested exception is java.io.IOException: mark/reset not supported

Expected Behavior

I expect to get a log of the request and then get the desired response along with a log of response and its body.

Actual Behavior

I get the request log but after that i encounter the exception mentioned above.

Possible Fix

Steps to Reproduce

  1. add the logbook-spring-boot-starter dependency
  2. add the LogbookClientHttpRequestInterceptor interceptor to the rest template bean
  3. set the logging level to TRACE

Context

I am trying to see a log of request and the response of the web services i'm consuming using rest template.

Your Environment

  • Version used:
  • Link to your project:

Hi @HaniBikdeli, please help me reproduce the issue. I followed the steps you listed, but can see the logs. Could you create a repo where this is reproducible and share it here? Probably, some details are missing.