[ https://issues.apache.org/jira/browse/SAMZA-933?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15231688#comment-15231688 ]
Navina Ramesh commented on SAMZA-933: ------------------------------------- [~Yuanchi] I think the Line 96 in SamzaObjectMapper was added as a part of the Coordinator Stream change. If I understand it right, the JsonSerde was modified to use SamzaObjectMapper when [~criccomini] registered custom serializers for the JobModel object. The line to disable AUTO_DETECT_GETTERS was part of SAMZA-465. I am not entirely sure about the rationale behind this change. [~naveenatceg] Did you have any strong reasoning for disabling this feature in SamzaObjectMapper? With AUTO_DETECT_GETTERS disabled, I think you cannot use the JsonSerde to serialize any object type. For example, in your test case, HashMap fails to serialize because the Jackson decoder does not have visibility on private inner class "Node" of HashMap. I don't believe this issue has surfaced at LinkedIn because we don't use Json data at LinkedIn. I think it is a reasonable change to make and I do believe having better test coverage would have caught this :) Thanks! > SamzaObjectMapper used in JsonSerde has disabled the auto_detect_getters > ------------------------------------------------------------------------ > > Key: SAMZA-933 > URL: https://issues.apache.org/jira/browse/SAMZA-933 > Project: Samza > Issue Type: Bug > Components: container > Affects Versions: 0.10.0 > Reporter: Yuanchi Ning > Assignee: Yuanchi Ning > Fix For: 0.10.1 > > > Find there is a bug in the new version JsonSerde file in Samza 0.10.0, it > replaced the codehaus ObjectMapper with SamzaObjectMapper and in the > SamzaObjectMapper there is one line: > {quote} > mapper.configure(SerializationConfig.Feature.AUTO_DETECT_GETTERS, false); > {quote} > In the code comment we can see: > {quote} > /** > * Feature that determines whether regualr "getter" methods are > * automatically detected based on standard Bean naming convention > * or not. If yes, then all public zero-argument methods that > * start with prefix "get" > * are considered as getters. > * If disabled, only methods explicitly annotated are considered getters. > *<p> > * Note that since version 1.3, this does <b>NOT</b> include > * "is getters" (see {@link #AUTO_DETECT_IS_GETTERS} for details) > *<p> > * Note that this feature has lower precedence than per-class > * annotations, and is only used if there isn't more granular > * configuration available. > *<P> > * Feature is enabled by default. > */ > AUTO_DETECT_GETTERS(true), > {quote} > Which causes the Serde fail to serialize the HashMap entry object in > hello-athena example. > To verify that, I wrote a simple code to test it out: > {quote} > package com.uber.athena; > import java.util.HashMap; > import java.util.Map; > import org.apache.samza.serializers.JsonSerde; > public class SerializationHMEntry { > public static void main(String[] args) { > JsonSerde jsonSerde = new JsonSerde(); > Map<String, Long> dummyHashMap = new HashMap<>(); > dummyHashMap.put("key1", 1L); > for (Map.Entry<String, Long> entry : dummyHashMap.entrySet()) { > byte[] bytes = jsonSerde.toBytes(entry); > System.out.println(bytes.toString()); > } > } > } > {quote} > The output exception is as below: > {quote} > Exception in thread "main" org.apache.samza.SamzaException: > org.codehaus.jackson.map.JsonMappingException: No serializer found for class > java.util.HashMap$Node and no properties discovered to create BeanSerializer > (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) > ) > at org.apache.samza.serializers.JsonSerde.toBytes(JsonSerde.scala:36) > at > com.uber.athena.SerializationHMEntry.main(SerializationHMEntry.java:16) > Caused by: org.codehaus.jackson.map.JsonMappingException: No serializer found > for class java.util.HashMap$Node and no properties discovered to create > BeanSerializer (to avoid exception, disable > SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) > at > org.codehaus.jackson.map.ser.StdSerializerProvider$1.failForEmpty(StdSerializerProvider.java:89) > at > org.codehaus.jackson.map.ser.StdSerializerProvider$1.serialize(StdSerializerProvider.java:62) > at > org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:600) > at > org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:280) > at > org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:2260) > at > org.codehaus.jackson.map.ObjectMapper.writeValueAsString(ObjectMapper.java:1829) > at org.apache.samza.serializers.JsonSerde.toBytes(JsonSerde.scala:33) > ... 1 more > {quote} > And if commented out that line in the Samza 0.10.0 SamzaObjectMapper file and > rebuild Samza as the dependency, the sample code works fine. -- This message was sent by Atlassian JIRA (v6.3.4#6332)