From 1949c848b870167f58084956c871939f52ba6fdc Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Sat, 20 May 2023 20:02:35 +0100 Subject: [PATCH] Fix up method synchronisation. --- .../lib/calmnet/marshal/NetMarshalClient.java | 12 ++++++------ .../lib/calmnet/marshal/NetMarshalServer.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java b/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java index 7bc7dea..edff1dd 100644 --- a/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java +++ b/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java @@ -319,7 +319,7 @@ public class NetMarshalClient implements Closeable { * Clears the fragment storage registries if fragmentation is enabled. * WARNING: Use of this method is not recommended. */ - public synchronized final void clearFragmentStorage() { + public final void clearFragmentStorage() { if (fragmentationOptions == null) return; fragmentReceiver.clearRegistry(); fragmentSender.clearRegistry(); @@ -366,7 +366,7 @@ public class NetMarshalClient implements Closeable { * * @return If the marshal is running. */ - public synchronized final boolean isRunning() { + public final boolean isRunning() { return running; } @@ -384,7 +384,7 @@ public class NetMarshalClient implements Closeable { * * @return Is the marshal ssl upgraded. */ - public synchronized final boolean isSSLUpgraded() { + public final boolean isSSLUpgraded() { if (!running) return false; return socket instanceof SSLSocket; } @@ -398,7 +398,7 @@ public class NetMarshalClient implements Closeable { * @throws PacketException An exception has occurred. * @throws NullPointerException packetIn is null. */ - public synchronized final void sendPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { + public final void sendPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { if (packetIn == null) throw new NullPointerException("packetIn is null"); synchronized (slocksock) { if (fragmentationOptions == null || directSend) { @@ -415,7 +415,7 @@ public class NetMarshalClient implements Closeable { * * @throws IOException A stream exception has occurred. */ - public synchronized final void flush() throws IOException { + public final void flush() throws IOException { synchronized (slocksock) { outputStream.flush(); rootOutputStream.flush(); @@ -514,7 +514,7 @@ public class NetMarshalClient implements Closeable { sslUpgrade(context, remoteHostName); } - protected synchronized final void sslUpgrade(SSLContext context, String remoteHostName) throws SSLUtilityException, IOException { + protected final void sslUpgrade(SSLContext context, String remoteHostName) throws SSLUtilityException, IOException { if (!running || socket == null || socket instanceof SSLSocket) return; if (context == null) throw new NullPointerException("context is null"); if (!disablePacketReading && Thread.currentThread() != receiveThread) throw new IllegalStateException("sslUpgrade methods should be called in a BiConsumer (for setReceiveBiConsumer) within the target NetMarshalClient" + diff --git a/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java b/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java index 9f636b6..02aea3a 100644 --- a/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java +++ b/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java @@ -162,7 +162,7 @@ public class NetMarshalServer implements Closeable { * * @return If the marshal is running. */ - public synchronized final boolean isRunning() { + public final boolean isRunning() { return running; } @@ -180,7 +180,7 @@ public class NetMarshalServer implements Closeable { * * @return An array of connected clients. */ - public synchronized final NetMarshalClient[] getConnectedClients() { + public final NetMarshalClient[] getConnectedClients() { synchronized (slocksock) { return clients.toArray(new NetMarshalClient[0]); } @@ -195,7 +195,7 @@ public class NetMarshalServer implements Closeable { * @throws PacketException An exception has occurred. * @throws NullPointerException packetIn is null. */ - public synchronized final void broadcastPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { + public final void broadcastPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { if (packetIn == null) throw new NullPointerException("packetIn is null"); synchronized (slocksock) { for (NetMarshalClient c : clients) @@ -208,7 +208,7 @@ public class NetMarshalServer implements Closeable { * * @throws IOException A stream exception has occurred. */ - public synchronized final void flush() throws IOException { + public final void flush() throws IOException { synchronized (slocksock) { for (NetMarshalClient c : clients) if (c.isRunning()) c.flush(); @@ -220,7 +220,7 @@ public class NetMarshalServer implements Closeable { * * @throws IOException An I/O Exception has occurred. */ - public synchronized final void disconnectAll() throws IOException { + public final void disconnectAll() throws IOException { disconnectAllInternal(); } @@ -396,7 +396,7 @@ public class NetMarshalServer implements Closeable { * @return A NetMarshalClient instance or null for non-accepted connection. * @throws IOException A connection error has occurred. */ - public synchronized final NetMarshalClient connect(InetAddress remoteAddress, int remotePort, int timeout) throws IOException { + public final NetMarshalClient connect(InetAddress remoteAddress, int remotePort, int timeout) throws IOException { if (remoteAddress == null) throw new NullPointerException("remoteAddress is null"); if (remotePort < 0) throw new IllegalArgumentException("remotePort is less than 0"); if (remotePort > 65535) throw new IllegalArgumentException("remotePort is greater than 65535");