Skip to content

Datastore: When using grpc as transport with an emulator, requests are still sent to the google service #2022

@fp7

Description

@fp7
  1. OS type and version: google-cloud-datastore 2.33.0
  2. Java version: openjdk 25

Steps to reproduce

  1. Start a firestore emulator in datastore mode gcloud emulators firestore start --database-mode=datastore-mode --host-port "localhost:8082"
  2. Try to connect to it with grpc

Code example

DatastoreOptions.newBuilder()
            .setHost("localhost:8082")
            .setProjectId("project")
            .setTransportOptions(GrpcTransportOptions.newBuilder()
                .build())
            .build()
            .getService()

The requests will go to the google apis instead of the emulator.

I think the problem is within com.google.cloud.datastore.spi.v1.GrpcDatastoreRpc
The lines

.setTransportChannelProvider(
DatastoreSettings.defaultGrpcTransportProviderBuilder()
.setChannelPoolSettings(
ChannelPoolSettings.builder()
.setInitialChannelCount(DatastoreOptions.INIT_CHANNEL_COUNT)
.setMinChannelCount(DatastoreOptions.MIN_CHANNEL_COUNT)
.build())
.build())
override the channelprovider unconditionally. I think they should only do that, when isEmulator(datastoreOptions) is false

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/java-datastore API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions