Skip to content

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

@brycechesternewman

Description

@brycechesternewman

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;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions