You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by "Navina Ramesh (JIRA)" <ji...@apache.org> on 2016/04/07 21:15:25 UTC
[jira] [Updated] (SAMZA-933) SamzaObjectMapper used in JsonSerde
has disabled the auto_detect_getters
[ https://issues.apache.org/jira/browse/SAMZA-933?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Navina Ramesh updated SAMZA-933:
--------------------------------
Fix Version/s: 0.10.1
> 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
> 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)