Skip to content

StringEnumValue does not support reference equality after Serialization #3942

@pmkc

Description

@pmkc

Environment details

  • OS: Linux (Debian 9)
  • Java version: openjdk version "1.8.0_181"
  • google-cloud-java version(s): 1.52.0

Steps to reproduce

  1. Serialize StringEnumValue
  2. Deserialize StringEnumValue
  3. Use it in a way that requires reference equality
  4. Crash

Stacktrace

Exception in thread "main" java.lang.IllegalArgumentException: Only RECORD fields can have sub-fields
        at com.google.cloud.bigquery.Field$Builder.setType(Field.java:137)
        at com.google.cloud.bigquery.Field.newBuilder(Field.java:275)
        at com.google.cloud.bigquery.Field.of(Field.java:261)
        at App.main(App.java:27)

Code snippet

LegacySQLTypeName record = SerializationUtils.clone(LegacySQLTypeName.RECORD);
System.out.println(LegacySQLTypeName.RECORD == record); // false
Field.of("foo", record, Field.of("bar", LegacySQLTypeName.BOOLEAN)); // throws

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery 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