From 32f65a506e86c0fb9505635f56d6412d334da912 Mon Sep 17 00:00:00 2001 From: Haarolean Date: Sun, 25 Mar 2018 19:47:35 +0300 Subject: [PATCH] https://github.com/rmichela/Bukkit-SSHD/issues/6 fix --- .../java/com/ryanmichela/sshd/FlushyOutputStream.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java b/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java index 1aea21e..b79a5f8 100644 --- a/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java +++ b/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java @@ -8,6 +8,7 @@ import java.io.OutputStream; */ public class FlushyOutputStream extends OutputStream { private OutputStream base; + private boolean isClosed = false; public FlushyOutputStream(OutputStream base) { this.base = base; @@ -15,19 +16,27 @@ public class FlushyOutputStream extends OutputStream { @Override public void write(int b) throws IOException { + if(isClosed) return; base.write(b); base.flush(); } @Override public void write(byte[] b) throws IOException { + if(isClosed) return; base.write(b); base.flush(); } @Override public void write(byte[] b, int off, int len) throws IOException { + if(isClosed) return; base.write(b, off, len); base.flush(); } + + @Override + public void close() { + isClosed = true; + } }