Program: 74059
Project: 74059
Buggy source:
/** 
 * React to a change in an attribute.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == classesToRemove) {
    RemoveGraphicalClasses removeGraphicalClassesFilter=null;
    List momlFilters=MoMLParser.getMoMLFilters();
    Iterator filters=momlFilters.iterator();
    while (filters.hasNext()) {
      MoMLFilter filter=(MoMLFilter)filters.next();
      if (filter instanceof RemoveGraphicalClasses) {
        removeGraphicalClassesFilter=(RemoveGraphicalClasses)filter;
        break;
      }
    }
    ArrayToken classesToRemoveToken=(ArrayToken)classesToRemove.getToken();
    if (removeGraphicalClassesFilter == null) {
      removeGraphicalClassesFilter=new RemoveGraphicalClasses();
      removeGraphicalClassesFilter.clear();
      momlFilters.add(removeGraphicalClassesFilter);
    }
    for (int i=0; i < classesToRemoveToken.length(); i++) {
      String classNameToRemove=((StringToken)classesToRemoveToken.getElement(i)).stringValue();
      removeGraphicalClassesFilter.put(classNameToRemove,null);
    }
    MoMLParser.setMoMLFilters(momlFilters);
  }
 else   if (attribute == removeGraphicalClasses) {
    RemoveGraphicalClasses removeGraphicalClassesFilter=null;
    List momlFilters=MoMLParser.getMoMLFilters();
    Iterator filters=momlFilters.iterator();
    while (filters.hasNext()) {
      MoMLFilter filter=(MoMLFilter)filters.next();
      if (filter instanceof RemoveGraphicalClasses) {
        removeGraphicalClassesFilter=(RemoveGraphicalClasses)filter;
        break;
      }
    }
    ArrayToken classesToRemoveToken=(ArrayToken)classesToRemove.getToken();
    if (removeGraphicalClassesFilter == null) {
      removeGraphicalClassesFilter=new RemoveGraphicalClasses();
      momlFilters.add(removeGraphicalClassesFilter);
    }
  }
  super.attributeChanged(attribute);
}

Fixed version (ground truth):
/** 
 * React to a change in an attribute.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the change is not acceptableto this container (not thrown in this base class).
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == classesToRemove) {
    RemoveGraphicalClasses removeGraphicalClassesFilter=null;
    List momlFilters=MoMLParser.getMoMLFilters();
    Iterator filters=momlFilters.iterator();
    while (filters.hasNext()) {
      MoMLFilter filter=(MoMLFilter)filters.next();
      if (filter instanceof RemoveGraphicalClasses) {
        removeGraphicalClassesFilter=(RemoveGraphicalClasses)filter;
        break;
      }
    }
    ArrayToken classesToRemoveToken=(ArrayToken)classesToRemove.getToken();
    if (removeGraphicalClassesFilter == null) {
      removeGraphicalClassesFilter=new RemoveGraphicalClasses();
      momlFilters.add(removeGraphicalClassesFilter);
    }
    for (int i=0; i < classesToRemoveToken.length(); i++) {
      String classNameToRemove=((StringToken)classesToRemoveToken.getElement(i)).stringValue();
      removeGraphicalClassesFilter.put(classNameToRemove,null);
    }
    MoMLParser.setMoMLFilters(momlFilters);
  }
 else   if (attribute == removeGraphicalClasses) {
    RemoveGraphicalClasses removeGraphicalClassesFilter=null;
    List momlFilters=MoMLParser.getMoMLFilters();
    Iterator filters=momlFilters.iterator();
    while (filters.hasNext()) {
      MoMLFilter filter=(MoMLFilter)filters.next();
      if (filter instanceof RemoveGraphicalClasses) {
        removeGraphicalClassesFilter=(RemoveGraphicalClasses)filter;
        break;
      }
    }
    ArrayToken classesToRemoveToken=(ArrayToken)classesToRemove.getToken();
    if (removeGraphicalClassesFilter == null) {
      removeGraphicalClassesFilter=new RemoveGraphicalClasses();
      momlFilters.add(removeGraphicalClassesFilter);
    }
  }
  super.attributeChanged(attribute);
}