TheNeuralBit commented on a change in pull request #12426:
URL: https://github.com/apache/beam/pull/12426#discussion_r463194527



##########
File path: 
runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/CommonCoderTest.java
##########
@@ -366,12 +368,15 @@ private static Object parseField(Object value, 
Schema.FieldType fieldType) {
                 .map((element) -> parseField(element, 
fieldType.getCollectionElementType()))
                 .collect(toImmutableList());
       case MAP:
-        Map<Object, Object> kvMap = (Map<Object, Object>) value;
-        return kvMap.entrySet().stream()
-            .collect(
-                toImmutableMap(
-                    (pair) -> parseField(pair.getKey(), 
fieldType.getMapKeyType()),
-                    (pair) -> parseField(pair.getValue(), 
fieldType.getMapValueType())));
+        Map<Object, Object> kvMap = new HashMap<>();
+        ((Map<Object, Object>) value)
+            .entrySet().stream()
+                .forEach(
+                    (entry) ->
+                        kvMap.put(
+                            parseField(entry.getKey(), 
fieldType.getMapKeyType()),
+                            parseField(entry.getValue(), 
fieldType.getMapValueType())));
+        return kvMap;

Review comment:
       This change is necessary because `ImmutableMap` (as well as 
`Collectors.toMap`) does not allow null values, so it errors on the new test 
cases.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to