diff --git a/README.md b/README.md index 12792a10b6..8fd23d2c2d 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:24.1.0') +implementation platform('com.google.cloud:libraries-bom:24.1.1') implementation 'com.google.cloud:google-cloud-bigquerystorage' ``` diff --git a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java index 6423fe43f7..20a6d1669f 100644 --- a/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java +++ b/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessage.java @@ -154,9 +154,6 @@ private static DynamicMessage convertJsonToProtoMessageImpl( String.format( "JSONObject does not have the required field %s.%s.", jsonScope, missingFieldName)); } - if (topLevel && msg.getSerializedSize() == 0) { - throw new IllegalArgumentException("The created protobuf message is empty."); - } return msg; } diff --git a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java index 96b46ed8d0..017c45f1e4 100644 --- a/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java +++ b/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonToProtoMessageTest.java @@ -1033,13 +1033,9 @@ public void testEmptyProtoMessage() throws Exception { JSONObject json = new JSONObject(); json.put("test_repeated", new JSONArray(new int[0])); - try { - DynamicMessage protoMsg = - JsonToProtoMessage.convertJsonToProtoMessage(RepeatedInt64.getDescriptor(), json); - Assert.fail("Should fail"); - } catch (IllegalArgumentException e) { - assertEquals("The created protobuf message is empty.", e.getMessage()); - } + DynamicMessage protoMsg = + JsonToProtoMessage.convertJsonToProtoMessage(RepeatedInt64.getDescriptor(), json); + assertEquals(protoMsg.getAllFields().size(), 0); } @Test @@ -1121,4 +1117,15 @@ public void testJsonNullValue() throws Exception { JsonToProtoMessage.convertJsonToProtoMessage(TestInt64.getDescriptor(), json); assertEquals(expectedProto, protoMsg); } + + @Test + public void testJsonAllFieldsNullValue() throws Exception { + TestInt64 expectedProto = TestInt64.newBuilder().build(); + JSONObject json = new JSONObject(); + json.put("long", JSONObject.NULL); + json.put("int", JSONObject.NULL); + DynamicMessage protoMsg = + JsonToProtoMessage.convertJsonToProtoMessage(TestInt64.getDescriptor(), json); + assertEquals(expectedProto, protoMsg); + } }