Emmanuel Lecharny created DIRMINA-994:
-----------------------------------------

             Summary: The ConnectionRequest.cancel() method is inconsistent wrt 
concurrent access
                 Key: DIRMINA-994
                 URL: https://issues.apache.org/jira/browse/DIRMINA-994
             Project: MINA
          Issue Type: Bug
    Affects Versions: 2.0.9
            Reporter: Emmanuel Lecharny
            Priority: Critical
             Fix For: 2.0.10


When we call the ConnectionRequest.cancel() method, it does :

{code}
        public void cancel() {
            if (!isDone()) {
                super.cancel();
                cancelQueue.add(this);
                startupWorker();
                wakeup();
            }
{code}

The problem is that the isDone() method is  :

{code}
    public boolean isDone() {
        synchronized (lock) {
            return ready;
        }
    }
{code}

and the super.cancel() method is :

{code}
    public void cancel() {
        setValue(CANCELED);
    }
{code}

with the setValue() method :

{code}
    public void setValue(Object newValue) {
        synchronized (lock) {
            // Allowed only once.
            if (ready) {
                return;
            }

            result = newValue;
            ready = true;
            ...
{code}

At this point, we may have the 'ready' flag set to false, enter into the 
super.cancel() method, and have the 'ready' flag set to true when we check it 
again, but still we will add the current connectRequest into the cancel queue, 
when we should not.  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to