From e33bc726ac4eba721bf1e57512029420b680476a Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 5 Jul 2020 16:53:27 +0200 Subject: [PATCH] Apply suggestions from code review (not everything) Co-authored-by: CyB3RC0nN0R --- src/main/java/envoy/server/Startup.java | 11 +---------- src/main/java/envoy/server/data/GroupMessage.java | 7 +------ .../processors/GroupMessageStatusChangeProcessor.java | 5 +++-- .../server/processors/LoginCredentialProcessor.java | 11 +++-------- .../envoy/server/processors/MessageProcessor.java | 2 +- .../processors/MessageStatusChangeProcessor.java | 2 +- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/main/java/envoy/server/Startup.java b/src/main/java/envoy/server/Startup.java index 0edcfed..5128d15 100755 --- a/src/main/java/envoy/server/Startup.java +++ b/src/main/java/envoy/server/Startup.java @@ -14,16 +14,7 @@ import envoy.server.data.PersistenceManager; import envoy.server.net.ConnectionManager; import envoy.server.net.ObjectMessageProcessor; import envoy.server.net.ObjectMessageReader; -import envoy.server.processors.ContactOperationProcessor; -import envoy.server.processors.ContactSearchProcessor; -import envoy.server.processors.GroupCreationProcessor; -import envoy.server.processors.GroupMessageProcessor; -import envoy.server.processors.GroupMessageStatusChangeProcessor; -import envoy.server.processors.IDGeneratorRequestProcessor; -import envoy.server.processors.LoginCredentialProcessor; -import envoy.server.processors.MessageProcessor; -import envoy.server.processors.MessageStatusChangeProcessor; -import envoy.server.processors.UserStatusChangeProcessor; +import envoy.server.processors.*; import envoy.util.EnvoyLog; /** diff --git a/src/main/java/envoy/server/data/GroupMessage.java b/src/main/java/envoy/server/data/GroupMessage.java index 28965ec..3dfe94a 100644 --- a/src/main/java/envoy/server/data/GroupMessage.java +++ b/src/main/java/envoy/server/data/GroupMessage.java @@ -4,12 +4,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.NamedQuery; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import javax.persistence.*; import envoy.data.Group; diff --git a/src/main/java/envoy/server/processors/GroupMessageStatusChangeProcessor.java b/src/main/java/envoy/server/processors/GroupMessageStatusChangeProcessor.java index 1dc37eb..20a25f7 100644 --- a/src/main/java/envoy/server/processors/GroupMessageStatusChangeProcessor.java +++ b/src/main/java/envoy/server/processors/GroupMessageStatusChangeProcessor.java @@ -21,8 +21,9 @@ import envoy.server.net.ObjectWriteProxy; */ public class GroupMessageStatusChangeProcessor implements ObjectProcessor { - private final PersistenceManager persistenceManager = PersistenceManager.getInstance(); - private final ConnectionManager connectionManager = ConnectionManager.getInstance(); + private static final PersistenceManager persistenceManager = PersistenceManager.getInstance(); + private static final ConnectionManager connectionManager = ConnectionManager.getInstance(); + @Override public void process(GroupMessageStatusChange input, long socketID, ObjectWriteProxy writeProxy) throws IOException { diff --git a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java index fc43207..f54498b 100755 --- a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java +++ b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java @@ -1,10 +1,7 @@ package envoy.server.processors; import static envoy.data.User.UserStatus.ONLINE; -import static envoy.event.HandshakeRejection.INTERNAL_ERROR; -import static envoy.event.HandshakeRejection.USERNAME_TAKEN; -import static envoy.event.HandshakeRejection.WRONG_PASSWORD_OR_USER; -import static envoy.event.HandshakeRejection.WRONG_VERSION; +import static envoy.event.HandshakeRejection.*; import java.io.IOException; import java.time.LocalDateTime; @@ -122,7 +119,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor m instanceof GroupMessage); + pendingMessages.removeIf(GroupMessage.class::isInstance); logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "..."); List pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user); @@ -161,9 +158,7 @@ public final class LoginCredentialProcessor implements ObjectProcessor { 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.getClass().equals(envoy.data.GroupMessage.class)) { + if (message instanceof envoy.data.GroupMessage)) { return; } message.nextStatus(); diff --git a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java index f4e2312..0d57be0 100755 --- a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java +++ b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java @@ -26,7 +26,7 @@ public class MessageStatusChangeProcessor implements ObjectProcessor