A possible duplicate event emission in DefaultIoFuture
------------------------------------------------------
Key: DIRMINA-384
URL: https://issues.apache.org/jira/browse/DIRMINA-384
Project: MINA
Issue Type: Bug
Components: Core
Affects Versions: 1.1.0
Reporter: Trustin Lee
Assignee: Trustin Lee
Fix For: 1.1.1
I was reviewing DefaultIoFuture implementation in 1.1 which used CountDownLatch
and AtomicBoolean, and found a possible bug.
Current implementation:
protected void setValue( Object newValue )
{
if( ready.compareAndSet( false, true ) )
{
result = newValue;
completionLatch.countDown();
notifyListeners();
}
}
public void addListener( IoFutureListener listener )
{
if( listener == null )
{
throw new NullPointerException( "listener" );
}
listeners.add( listener );
if( ready.get() )
{
listener.operationComplete( this );
}
}
A counter example:
1) A user calls the future's addListener().
2) addListener() adds the specified listener to the 'listeners'.
3) MINA calls the future's setValue(); all listeners including what has just
added are notified.
4) ready.get() returns true, so listener.operationComplete() is invoked once
again causing duplicate events.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.