From 4dba9ebf9499fbd23b0a81cb611be7b20c9a6d29 Mon Sep 17 00:00:00 2001 From: Luis Uguina Date: Tue, 7 Jul 2020 23:38:23 +1000 Subject: [PATCH] Fix: NullPointerException triggered when http error in job allocation (#274) --- src/com/sheepit/client/Server.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/sheepit/client/Server.java b/src/com/sheepit/client/Server.java index 43b0603..48ce607 100644 --- a/src/com/sheepit/client/Server.java +++ b/src/com/sheepit/client/Server.java @@ -475,11 +475,16 @@ public class Server extends Thread { } finally { try { - output.flush(); - output.close(); - is.close(); + if (output != null) { + output.flush(); + output.close(); + } + + if (is != null) { + is.close(); + } } - catch (IOException e) { + catch (Exception e) { this.log.debug(String.format("Server::HTTPGetFile Error trying to close the open streams (%s)", e.getMessage())); } }