Skip to content

BigQueryImpl.testIamPermissions can throw NPE #1595

@rculbertson

Description

@rculbertson

BigQueryImpl.testIamPermissions will throw a NullPointerException if the caller does not have any of the permissions being checked.

If none of the permissions being checked are granted, BigQuery returns an empty json object, {}.
This causes TestIamPermissionsResponse.permissions to be set to null.
On this line, BigQueryImpl calls ImmutableList.copyOf(response.getPermissions()).
This causes copyOf to throw a NullPointerException, and produces this stack trace.

java.lang.NullPointerException
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:259)
	at com.google.cloud.bigquery.BigQueryImpl.testIamPermissions(BigQueryImpl.java:1496)
	at com.spotify.ml.featureregistry.validation.iam.BigQueryIamTester.lambda$credentialsHavePermission$0(BigQueryIamTester.java:39)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Metadata

Metadata

Labels

api: bigqueryIssues related to the googleapis/java-bigquery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions