Skip to content

ApiException.getMessage throws NullPointerException when IOException occurs #30

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

Closed
jlorenzen opened this issue Aug 21, 2023 · 2 comments
Labels

Comments

@jlorenzen
Copy link

jlorenzen commented Aug 21, 2023

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());
    }
@louis-launchdarkly
Copy link

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

Filed internally as 213590.

@tanderson-ld tanderson-ld transferred this issue from launchdarkly/java-server-sdk May 28, 2024
@tanderson-ld tanderson-ld added bug Something isn't working package: java-server-sdk labels May 28, 2024
Copy link
Contributor

This issue is stale because it has been open for 90 days without activity. Remove the stale label or comment, or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Aug 27, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants