From 688beae1d62be26e93a6186a1dcf485dcdb69b55 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 21 Oct 2020 14:10:59 +0100 Subject: [PATCH] wrap closing of compressed streams in try-catch --- .../muwire/core/connection/ConnectionAcceptor.groovy | 12 +++++++++--- .../com/muwire/core/search/ResultsSender.groovy | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy index 288593dc..66d3b6f5 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy @@ -399,7 +399,9 @@ class ConnectionAcceptor { dos.write(json.getBytes(StandardCharsets.US_ASCII)) } dos.flush() - dos.close() + try { + dos.close() + } catch (Exception ignored) {} } finally { e.close() } @@ -522,7 +524,9 @@ class ConnectionAcceptor { dos.writeShort(payload.length) dos.write(payload) } - dos.close() + try { + dos.close() + } catch (Exception ignored) {} } finally { e.close() } @@ -584,7 +588,9 @@ class ConnectionAcceptor { dos.write(json.getBytes(StandardCharsets.US_ASCII)) } dos.flush() - dos.close() + try { + dos.close() + } catch(Exception ignore) {} } finally { e.close() } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy index d9196890..b6c6438b 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy @@ -150,7 +150,9 @@ class ResultsSender { dos.writeShort((short)json.length()) dos.write(json.getBytes(StandardCharsets.US_ASCII)) } - dos.close() + try { + dos.close() + } catch (Exception ignore) {} } finally { endpoint?.close() }