Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,22 @@ protected void notifyListeners() {
* @param future the future to pass on to the listeners.
*/
protected void notifyListeners(final Future<?> future) {
final List<GenericCompletionListener<? extends Future<T>>> copy =
new ArrayList<GenericCompletionListener<? extends Future<T>>>();
final List<GenericCompletionListener<? extends Future<T>>> copy;
synchronized(this) {
copy.addAll(listeners);
if (listeners.isEmpty()) {
copy = null;
}
else {
copy = new ArrayList<GenericCompletionListener
<? extends Future<T>>>(listeners);
}
listeners = new ArrayList<GenericCompletionListener<? extends Future<T>>>();
}
for (GenericCompletionListener<? extends Future<? super T>> listener
: copy) {
notifyListener(executor(), future, listener);
if (copy != null) {
for (GenericCompletionListener<? extends Future<? super T>> listener
: copy) {
notifyListener(executor(), future, listener);
}
}
}

Expand Down