From cdf0cf97e3479c02295a298ffbc849fbf047263c Mon Sep 17 00:00:00 2001 From: jubafourali Date: Fri, 5 Apr 2024 19:15:21 +0400 Subject: [PATCH] fixes --- .../RuntimeTypeAdapterFactory.java | 2 +- .../main/java/com/google/gson/JsonArray.java | 2 +- .../main/java/com/google/gson/JsonObject.java | 2 +- .../gson/DefaultMapJsonSerializerTest.java | 2 +- .../java/com/google/gson/JsonObjectTest.java | 14 +- .../google/gson/functional/JsonTreeTest.java | 2 +- ...ntimeTypeAdapterFactoryFunctionalTest.java | 2 +- ...gOfPrimitivesDeserializationBenchmark.java | 117 ------------- .../CollectionsDeserializationBenchmark.java | 138 --------------- .../metrics/DeserializationBenchmark.java | 165 ++++++++++++++++++ .../gson/protobuf/ProtoTypeAdapter.java | 12 +- 11 files changed, 184 insertions(+), 274 deletions(-) delete mode 100644 metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java delete mode 100644 metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java create mode 100644 metrics/src/main/java/com/google/gson/metrics/DeserializationBenchmark.java diff --git a/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java b/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java index fa70755abd..0359cf6457 100644 --- a/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java +++ b/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java @@ -312,7 +312,7 @@ public void write(JsonWriter out, R value) throws IOException { JsonObject clone = new JsonObject(); - if (jsonObject.has(typeFieldName)) { + if (jsonObject.hasMember(typeFieldName)) { throw new JsonParseException( "cannot serialize " + srcType.getName() diff --git a/gson/src/main/java/com/google/gson/JsonArray.java b/gson/src/main/java/com/google/gson/JsonArray.java index 6f680c7f3b..3604af0771 100644 --- a/gson/src/main/java/com/google/gson/JsonArray.java +++ b/gson/src/main/java/com/google/gson/JsonArray.java @@ -419,4 +419,4 @@ public boolean equals(Object o) { public int hashCode() { return elements.hashCode(); } -} +} \ No newline at end of file diff --git a/gson/src/main/java/com/google/gson/JsonObject.java b/gson/src/main/java/com/google/gson/JsonObject.java index d13be19dce..72d44f0590 100644 --- a/gson/src/main/java/com/google/gson/JsonObject.java +++ b/gson/src/main/java/com/google/gson/JsonObject.java @@ -170,7 +170,7 @@ public boolean isEmpty() { * @param memberName name of the member that is being checked for presence. * @return true if there is a member with the specified name, false otherwise. */ - public boolean has(String memberName) { + public boolean hasMember(String memberName) { return members.containsKey(memberName); } diff --git a/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java b/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java index 1fd2102234..c55f697b1f 100644 --- a/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java +++ b/gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java @@ -64,6 +64,6 @@ public void testNonEmptyMapSerialization() { assertThat(element.isJsonObject()).isTrue(); JsonObject mapJsonObject = element.getAsJsonObject(); - assertThat(mapJsonObject.has(key)).isTrue(); + assertThat(mapJsonObject.hasMember(key)).isTrue(); } } diff --git a/gson/src/test/java/com/google/gson/JsonObjectTest.java b/gson/src/test/java/com/google/gson/JsonObjectTest.java index 353fa102d2..a9686c2e40 100644 --- a/gson/src/test/java/com/google/gson/JsonObjectTest.java +++ b/gson/src/test/java/com/google/gson/JsonObjectTest.java @@ -44,7 +44,7 @@ public class JsonObjectTest { public void testAddingAndRemovingObjectProperties() { JsonObject jsonObj = new JsonObject(); String propertyName = "property"; - assertThat(jsonObj.has(propertyName)).isFalse(); + assertThat(jsonObj.hasMember(propertyName)).isFalse(); assertThat(jsonObj.get(propertyName)).isNull(); JsonPrimitive value = new JsonPrimitive("blah"); @@ -53,7 +53,7 @@ public void testAddingAndRemovingObjectProperties() { JsonElement removedElement = jsonObj.remove(propertyName); assertThat(removedElement).isEqualTo(value); - assertThat(jsonObj.has(propertyName)).isFalse(); + assertThat(jsonObj.hasMember(propertyName)).isFalse(); assertThat(jsonObj.get(propertyName)).isNull(); assertThat(jsonObj.remove(propertyName)).isNull(); @@ -65,7 +65,7 @@ public void testAddingNullPropertyValue() { JsonObject jsonObj = new JsonObject(); jsonObj.add(propertyName, null); - assertThat(jsonObj.has(propertyName)).isTrue(); + assertThat(jsonObj.hasMember(propertyName)).isTrue(); JsonElement jsonElement = jsonObj.get(propertyName); assertThat(jsonElement).isNotNull(); @@ -91,7 +91,7 @@ public void testAddingBooleanProperties() { JsonObject jsonObj = new JsonObject(); jsonObj.addProperty(propertyName, true); - assertThat(jsonObj.has(propertyName)).isTrue(); + assertThat(jsonObj.hasMember(propertyName)).isTrue(); JsonElement jsonElement = jsonObj.get(propertyName); assertThat(jsonElement).isNotNull(); @@ -106,7 +106,7 @@ public void testAddingStringProperties() { JsonObject jsonObj = new JsonObject(); jsonObj.addProperty(propertyName, value); - assertThat(jsonObj.has(propertyName)).isTrue(); + assertThat(jsonObj.hasMember(propertyName)).isTrue(); JsonElement jsonElement = jsonObj.get(propertyName); assertThat(jsonElement).isNotNull(); @@ -121,7 +121,7 @@ public void testAddingCharacterProperties() { JsonObject jsonObj = new JsonObject(); jsonObj.addProperty(propertyName, value); - assertThat(jsonObj.has(propertyName)).isTrue(); + assertThat(jsonObj.hasMember(propertyName)).isTrue(); JsonElement jsonElement = jsonObj.get(propertyName); assertThat(jsonElement).isNotNull(); @@ -344,4 +344,4 @@ public void testEntrySet() { assertThat(new ArrayList<>(o.entrySet())).isEqualTo(new ArrayList<>(expectedEntriesQueue)); } } -} +} \ No newline at end of file diff --git a/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java b/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java index 4a00f399d0..701df87598 100644 --- a/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java +++ b/gson/src/test/java/com/google/gson/functional/JsonTreeTest.java @@ -86,7 +86,7 @@ public void testJsonTreeToString() { public void testJsonTreeNull() { BagOfPrimitives bag = new BagOfPrimitives(10L, 5, false, null); JsonObject jsonElement = (JsonObject) gson.toJsonTree(bag, BagOfPrimitives.class); - assertThat(jsonElement.has("stringValue")).isFalse(); + assertThat(jsonElement.hasMember("stringValue")).isFalse(); } private static void assertContains(JsonObject json, JsonPrimitive child) { diff --git a/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java b/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java index 667d231f36..39e0aa67c5 100644 --- a/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java +++ b/gson/src/test/java/com/google/gson/functional/RuntimeTypeAdapterFactoryFunctionalTest.java @@ -213,7 +213,7 @@ public void write(JsonWriter out, R value) throws IOException { + "; did you forget to register a subtype?"); } JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); - if (!jsonObject.has(typeFieldName)) { + if (!jsonObject.hasMember(typeFieldName)) { JsonObject clone = new JsonObject(); clone.add(typeFieldName, new JsonPrimitive(label)); for (Map.Entry e : jsonObject.entrySet()) { diff --git a/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java deleted file mode 100644 index b841787d00..0000000000 --- a/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.metrics; - -import com.google.caliper.BeforeExperiment; -import com.google.gson.Gson; -import com.google.gson.stream.JsonReader; -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Field; - -/** - * Caliper based micro benchmarks for Gson - * - * @author Inderjeet Singh - * @author Jesse Wilson - * @author Joel Leitch - */ -public class BagOfPrimitivesDeserializationBenchmark { - - private Gson gson; - private String json; - - public static void main(String[] args) { - NonUploadingCaliperRunner.run(BagOfPrimitivesDeserializationBenchmark.class, args); - } - - @BeforeExperiment - void setUp() throws Exception { - this.gson = new Gson(); - BagOfPrimitives bag = new BagOfPrimitives(10L, 1, false, "foo"); - this.json = gson.toJson(bag); - } - - /** Benchmark to measure Gson performance for deserializing an object */ - public void timeBagOfPrimitivesDefault(int reps) { - for (int i = 0; i < reps; ++i) { - gson.fromJson(json, BagOfPrimitives.class); - } - } - - /** Benchmark to measure deserializing objects by hand */ - public void timeBagOfPrimitivesStreaming(int reps) throws IOException { - for (int i = 0; i < reps; ++i) { - StringReader reader = new StringReader(json); - JsonReader jr = new JsonReader(reader); - jr.beginObject(); - long longValue = 0; - int intValue = 0; - boolean booleanValue = false; - String stringValue = null; - while (jr.hasNext()) { - String name = jr.nextName(); - if (name.equals("longValue")) { - longValue = jr.nextLong(); - } else if (name.equals("intValue")) { - intValue = jr.nextInt(); - } else if (name.equals("booleanValue")) { - booleanValue = jr.nextBoolean(); - } else if (name.equals("stringValue")) { - stringValue = jr.nextString(); - } else { - throw new IOException("Unexpected name: " + name); - } - } - jr.endObject(); - new BagOfPrimitives(longValue, intValue, booleanValue, stringValue); - } - } - - /** - * This benchmark measures the ideal Gson performance: the cost of parsing a JSON stream and - * setting object values by reflection. We should strive to reduce the discrepancy between this - * and {@link #timeBagOfPrimitivesDefault(int)} . - */ - public void timeBagOfPrimitivesReflectionStreaming(int reps) throws IOException, IllegalAccessException { - for (int i = 0; i < reps; ++i) { - StringReader reader = new StringReader(json); - JsonReader jr = new JsonReader(reader); - jr.beginObject(); - BagOfPrimitives bag = new BagOfPrimitives(); - while (jr.hasNext()) { - String name = jr.nextName(); - for (Field field : BagOfPrimitives.class.getDeclaredFields()) { - if (field.getName().equals(name)) { - Class fieldType = field.getType(); - if (fieldType.equals(long.class)) { - field.setLong(bag, jr.nextLong()); - } else if (fieldType.equals(int.class)) { - field.setInt(bag, jr.nextInt()); - } else if (fieldType.equals(boolean.class)) { - field.setBoolean(bag, jr.nextBoolean()); - } else if (fieldType.equals(String.class)) { - field.set(bag, jr.nextString()); - } else { - throw new RuntimeException("Unexpected: type: " + fieldType + ", name: " + name); - } - } - } - } - jr.endObject(); - } - } -} \ No newline at end of file diff --git a/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java deleted file mode 100644 index b844abb381..0000000000 --- a/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.gson.metrics; - -import com.google.caliper.BeforeExperiment; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Field; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -/** - * Caliper based micro benchmarks for Gson - * - * @author Inderjeet Singh - */ -public class CollectionsDeserializationBenchmark { - - private static final TypeToken> LIST_TYPE_TOKEN = - new TypeToken>() {}; - private static final Type LIST_TYPE = LIST_TYPE_TOKEN.getType(); - private Gson gson; - private String json; - - public static void main(String[] args) { - NonUploadingCaliperRunner.run(CollectionsDeserializationBenchmark.class, args); - } - - @BeforeExperiment - void setUp() throws Exception { - this.gson = new Gson(); - List bags = new ArrayList<>(); - for (int i = 0; i < 100; ++i) { - bags.add(new BagOfPrimitives(10L, 1, false, "foo")); - } - this.json = gson.toJson(bags, LIST_TYPE); - } - - /** Benchmark to measure Gson performance for deserializing an object */ - public void timeCollectionsDefault(int reps) { - for (int i = 0; i < reps; ++i) { - gson.fromJson(json, LIST_TYPE_TOKEN); - } - } - - /** Benchmark to measure deserializing objects by hand */ - @SuppressWarnings("ModifiedButNotUsed") - public void timeCollectionsStreaming(int reps) throws IOException { - for (int i = 0; i < reps; ++i) { - StringReader reader = new StringReader(json); - JsonReader jr = new JsonReader(reader); - jr.beginArray(); - List bags = new ArrayList<>(); - while (jr.hasNext()) { - jr.beginObject(); - long longValue = 0; - int intValue = 0; - boolean booleanValue = false; - String stringValue = null; - while (jr.hasNext()) { - String name = jr.nextName(); - if (name.equals("longValue")) { - longValue = jr.nextLong(); - } else if (name.equals("intValue")) { - intValue = jr.nextInt(); - } else if (name.equals("booleanValue")) { - booleanValue = jr.nextBoolean(); - } else if (name.equals("stringValue")) { - stringValue = jr.nextString(); - } else { - throw new IOException("Unexpected name: " + name); - } - } - jr.endObject(); - bags.add(new BagOfPrimitives(longValue, intValue, booleanValue, stringValue)); - } - jr.endArray(); - } - } - - /** - * This benchmark measures the ideal Gson performance: the cost of parsing a JSON stream and - * setting object values by reflection. We should strive to reduce the discrepancy between this - * and {@link #timeCollectionsDefault(int)} . - */ - @SuppressWarnings("ModifiedButNotUsed") - public void timeCollectionsReflectionStreaming(int reps) throws Exception { - for (int i = 0; i < reps; ++i) { - StringReader reader = new StringReader(json); - JsonReader jr = new JsonReader(reader); - jr.beginArray(); - List bags = new ArrayList<>(); - while (jr.hasNext()) { - jr.beginObject(); - BagOfPrimitives bag = new BagOfPrimitives(); - while (jr.hasNext()) { - String name = jr.nextName(); - for (Field field : BagOfPrimitives.class.getDeclaredFields()) { - if (field.getName().equals(name)) { - Class fieldType = field.getType(); - if (fieldType.equals(long.class)) { - field.setLong(bag, jr.nextLong()); - } else if (fieldType.equals(int.class)) { - field.setInt(bag, jr.nextInt()); - } else if (fieldType.equals(boolean.class)) { - field.setBoolean(bag, jr.nextBoolean()); - } else if (fieldType.equals(String.class)) { - field.set(bag, jr.nextString()); - } else { - throw new RuntimeException("Unexpected: type: " + fieldType + ", name: " + name); - } - } - } - } - jr.endObject(); - bags.add(bag); - } - jr.endArray(); - } - } -} diff --git a/metrics/src/main/java/com/google/gson/metrics/DeserializationBenchmark.java b/metrics/src/main/java/com/google/gson/metrics/DeserializationBenchmark.java new file mode 100644 index 0000000000..45c2e78a84 --- /dev/null +++ b/metrics/src/main/java/com/google/gson/metrics/DeserializationBenchmark.java @@ -0,0 +1,165 @@ +package com.google.gson.metrics; + +import com.google.caliper.BeforeExperiment; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +public class DeserializationBenchmark { + private static final TypeToken> LIST_TYPE_TOKEN = + new TypeToken>() {}; + private static final Type LIST_TYPE = LIST_TYPE_TOKEN.getType(); + private Gson gson; + private String jsonSingle; + private String jsonCollection; + + public static void main(String[] args) { + NonUploadingCaliperRunner.run(DeserializationBenchmark.class, args); + } + @BeforeExperiment + void setUp() throws Exception { + this.gson = new Gson(); + //setup for single object + BagOfPrimitives singleBag = new BagOfPrimitives(10L, 1, false, "foo"); + this.jsonSingle = gson.toJson(singleBag); + //setup for collection + List bags = new ArrayList<>(); + for (int i = 0; i < 100; ++i) { + bags.add(new BagOfPrimitives(10L, 1, false, "foo")); + } + this.jsonCollection = gson.toJson(bags, LIST_TYPE); + } + + public void timeSingleObjectBagOfPrimitivesDefault(int reps) { + for (int i = 0; i < reps; ++i) { + gson.fromJson(jsonSingle, BagOfPrimitives.class); + } + } + + public void timeCollectionsDefault(int reps) { + for (int i = 0; i < reps; ++i) { + gson.fromJson(jsonCollection, LIST_TYPE_TOKEN); + } + } + + private BagOfPrimitives parseAndAssignFields(JsonReader jr)throws IOException{ + jr.beginObject(); + long longValue = 0; + int intValue = 0; + boolean booleanValue = false; + String stringValue = null; + while (jr.hasNext()) { + String name = jr.nextName(); + if (name.equals("longValue")) { + longValue = jr.nextLong(); + } else if (name.equals("intValue")) { + intValue = jr.nextInt(); + } else if (name.equals("booleanValue")) { + booleanValue = jr.nextBoolean(); + } else if (name.equals("stringValue")) { + stringValue = jr.nextString(); + } else { + throw new IOException("Unexpected name: " + name); + } + } + jr.endObject(); + return new BagOfPrimitives(longValue, intValue, booleanValue, stringValue); + + } + + + /** Benchmark to measure deserializing objects by hand */ + public void timeBagOfPrimitivesStreaming(int reps) throws IOException { + for (int i = 0; i < reps; ++i) { + StringReader reader = new StringReader(jsonSingle); + JsonReader jr = new JsonReader(reader); + parseAndAssignFields(jr); + } + } + + + /** Benchmark to measure deserializing objects by hand */ + @SuppressWarnings("ModifiedButNotUsed") + public void timeCollectionsStreaming(int reps) throws IOException { + for (int i = 0; i < reps; ++i) { + StringReader reader = new StringReader(jsonCollection); + JsonReader jr = new JsonReader(reader); + jr.beginArray(); + List bags = new ArrayList<>(); + while (jr.hasNext()) { + BagOfPrimitives bagOfPrimitives = parseAndAssignFields(jr); + bags.add(bagOfPrimitives); + } + jr.endArray(); + } + } + + + private BagOfPrimitives parseAndSetFieldFromJson(JsonReader jr) throws IOException, IllegalAccessException{ + jr.beginObject(); + BagOfPrimitives bag = new BagOfPrimitives(); + while (jr.hasNext()) { + String name = jr.nextName(); + for (Field field : BagOfPrimitives.class.getDeclaredFields()) { + if (field.getName().equals(name)) { + Class fieldType = field.getType(); + if (fieldType.equals(long.class)) { + field.setLong(bag, jr.nextLong()); + } else if (fieldType.equals(int.class)) { + field.setInt(bag, jr.nextInt()); + } else if (fieldType.equals(boolean.class)) { + field.setBoolean(bag, jr.nextBoolean()); + } else if (fieldType.equals(String.class)) { + field.set(bag, jr.nextString()); + } else { + throw new RuntimeException("Unexpected: type: " + fieldType + ", name: " + name); + } + } + } + } + jr.endObject(); + return bag; + } + + + /** + * This benchmark measures the ideal Gson performance: the cost of parsing a JSON stream and + * setting object values by reflection. We should strive to reduce the discrepancy between this + * and {@link #timeSingleObjectBagOfPrimitivesDefault(int)} . + */ + public void timeBagOfPrimitivesReflectionStreaming(int reps) throws IOException, IllegalAccessException { + for (int i = 0; i < reps; ++i) { + StringReader reader = new StringReader(jsonSingle); + JsonReader jr = new JsonReader(reader); + parseAndSetFieldFromJson(jr); + } + } + + + /** + * This benchmark measures the ideal Gson performance: the cost of parsing a JSON stream and + * setting object values by reflection. We should strive to reduce the discrepancy between this + * and {@link #timeCollectionsDefault(int)} . + */ + @SuppressWarnings("ModifiedButNotUsed") + public void timeCollectionsReflectionStreaming(int reps) throws Exception { + for (int i = 0; i < reps; ++i) { + StringReader reader = new StringReader(jsonCollection); + JsonReader jr = new JsonReader(reader); + jr.beginArray(); + List bags = new ArrayList<>(); + while (jr.hasNext()) { + BagOfPrimitives bag = parseAndSetFieldFromJson(jr); + bags.add(bag); + } + jr.endArray(); + } + } + +} \ No newline at end of file diff --git a/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java b/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java index 7b872f1885..7cc903b53a 100644 --- a/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java +++ b/proto/src/main/java/com/google/gson/protobuf/ProtoTypeAdapter.java @@ -219,7 +219,7 @@ private ProtoTypeAdapter( @Override public JsonElement serialize(Message src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject ret = new JsonObject(); + JsonObject serializedMessage = new JsonObject(); final Map fields = src.getAllFields(); for (Map.Entry fieldPair : fields.entrySet()) { @@ -236,17 +236,17 @@ public JsonElement serialize(Message src, Type typeOfSrc, JsonSerializationConte (Collection) fieldPair.getValue(); for (EnumValueDescriptor enumDesc : enumDescs) { array.add(context.serialize(getEnumValue(enumDesc))); - ret.add(name, array); + serializedMessage.add(name, array); } } else { EnumValueDescriptor enumDesc = ((EnumValueDescriptor) fieldPair.getValue()); - ret.add(name, context.serialize(getEnumValue(enumDesc))); + serializedMessage.add(name, context.serialize(getEnumValue(enumDesc))); } } else { - ret.add(name, context.serialize(fieldPair.getValue())); + serializedMessage.add(name, context.serialize(fieldPair.getValue())); } } - return ret; + return serializedMessage; } @Override @@ -404,4 +404,4 @@ private static Method getCachedMethod( } return method; } -} +} \ No newline at end of file