diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index 780aea86fc53c69a25f096b0ac1947fc2adca324..00feea7f4aeaa99abb3c3f60b113a4ef8f372b9b 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -197,12 +197,17 @@ public final class TcpSlaveAgentListener extends Thread { out.println("Welcome"); - OutputStream log = computer.openLogFile(); + final OutputStream log = computer.openLogFile(); new PrintWriter(log).println("JNLP agent connected from "+ this.s.getInetAddress()); computer.setChannel(new BufferedInputStream(this.s.getInputStream()), new BufferedOutputStream(this.s.getOutputStream()), log, new Listener() { public void onClosed(Channel channel, IOException cause) { + try { + log.close(); + } catch (IOException e) { + e.printStackTrace(); + } if(cause!=null) LOGGER.log(Level.WARNING, "Connection #"+id+" terminated",cause); try {