From 6d096beb3f275e9850a6df0e4a3e12aaae0a7bd2 Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Sun, 21 May 2023 01:11:07 +0100 Subject: [PATCH] Switch out exception with warning in Javadoc. --- .../captainalm/lib/calmnet/marshal/NetMarshalClient.java | 8 ++------ .../captainalm/lib/calmnet/marshal/NetMarshalServer.java | 6 ++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java b/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java index 8827fde..d6d42f9 100644 --- a/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java +++ b/src/com/captainalm/lib/calmnet/marshal/NetMarshalClient.java @@ -409,11 +409,9 @@ public class NetMarshalClient implements Closeable { * @throws IOException A stream exception has occurred. * @throws PacketException An exception has occurred. * @throws NullPointerException packetIn is null. - * @throws IllegalStateException sendPacket accessed in the receive thread. */ public final void sendPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { if (packetIn == null) throw new NullPointerException("packetIn is null"); - if (Thread.currentThread() == receiveThread) throw new IllegalStateException("sendPacket accessed in the receive thread"); synchronized (slocksock) { if (fragmentationOptions == null || directSend) { loader.writePacket(outputStream, packetIn, true); @@ -428,10 +426,8 @@ public class NetMarshalClient implements Closeable { * Flushes the output streams. * * @throws IOException A stream exception has occurred. - * @throws IllegalStateException flush accessed in the receive thread. */ public final void flush() throws IOException { - if (Thread.currentThread() == receiveThread) throw new IllegalStateException("sendPacket accessed in the receive thread"); synchronized (slocksock) { outputStream.flush(); rootOutputStream.flush(); @@ -558,7 +554,7 @@ public class NetMarshalClient implements Closeable { /** * Gets the {@link BiConsumer} receiver consumer. - * WARNING: {@link #sendPacket(IPacket, boolean)} and {@link #flush()} cannot be called within the consumer. + * WARNING: Calling {@link #sendPacket(IPacket, boolean)} or {@link #flush()} could cause full buffer hangs. * * @return The receiver consumer or null. */ @@ -568,7 +564,7 @@ public class NetMarshalClient implements Closeable { /** * Sets the {@link BiConsumer} receiver consumer. - * WARNING: {@link #sendPacket(IPacket, boolean)} and {@link #flush()} cannot be called within the consumer. + * WARNING: Calling {@link #sendPacket(IPacket, boolean)} or {@link #flush()} could cause full buffer hangs. * * @param consumer The new receiver consumer. * @throws NullPointerException consumer is null. diff --git a/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java b/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java index 5d01821..d2f5d21 100644 --- a/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java +++ b/src/com/captainalm/lib/calmnet/marshal/NetMarshalServer.java @@ -194,7 +194,6 @@ public class NetMarshalServer implements Closeable { * @throws IOException A stream exception has occurred. * @throws PacketException An exception has occurred. * @throws NullPointerException packetIn is null. - * @throws IllegalStateException sendPacket accessed in the receive thread. */ public final void broadcastPacket(IPacket packetIn, boolean directSend) throws IOException, PacketException { if (packetIn == null) throw new NullPointerException("packetIn is null"); @@ -208,7 +207,6 @@ public class NetMarshalServer implements Closeable { * Flushes all the output streams on all the clients. * * @throws IOException A stream exception has occurred. - * @throws IllegalStateException flush accessed in the receive thread. */ public final void flush() throws IOException { synchronized (slocksock) { @@ -228,7 +226,7 @@ public class NetMarshalServer implements Closeable { /** * Gets the {@link BiConsumer} receiver consumer. - * WARNING: {@link #broadcastPacket(IPacket, boolean)} and {@link #flush()} cannot be called within the consumer. + * WARNING: Calling {@link #broadcastPacket(IPacket, boolean)} or {@link #flush()} could cause full buffer hangs. * * @return The receiver consumer or null. */ @@ -238,7 +236,7 @@ public class NetMarshalServer implements Closeable { /** * Sets the {@link BiConsumer} receiver consumer. - * WARNING: {@link #broadcastPacket(IPacket, boolean)} and {@link #flush()} cannot be called within the consumer. + * WARNING: Calling {@link #broadcastPacket(IPacket, boolean)} or {@link #flush()} could cause full buffer hangs. * * @param consumer The new receiver consumer. * @throws NullPointerException consumer is null.