diff --git a/src/debug/org/luaj/debug/net/j2me/ClientConnectionTask.java b/src/debug/org/luaj/debug/net/j2me/ClientConnectionTask.java index ad266c27..e50a6847 100644 --- a/src/debug/org/luaj/debug/net/j2me/ClientConnectionTask.java +++ b/src/debug/org/luaj/debug/net/j2me/ClientConnectionTask.java @@ -93,12 +93,14 @@ public class ClientConnectionTask implements Runnable, DebugEventListener { debugSupport.disconnect(1); } finally { - try { - redirectOutputStream.close(); - } catch (IOException ignore) {} - - // restore the print output - BaseLib.restoreStandardOutput(); + if (redirectOutputStream != null) { + try { + redirectOutputStream.close(); + } catch (IOException ignore) {} + + // restore the print output + BaseLib.restoreStandardOutput(); + } dispose(); }