From 5e75bd4a9776dd6566ae938c72ac97957135733c Mon Sep 17 00:00:00 2001 From: Andrew Stone Date: Fri, 8 Jun 2012 16:49:31 -0400 Subject: [PATCH] Fix for bug 950 -- NPE Compiler.java:407 -- also searched for any other instances & found two other cases of the same bug --- app/src/processing/app/debug/Compiler.java | 8 ++------ app/src/processing/app/debug/MessageSiphon.java | 11 +++++++++-- app/src/processing/app/debug/Sizer.java | 6 ++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 235ed30c7..9660ca721 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -401,12 +401,8 @@ public class Compiler implements MessageConsumer { boolean compiling = true; while (compiling) { try { - Thread t = in.thread; - if (t != null) - t.join(); - t = err.thread; - if (t != null) - t.join(); + in.join(); + err.join(); result = process.waitFor(); //System.out.println("result is " + result); compiling = false; diff --git a/app/src/processing/app/debug/MessageSiphon.java b/app/src/processing/app/debug/MessageSiphon.java index 79a0920d5..12b1f993b 100644 --- a/app/src/processing/app/debug/MessageSiphon.java +++ b/app/src/processing/app/debug/MessageSiphon.java @@ -85,8 +85,15 @@ public class MessageSiphon implements Runnable { } } - + // Wait until the MessageSiphon thread is complete. + public void join() throws java.lang.InterruptedException { + // Grab a temp copy in case another thread nulls the "thread" + // member variable + Thread t = thread; + if (t != null) t.join(); + } + public Thread getThread() { return thread; -} + } } diff --git a/app/src/processing/app/debug/Sizer.java b/app/src/processing/app/debug/Sizer.java index d67728a3c..67ce2080c 100644 --- a/app/src/processing/app/debug/Sizer.java +++ b/app/src/processing/app/debug/Sizer.java @@ -63,10 +63,8 @@ public class Sizer implements MessageConsumer { while(running) { try { - if (in.thread != null) - in.thread.join(); - if (err.thread != null) - err.thread.join(); + in.join(); + err.join(); r = process.waitFor(); running = false; } catch (InterruptedException intExc) { }