java-server-sdk icon indicating copy to clipboard operation
java-server-sdk copied to clipboard

ApiException.getMessage throws NullPointerException when IOException occurs

Open jlorenzen opened this issue 3 years ago • 1 comments

Describe the bug I'm noticing a NullPointerException when an IO error happens and I attempt to call the ApiException.getMessage method.

To reproduce Trigger an IOException when using the java sdk. I'm triggering this using mock-server's withDropConnection feature.

Expected behavior I should not see an NPE.

SDK version 13.0.0

Language version, developer tools Java 17

OS/platform M1 Mac

Additional context I believe the issue is because when an IO errors happens, the headers are null and this line in ApiException is what throws the NPE.

    public String getMessage() {
        return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s",
                super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders().toString());
    }

jlorenzen avatar Aug 21 '23 16:08 jlorenzen

Hello @jlorenzen, thank you for reporting this issue. We will look into this and get back to you.

Filed internally as 213590.

louis-launchdarkly avatar Aug 21 '23 18:08 louis-launchdarkly