From e673c4e2422e634844fab1fec53b0a544298d16d Mon Sep 17 00:00:00 2001 From: delvh Date: Tue, 18 Feb 2020 16:28:32 +0100 Subject: [PATCH] Added null check to ObjectMessageProcessor --- src/main/java/envoy/server/net/ObjectMessageProcessor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/envoy/server/net/ObjectMessageProcessor.java b/src/main/java/envoy/server/net/ObjectMessageProcessor.java index 226fb69..346e253 100644 --- a/src/main/java/envoy/server/net/ObjectMessageProcessor.java +++ b/src/main/java/envoy/server/net/ObjectMessageProcessor.java @@ -38,7 +38,12 @@ public class ObjectMessageProcessor implements IMessageProcessor { public void process(Message message, WriteProxy writeProxy) { try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(message.sharedArray, message.offset + 4, message.length - 4))) { Object obj = in.readObject(); - System.out.println("Read object: " + obj.toString()); + if (obj == null) { + System.out.println("received a null object"); + return; + } + + System.out.println("Read object: " + obj); // Process object processors.stream().filter(p -> p.getInputClass().isInstance(obj)).forEach((@SuppressWarnings("rawtypes") ObjectProcessor p) -> {