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

Caused by: java.lang.NullPointerException: null at com.bettercloud.vault.rest.Rest.responseBodyBytes(Rest.java:519) #253

Open
brycechesternewman opened this issue Apr 14, 2023 · 0 comments

Comments

@brycechesternewman
Copy link

Hello.
We are using vault-java-driver 5.1.0.

Sometimes we are seeing this NPE.

  com.bettercloud.vault.VaultException: java.lang.NullPointerException
	at com.bettercloud.vault.api.Auth.loginByAwsIam(Auth.java:913)
	...
Caused by: java.lang.NullPointerException: null
	at com.bettercloud.vault.rest.Rest.responseBodyBytes(Rest.java:519)
	at com.bettercloud.vault.rest.Rest.postOrPutImpl(Rest.java:413)
	at com.bettercloud.vault.rest.Rest.post(Rest.java:306)
	at com.bettercloud.vault.api.Auth.loginByAwsIam(Auth.java:886)
	... 21 common frames omitted

In Rest.java at line 519 the inputStream is null.

...
            while ((bytesRead = inputStream.read(bytes, 0, bytes.length)) != -1) {
                byteArrayOutputStream.write(bytes, 0, bytesRead);
            }
...

The null needs to be handled since HttpURLConnection.java can return null.

 public InputStream getErrorStream() {
        return null;
    }
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

1 participant