Fixed - NPE in CommandPubSubDecoder. #1838

pull/1856/head
Nikita Koksharov 6 years ago
parent cd49e38f48
commit 4e1331fde8

@ -152,7 +152,7 @@ public class CommandPubSubDecoder extends CommandDecoder {
pubSubConnection.onMessage((PubSubStatusMessage) result); pubSubConnection.onMessage((PubSubStatusMessage) result);
} else if (result instanceof PubSubMessage) { } else if (result instanceof PubSubMessage) {
pubSubConnection.onMessage((PubSubMessage) result); pubSubConnection.onMessage((PubSubMessage) result);
} else { } else if (result instanceof PubSubPatternMessage) {
pubSubConnection.onMessage((PubSubPatternMessage) result); pubSubConnection.onMessage((PubSubPatternMessage) result);
} }
} }
@ -182,7 +182,7 @@ public class CommandPubSubDecoder extends CommandDecoder {
pubSubConnection.onMessage((PubSubStatusMessage) result); pubSubConnection.onMessage((PubSubStatusMessage) result);
} else if (result instanceof PubSubMessage) { } else if (result instanceof PubSubMessage) {
pubSubConnection.onMessage((PubSubMessage) result); pubSubConnection.onMessage((PubSubMessage) result);
} else { } else if (result instanceof PubSubPatternMessage) {
pubSubConnection.onMessage((PubSubPatternMessage) result); pubSubConnection.onMessage((PubSubPatternMessage) result);
} }
} else { } else {
@ -242,11 +242,11 @@ public class CommandPubSubDecoder extends CommandDecoder {
if (parts.size() == 2 && "message".equals(parts.get(0))) { if (parts.size() == 2 && "message".equals(parts.get(0))) {
byte[] channelName = (byte[]) parts.get(1); byte[] channelName = (byte[]) parts.get(1);
return entries.get(new ChannelName(channelName)).getDecoder().getDecoder(parts.size(), state()); return getDecoder(parts, channelName);
} }
if (parts.size() == 3 && "pmessage".equals(parts.get(0))) { if (parts.size() == 3 && "pmessage".equals(parts.get(0))) {
byte[] patternName = (byte[]) parts.get(1); byte[] patternName = (byte[]) parts.get(1);
return entries.get(new ChannelName(patternName)).getDecoder().getDecoder(parts.size(), state()); return getDecoder(parts, patternName);
} }
} }
@ -257,4 +257,12 @@ public class CommandPubSubDecoder extends CommandDecoder {
return super.selectDecoder(data, parts); return super.selectDecoder(data, parts);
} }
private Decoder<Object> getDecoder(List<Object> parts, byte[] name) {
PubSubEntry entry = entries.get(new ChannelName(name));
if (entry != null) {
return entry.getDecoder().getDecoder(parts.size(), state());
}
return ByteArrayCodec.INSTANCE.getValueDecoder();
}
} }

Loading…
Cancel
Save