From 958c835ef04811b3c4e8127458d31f013df2f6ed Mon Sep 17 00:00:00 2001 From: Andrew Stone Date: Wed, 6 Jun 2012 17:30:14 -0400 Subject: [PATCH 1/2] Issue 950: NPE Compiler.java:407 --- app/src/processing/app/debug/Compiler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java index 6d469e276da..235ed30c700 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -401,10 +401,12 @@ private void execAsynchronously(List commandList) throws RunnerException { boolean compiling = true; while (compiling) { try { - if (in.thread != null) - in.thread.join(); - if (err.thread != null) - err.thread.join(); + Thread t = in.thread; + if (t != null) + t.join(); + t = err.thread; + if (t != null) + t.join(); result = process.waitFor(); //System.out.println("result is " + result); compiling = false; From 5e75bd4a9776dd6566ae938c72ac97957135733c Mon Sep 17 00:00:00 2001 From: Andrew Stone Date: Fri, 8 Jun 2012 16:49:31 -0400 Subject: [PATCH 2/2] 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 235ed30c700..9660ca721fe 100644 --- a/app/src/processing/app/debug/Compiler.java +++ b/app/src/processing/app/debug/Compiler.java @@ -401,12 +401,8 @@ private void execAsynchronously(List commandList) throws RunnerException { 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 79a0920d53a..12b1f993b77 100644 --- a/app/src/processing/app/debug/MessageSiphon.java +++ b/app/src/processing/app/debug/MessageSiphon.java @@ -85,8 +85,15 @@ public void run() { } } - + // 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 d67728a3c85..67ce2080ca7 100644 --- a/app/src/processing/app/debug/Sizer.java +++ b/app/src/processing/app/debug/Sizer.java @@ -63,10 +63,8 @@ public long computeSize() throws RunnerException { 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) { }