From a010949ef28b5b743db31150be2bd724b785a8f4 Mon Sep 17 00:00:00 2001 From: Chinmay Pendharkar Date: Thu, 3 Oct 2024 14:59:33 +0800 Subject: [PATCH] fix(websocket): cleanup some warnings --- .../org/arl/fjage/connectors/WebSocketConnector.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/arl/fjage/connectors/WebSocketConnector.java b/src/main/java/org/arl/fjage/connectors/WebSocketConnector.java index 3572e1d8..ff40e08b 100644 --- a/src/main/java/org/arl/fjage/connectors/WebSocketConnector.java +++ b/src/main/java/org/arl/fjage/connectors/WebSocketConnector.java @@ -35,7 +35,7 @@ public class WebSocketConnector implements Connector, WebSocketCreator { protected ContextHandler handler; protected List wsHandlers = new CopyOnWriteArrayList(); protected OutputThread outThread = null; - protected PseudoInputStream pin = new PseudoInputStream(); + protected final PseudoInputStream pin = new PseudoInputStream(); protected PseudoOutputStream pout = new PseudoOutputStream(); protected ConnectionListener listener = null; protected Logger log = Logger.getLogger(getClass().getName()); @@ -143,8 +143,6 @@ public void close() { handler = null; pin.close(); pout.close(); - pin = null; - pout = null; } @Override @@ -197,9 +195,9 @@ void close() { } - // servlets to manage web socket connections + // POJO for each web socket connection - @WebSocket(maxIdleTime = Integer.MAX_VALUE) + @WebSocket(maxIdleTime = Integer.MAX_VALUE, batchMode = BatchMode.OFF) public class WSHandler { Session session = null; @@ -232,12 +230,12 @@ public void onError(Throwable t) { @OnWebSocketMessage public void onMessage(String message) { byte[] buf = message.getBytes(); - synchronized (pin) { + synchronized (conn.pin) { for (int c : buf) { if (c < 0) c += 256; if (c == 4) continue; // ignore ^D try { - pin.write(c); + conn.pin.write(c); } catch (IOException ex) { // do nothing }