use of org.codehaus.jackson.map.DeserializationConfig in project helix by apache.
the class JacksonPayloadSerializer method deserialize.
@Override
public <T> T deserialize(final Class<T> clazz, final byte[] bytes) {
if (bytes == null || bytes.length == 0) {
return null;
}
ObjectMapper mapper = new ObjectMapper();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
try {
T payload = mapper.readValue(bais, clazz);
return payload;
} catch (Exception e) {
logger.error("Exception during deserialization of payload bytes: " + new String(bytes), e);
return null;
}
}
Aggregations