Fix AsyncEvent callback triggering.
Before this, two concurrent postCall() and completeIntent() calls might cause the callback to be called more than once.
This commit is contained in:
parent
70564d9f44
commit
9cf57ca929
@ -33,11 +33,11 @@ public class AsyncEvent<T> extends Event
|
||||
@SuppressWarnings("unchecked")
|
||||
public void postCall()
|
||||
{
|
||||
fired.set( true );
|
||||
if ( latch.get() == 0 )
|
||||
{
|
||||
done.done( (T) this, null );
|
||||
}
|
||||
fired.set( true );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,9 +67,14 @@ public class AsyncEvent<T> extends Event
|
||||
{
|
||||
Preconditions.checkState( intents.contains( plugin ), "Plugin %s has not registered intent for event %s", plugin, this );
|
||||
intents.remove( plugin );
|
||||
if ( latch.decrementAndGet() == 0 && fired.get() )
|
||||
if ( fired.get() )
|
||||
{
|
||||
done.done( (T) this, null );
|
||||
if ( latch.decrementAndGet() == 0 )
|
||||
{
|
||||
done.done( (T) this, null );
|
||||
}
|
||||
} else {
|
||||
latch.decrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user