From 1a93ceffb3510c7000ed46ed9ba211f4db70f0ae Mon Sep 17 00:00:00 2001 From: JanHolger Date: Wed, 1 Dec 2021 16:46:48 +0100 Subject: Added proper handling of SocketException's --- src/main/java/com/lumaserv/bgp/BGPSession.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lumaserv/bgp/BGPSession.java b/src/main/java/com/lumaserv/bgp/BGPSession.java index 1d40f9d..669010b 100644 --- a/src/main/java/com/lumaserv/bgp/BGPSession.java +++ b/src/main/java/com/lumaserv/bgp/BGPSession.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; +import java.net.SocketException; public class BGPSession implements Runnable { @@ -50,8 +51,14 @@ public class BGPSession implements Runnable { public void run() { try { - while (!closed) - handle(BGPPacket.read(inputStream)); + while (!closed) { + try { + handle(BGPPacket.read(inputStream)); + } catch (SocketException ignored) { + closed = true; + configuration.getListener().onClose(this); + } + } } catch (IOException ex) { ex.printStackTrace(); } -- cgit v1.2.3