From af765ee1f7c2b36ecb87814739d26eb20b0c8286 Mon Sep 17 00:00:00 2001 From: kske Date: Mon, 6 Jul 2020 12:34:13 +0200 Subject: [PATCH] Filter out subclasses in ObjectMessageProcessor --- .../envoy/server/net/ObjectMessageProcessor.java | 5 +++-- .../server/processors/LoginCredentialProcessor.java | 13 +++++++------ .../envoy/server/processors/MessageProcessor.java | 4 ---- .../processors/MessageStatusChangeProcessor.java | 3 --- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/envoy/server/net/ObjectMessageProcessor.java b/src/main/java/envoy/server/net/ObjectMessageProcessor.java index 8fb120d..ec8488a 100755 --- a/src/main/java/envoy/server/net/ObjectMessageProcessor.java +++ b/src/main/java/envoy/server/net/ObjectMessageProcessor.java @@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; import com.jenkov.nioserver.IMessageProcessor; @@ -50,11 +51,11 @@ public class ObjectMessageProcessor implements IMessageProcessor { logger.fine("Received " + obj); // Process object - processors.stream().filter(p -> p.getInputClass().isInstance(obj)).forEach((@SuppressWarnings("rawtypes") ObjectProcessor p) -> { + processors.stream().filter(p -> p.getInputClass().equals(obj.getClass())).forEach((@SuppressWarnings("rawtypes") ObjectProcessor p) -> { try { p.process(p.getInputClass().cast(obj), message.socketId, new ObjectWriteProxy(writeProxy)); } catch (IOException e) { - e.printStackTrace(); + logger.log(Level.SEVERE, "Exception during processor execution: ", e); } }); } catch (IOException | ClassNotFoundException e) { diff --git a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java index 418a30c..9f20800 100755 --- a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java +++ b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java @@ -1,5 +1,6 @@ package envoy.server.processors; +import static envoy.data.Message.MessageStatus.*; import static envoy.data.User.UserStatus.ONLINE; import static envoy.event.HandshakeRejection.*; @@ -10,7 +11,6 @@ import java.util.logging.Logger; import javax.persistence.NoResultException; import envoy.data.LoginCredentials; -import envoy.data.Message.MessageStatus; import envoy.event.GroupMessageStatusChange; import envoy.event.HandshakeRejection; import envoy.event.MessageStatusChange; @@ -120,7 +120,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor { @Override public void process(Message message, long socketID, ObjectWriteProxy writeProxy) { - // Makes sure, that there are no groupMessages processed here, because - // groupMessage is a subclass of message. - if (message instanceof envoy.data.GroupMessage) return; - message.nextStatus(); // Convert to server message diff --git a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java index 354e9f8..1c76f77 100755 --- a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java +++ b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java @@ -5,7 +5,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import envoy.data.Message.MessageStatus; -import envoy.event.GroupMessageStatusChange; import envoy.event.MessageStatusChange; import envoy.server.data.PersistenceManager; import envoy.server.net.ConnectionManager; @@ -28,8 +27,6 @@ public class MessageStatusChangeProcessor implements ObjectProcessor