Balzanka / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

ExecutionList is not threadsafe #1324

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(Guava 14.0)

ExecutionList.execute() polls it "runnables" instance field without 
synchronizing on it. Since this is a java.util.LinkedList which is not 
thread-safe, then ExecutionList is not thread-safe.

Non-safety could occur if :
- a thread A is executing ExecutionList.execute(), regularly polling the 
LinkedList without synchronizing access on it.
- another thread B executes ExecutionList.add(...), which adds an element to 
the LinkedList after synchronizing on it.

Original issue reported on code.google.com by sylvain....@gmail.com on 7 Mar 2013 at 9:46

GoogleCodeExporter commented 9 years ago
I think that the old ExecutionList was OK: add() won't add to the list unless 
|executed| is false, and execute() won't read from the list unless |executed| 
is true:
https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/com
mon/util/concurrent/ExecutionList.java?name=v14.0

We rely on similar guarantees in the rewrite of ExecutionList, which will 
appear in Guava 15:
https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/com
mon/util/concurrent/ExecutionList.java

If the |executed| checks aren't enough to reassure you, let me know. We had a 
discussion about this internally during the rewrite, but it's hard to be 
certain that we got it right.

Original comment by cpov...@google.com on 7 Mar 2013 at 10:47

GoogleCodeExporter commented 9 years ago
You're right, sorry for the incorrect issue, please close it.

Original comment by sylvain....@gmail.com on 9 Mar 2013 at 10:14

GoogleCodeExporter commented 9 years ago

Original comment by cpov...@google.com on 10 Mar 2013 at 1:20

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08