Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

FeignException::responseBody() returns request body instead of response body #2618

Open
BartoszMiller opened this issue Oct 24, 2024 · 2 comments

Comments

@BartoszMiller
Copy link

I wanted to retrieve response body from a FeignException, but FeignException::responseBody() returns request body of my request. Is it intentional or is it a bug? One of the FeignException constructors, as the parameter name implies, expects response body. However, in the errorReading method request.body() is passed instead.

static FeignException errorReading(Request request, Response response, IOException cause) {
    return new FeignException(
        response.status(),
        format("%s reading %s %s", cause.getMessage(), request.httpMethod(), request.url()),
        request,
        cause,
        request.body(),
        request.headers());
  }
protected FeignException(
      int status,
      String message,
      Request request,
      Throwable cause,
      byte[] responseBody,
      Map<String, Collection<String>> responseHeaders) {
    super(message, cause);
    this.status = status;
    this.responseBody = responseBody;
    this.responseHeaders = caseInsensitiveCopyOf(responseHeaders);
    this.request = checkRequestNotNull(request);
  }
@gromspys
Copy link
Contributor

Yes. It looks like a bug.

@Aryant-Tripathi
Copy link

Hey @gromspys, I want to work around feign and learn about it. Do we need to change the constructor params since it expects the response body as byte[] and response? getBody() is a String in nature.

What do you think we can do here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants