Ching-Yu Wu
Ching-Yu Wu

Reputation: 1

bigquery.tables().list() returns null by JAVA

I access bigquery by Java in order to check whether a table already exists in a dataset. After last Friday (11/7), my java code sometimes return null and a nullPointerException is throwed. For example,

Bigquery bigquery = new Bigquery.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName("BigQuery-Service-Accounts/0.1")
            .setHttpRequestInitializer(credential).build();

if(bigquery.tables().list(projectId, datasetId).execute().getTables() != null) {
    // do something
}

The method list() will return null and throw a java.lang.NullPointerException. This situation does not always happen, sometimes it will be fine when rerunning the code, but sometimes won't. My API version is BigQuery API v2 (Rev. 168) 1.19.0. Can anyone help to explain what happens? Thanks.

Upvotes: 0

Views: 739

Answers (1)

Pentium10
Pentium10

Reputation: 207830

You might want to run bigquery.tables().list(projectId, datasetId).execute() on it's own line, then catch the error if any.

Then of course you run next getTables(). You might want to dig in and search for other messages, like problems with credentials, SSL handshake problem. A full dump of the request would help you.

Upvotes: 1

Related Questions