From 7022585850e6d087085dc9ba6669ba69bf1243da Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Wed, 7 Feb 2024 19:31:54 +0100 Subject: [PATCH] Check for null value before closing toServerWriter --- src/main/java/ChatClient.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index f14ddd0..eb8fd84 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -77,8 +77,10 @@ public class ChatClient extends JFrame implements KeyListener { } } - toServerWriter.close(); - + if(null != toServerWriter) { + toServerWriter.close(); + } + } }