flink-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Lee (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLINK-8544) JSONKeyValueDeserializationSchema throws NPE when message key is null
Date Thu, 01 Feb 2018 13:38:00 GMT
Bill Lee created FLINK-8544:

             Summary: JSONKeyValueDeserializationSchema throws NPE when message key is null
                 Key: FLINK-8544
                 URL: https://issues.apache.org/jira/browse/FLINK-8544
             Project: Flink
          Issue Type: Bug
          Components: Kafka Connector
    Affects Versions: 1.4.0
            Reporter: Bill Lee

JSONKeyValueDeserializationSchema call Jaskon to deserialize the message key without validation.
 If a message with key == null is read, flink throws an NPE.
	public ObjectNode deserialize(byte[] messageKey, byte[] message, String topic, int partition,
long offset) throws IOException {
		if (mapper == null) {
			mapper = new ObjectMapper();
		ObjectNode node = mapper.createObjectNode();
		node.set("key", mapper.readValue(messageKey, JsonNode.class)); // messageKey is not validate
against null.
		node.set("value", mapper.readValue(message, JsonNode.class));

The fix is very straightforward.
		if (messageKey == null) {
			node.set("key", null)
		} else {
			node.set("key", mapper.readValue(messageKey, JsonNode.class));
If it is appreciated, I would send a pull request.

This message was sent by Atlassian JIRA

View raw message