BigtableSession should check for null credentials
See original GitHub issueI am using the Bigtable emulator for development, which doesn’t require authentication so is configured with CredentialType.None
. The CredentialFactory
returns null
when asked for credentials of this type:
https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/master/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/config/CredentialFactory.java#L138
BigtableSession
uses this factory and does not check for null
credentials, resulting in null
being passed into createNettyChannel
:
https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/master/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableSession.java#L470
This leads to failure with a NullPointerException
:
Exception in thread "main" java.lang.NullPointerException: interceptor
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
at io.grpc.ClientInterceptors$InterceptorChannel.<init>(ClientInterceptors.java:113)
at io.grpc.ClientInterceptors$InterceptorChannel.<init>(ClientInterceptors.java:107)
at io.grpc.ClientInterceptors.intercept(ClientInterceptors.java:102)
at io.grpc.internal.ManagedChannelImpl.<init>(ManagedChannelImpl.java:406)
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:295)
at com.google.cloud.bigtable.grpc.BigtableSession.createNettyChannel(BigtableSession.java:494)
at com.google.cloud.bigtable.grpc.BigtableSession$5.create(BigtableSession.java:462)
at com.google.cloud.bigtable.grpc.io.ChannelPool.<init>(ChannelPool.java:246)
at com.google.cloud.bigtable.grpc.BigtableSession.createChannelPool(BigtableSession.java:458)
at com.google.cloud.bigtable.grpc.BigtableSession.createChannelPool(BigtableSession.java:439)
at com.google.cloud.bigtable.grpc.BigtableClusterUtilities.<init>(BigtableClusterUtilities.java:152)
at com.google.cloud.bigtable.grpc.BigtableClusterUtilities.forAllInstances(BigtableClusterUtilities.java:69)
at com.google.cloud.bigtable.grpc.BigtableClusterUtilities.lookupInstanceId(BigtableClusterUtilities.java:82)
at com.google.cloud.bigtable.grpc.BigtableSession.resolveLegacyOptions(BigtableSession.java:278)
at com.google.cloud.bigtable.grpc.BigtableSession.<init>(BigtableSession.java:205)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Hi @sduskis @mbrukman, That error happened when I was setting the
BIGTABLE_EMULATOR_HOST
env var. I believe it’s because ofCredentialOptions.nullOption()
being set here: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/bigtable-client-0.9.6.2/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/config/BigtableOptions.java#L238This leads to a null credentials interceptor being set here: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/bigtable-client-0.9.6.2/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/BigtableSession.java#L454
…because of the null returned here: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/bigtable-client-0.9.6.2/bigtable-client-core-parent/bigtable-client-core/src/main/java/com/google/cloud/bigtable/grpc/io/CredentialInterceptorCache.java#L98
My workaround is to not set the
BIGTABLE_EMULATOR_HOST
env var, and instead configure the Bigtable options myself, setting a fake JSON credentials.We fixed this problem recently. This ought to be fixed once we release 1.4.0