Skip to content

Commit 6d6f442

Browse files
committed
Merge pull request #96 from gandrewstone/master
Avoid null pointer exception during compilation (race condition). http://code.google.com/p/arduino/issues/detail?id=950
2 parents a363686 + 5e75bd4 commit 6d6f442

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

app/src/processing/app/debug/Compiler.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ private void execAsynchronously(List commandList) throws RunnerException {
401401
boolean compiling = true;
402402
while (compiling) {
403403
try {
404-
if (in.thread != null)
405-
in.thread.join();
406-
if (err.thread != null)
407-
err.thread.join();
404+
in.join();
405+
err.join();
408406
result = process.waitFor();
409407
//System.out.println("result is " + result);
410408
compiling = false;

app/src/processing/app/debug/MessageSiphon.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,15 @@ public void run() {
8585
}
8686
}
8787

88-
88+
// Wait until the MessageSiphon thread is complete.
89+
public void join() throws java.lang.InterruptedException {
90+
// Grab a temp copy in case another thread nulls the "thread"
91+
// member variable
92+
Thread t = thread;
93+
if (t != null) t.join();
94+
}
95+
8996
public Thread getThread() {
9097
return thread;
91-
}
98+
}
9299
}

app/src/processing/app/debug/Sizer.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ public long computeSize() throws RunnerException {
6363

6464
while(running) {
6565
try {
66-
if (in.thread != null)
67-
in.thread.join();
68-
if (err.thread != null)
69-
err.thread.join();
66+
in.join();
67+
err.join();
7068
r = process.waitFor();
7169
running = false;
7270
} catch (InterruptedException intExc) { }

0 commit comments

Comments
 (0)