From 64626610cab8ac85ea64a28c1abb13913e15771c Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Wed, 7 Feb 2024 19:30:27 +0100 Subject: [PATCH] Avoid closing fromServerReader in case of null --- src/main/java/ChatClient.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 851ef84..f14ddd0 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -69,10 +69,12 @@ public class ChatClient extends JFrame implements KeyListener { } } - try { - fromServerReader.close(); - } catch (IOException e) { - e.printStackTrace(); + if (null != fromServerReader) { + try { + fromServerReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } } toServerWriter.close();