Skip to content

Caused by: java.lang.NullPointerException: null at com.bettercloud.vault.rest.Rest.responseBodyBytes #30

Closed

Description

@brycechesternewman

Hello.
We are using BetterCloud vault-java-driver 5.1.0 and I just read that the BetterCloud project is no more, so...

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions