Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

InstanceId.of(String, String) accepts null project, but InstanceId.equals doesn't handle null #145

Description

@sebright2

InstanceId.equals threw a NullPointerException when I accidentally set the project to null. I would have expected the exception to be thrown earlier, in the factory method.

Code example

@Test
public void test() {
  InstanceId instance1 = InstanceId.of("project", "instance-1");
  InstanceId instance2 = InstanceId.of(null, "instance-2");
  System.out.println(instance1.equals(instance2));
}

Stack trace

java.lang.NullPointerException
	at com.google.cloud.spanner.InstanceId.equals(InstanceId.java:66)
...

EDIT: I used google-cloud-spanner version 1.52.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/java-spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions