From 53e623ec261a6e0f0eec75beb5d9bb31b8303eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=A0panger?= Date: Sat, 11 Nov 2023 12:17:48 +0100 Subject: [PATCH] suppress more irrelevant errors --- .../java/globalquake/client/ClientSocket.java | 17 ++++++++++++----- .../main/java/gqserver/server/DataService.java | 6 ++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/GlobalQuakeClient/src/main/java/globalquake/client/ClientSocket.java b/GlobalQuakeClient/src/main/java/globalquake/client/ClientSocket.java index 4da4b12cf..2128713ea 100644 --- a/GlobalQuakeClient/src/main/java/globalquake/client/ClientSocket.java +++ b/GlobalQuakeClient/src/main/java/globalquake/client/ClientSocket.java @@ -17,10 +17,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.net.ConnectException; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketTimeoutException; +import java.net.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -104,6 +101,9 @@ private void checkReconnect() { private void sendQuakeRequest() { try { sendPacket(new EarthquakesRequestPacket()); + } catch(SocketTimeoutException | SocketException e){ + Logger.trace(e); + onClose(); } catch (IOException e) { Logger.error(e); onClose(); @@ -113,6 +113,9 @@ private void sendQuakeRequest() { private void sendHeartbeat() { try { sendPacket(new HeartbeatPacket()); + } catch(SocketTimeoutException | SocketException e){ + Logger.trace(e); + onClose(); } catch (IOException e) { Logger.error(e); onClose(); @@ -124,8 +127,12 @@ private void onClose() { if(socket != null){ try { socket.close(); + } catch(SocketTimeoutException | SocketException e){ + Logger.trace(e); + onClose(); } catch (IOException e) { Logger.error(e); + onClose(); } } @@ -144,7 +151,7 @@ private void runReader() { Packet packet = (Packet) inputStream.readObject(); ((GlobalQuakeClient) GlobalQuakeClient.instance).processPacket(this, packet); } - } catch(SocketTimeoutException se){ + } catch(SocketTimeoutException | SocketException se){ Logger.trace(se); }catch (Exception e){ Logger.error(e); diff --git a/GlobalQuakeServer/src/main/java/gqserver/server/DataService.java b/GlobalQuakeServer/src/main/java/gqserver/server/DataService.java index 47ecdeed1..1554282ca 100644 --- a/GlobalQuakeServer/src/main/java/gqserver/server/DataService.java +++ b/GlobalQuakeServer/src/main/java/gqserver/server/DataService.java @@ -91,7 +91,7 @@ private void sendIntensityData() { if (!data.isEmpty()) { broadcast(getStationReceivingClients(), new StationsIntensityPacket(GlobalQuake.instance.getStationManager().getIndexing(), System.currentTimeMillis(), data)); } - }catch(Exception e){ + } catch(Exception e){ Logger.error(e); } } @@ -256,7 +256,9 @@ private void broadcast(List clients, Packet packet) { clients.forEach(client -> { try { client.sendPacket(packet); - } catch (IOException e) { + } catch(SocketException | SocketTimeoutException e){ + Logger.trace(e); + }catch (IOException e) { Logger.trace(e); } });