From 3464a33678f3873231f7e3d4dd2408461170abcf Mon Sep 17 00:00:00 2001 From: Paldiu Date: Fri, 8 Jan 2021 00:25:46 -0600 Subject: [PATCH] NPE on Thread.join() possible fix This bug is hard to decipher mainly due to the thread being terminated somewhere before the thread.join is called. this may be due to the safeClose method defined with serverSocket, but again, I'm not too sure what's up here. This may also be because something failed to execute in one of the try catch statements, causing the thread to never be initialized in the first place. --- .../java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java b/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java index 702c20d6..b661a982 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java @@ -251,7 +251,8 @@ public abstract class NanoHTTPD try { safeClose(myServerSocket); - myThread.join(); + //This should prevent a null pointer :) + if (myThread != null) myThread.join(); } catch (Exception e) {