/*
 * ################################################################
 *
 * ProActive: The Java(TM) library for Parallel, Distributed,
 *            Concurrent computing with Security and Mobility
 *
 * Copyright (C) 1997-2005 INRIA/University of Nice-Sophia Antipolis
 * Contact: proactive@objectweb.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 *  Initial developer(s):               The ProActive Team
 *                        http://www.inria.fr/oasis/ProActive/contacts.html
 *  Contributor(s):
 *
 * ################################################################
 */
package org.objectweb.proactive.core.exceptions.proxy;

import java.util.Iterator;

import org.objectweb.proactive.core.exceptions.NonFunctionalException;
import org.objectweb.proactive.core.exceptions.manager.NFEListener;
import org.objectweb.proactive.core.group.ExceptionInGroup;
import org.objectweb.proactive.core.group.ExceptionListException;
import org.objectweb.proactive.core.group.ProxyForGroup;


class AutomaticPurgeGroup implements NFEListener {
    public boolean handleNFE(NonFunctionalException nfe) {
        Iterator exceptions;
        ProxyForGroup group;

        try {
            FailedGroupRendezVousException fgrve = (FailedGroupRendezVousException) nfe;
            ExceptionListException list = (ExceptionListException) fgrve.getCause();
            exceptions = list.iterator();
            group = fgrve.getGroup();
        } catch (ClassCastException cce) {
            return false;
        }

        while (exceptions.hasNext()) {
            ExceptionInGroup eig = (ExceptionInGroup) exceptions.next();
            group.remove(eig.getObject());
        }

        return true;
    }
}


public class FailedGroupRendezVousException extends ProxyNonFunctionalException {
    public static final AutomaticPurgeGroup AUTO_GROUP_PURGE = new AutomaticPurgeGroup();
    private ProxyForGroup group;

    public FailedGroupRendezVousException(String message,
        ExceptionListException e, ProxyForGroup group) {
        super(message, e);
        this.group = group;
    }

    public ProxyForGroup getGroup() {
        return group;
    }
}

@@ -1827,24 +1827,70 @@
 Group group;
+%0A        ExceptionListException exceptionList;
 %0A%0A        tr
@@ -1994,38 +1994,25 @@
         
-ExceptionListE
+e
 xception
  list = 
@@ -2003,18 +2003,17 @@
 xception
- l
+L
 ist = (E
@@ -2057,50 +2057,8 @@
 ();%0A
-            exceptions = list.iterator();%0A
     
@@ -2163,32 +2163,127 @@
 lse;%0A        %7D%0A%0A
+        synchronized (exceptionList) %7B%0A            exceptions = exceptionList.iterator();%0A%0A    
         while (e
@@ -2309,32 +2309,36 @@
 ) %7B%0A            
+ 
+   
 ExceptionInGroup
@@ -2390,24 +2390,28 @@
             
+    
 group.remove
@@ -2429,16 +2429,30 @@
 ect());%0A
+            %7D%0A
         

Synchronize the list access