Program: 2510
Project: 2510
Buggy source:
/** 
 * This method returns the innermost block that encloses all of the activities associated with the supplied role.
 * @param protocol The protocol
 * @param role The role
 * @return The block
 */
public static Block getEnclosingBlock(final Protocol protocol,final Role role){
  Block ret=null;
  final java.util.List<Block> blocks=new java.util.Vector<Block>();
  protocol.visit(new DefaultVisitor(){
    public boolean start(    Protocol elem){
      if (protocol.getParameterDefinition(role.getName()) != null) {
        blocks.add(elem.getBlock());
      }
      return (protocol == elem);
    }
    public void accept(    org.scribble.protocol.model.Interaction elem){
      if (role.equals(elem.getFromRole()) || elem.getToRoles().contains(role) || ((elem.getFromRole() == null || elem.getToRoles().size() == 0) && role.equals(elem.enclosingProtocol().getRole()))) {
        blocks.add((Block)elem.getParent());
      }
    }
    public boolean start(    Choice elem){
      if (role.equals(elem.getRole())) {
        blocks.add((Block)elem.getParent());
      }
      return (true);
    }
    public boolean start(    DirectedChoice elem){
      if (role.equals(elem.getFromRole()) || elem.getToRoles().contains(role)) {
        blocks.add((Block)elem.getParent());
      }
      return (true);
    }
  }
);
  if (blocks.size() == 0) {
  }
 else   if (blocks.size() == 1) {
    ret=blocks.get(0);
  }
 else {
    java.util.List<java.util.List<Block>> listOfBlocks=new java.util.Vector<java.util.List<Block>>();
    for (    Block block : blocks) {
      java.util.List<Block> lb=getBlockPath(block);
      if (lb != null && lb.size() > 0) {
        listOfBlocks.add(lb);
      }
    }
    int pos=-1;
    java.util.List<Block> refblocks=listOfBlocks.get(0);
    for (int j=0; j < refblocks.size(); j++) {
      boolean f_same=true;
      Block ref=refblocks.get(j);
      for (int i=1; f_same && i < listOfBlocks.size(); i++) {
        java.util.List<Block> lb=listOfBlocks.get(i);
        if (lb.size() <= j || ref != lb.get(j)) {
          f_same=false;
        }
      }
      if (f_same) {
        pos=j;
      }
    }
    if (pos != -1) {
      ret=refblocks.get(pos);
    }
  }
  return (ret);
}

Fixed version (ground truth):
/** 
 * This method returns the innermost block that encloses all of the activities associated with the supplied role.
 * @param protocol The protocol
 * @param role The role
 * @return The block
 */
public static Block getEnclosingBlock(final Protocol protocol,final Role role){
  Block ret=null;
  final java.util.List<Block> blocks=new java.util.Vector<Block>();
  protocol.visit(new DefaultVisitor(){
    public boolean start(    Protocol elem){
      if (protocol.getParameterDefinition(role.getName()) != null) {
        blocks.add(elem.getBlock());
      }
      return (protocol == elem);
    }
    public void accept(    org.scribble.protocol.model.Interaction elem){
      if (role.equals(elem.getFromRole()) || elem.getToRoles().contains(role) || ((elem.getFromRole() == null || elem.getToRoles().size() == 0) && role.equals(elem.enclosingProtocol().getRole()))) {
        blocks.add((Block)elem.getParent());
      }
    }
    public boolean start(    Choice elem){
      if (role.equals(elem.getRole())) {
        blocks.add((Block)elem.getParent());
      }
      return (true);
    }
    public boolean start(    DirectedChoice elem){
      if (role.equals(elem.getFromRole()) || elem.getToRoles().contains(role) || ((elem.getFromRole() == null || elem.getToRoles().size() == 0) && role.equals(elem.enclosingProtocol().getRole()))) {
        blocks.add((Block)elem.getParent());
      }
      return (true);
    }
  }
);
  if (blocks.size() == 0) {
  }
 else   if (blocks.size() == 1) {
    ret=blocks.get(0);
  }
 else {
    java.util.List<java.util.List<Block>> listOfBlocks=new java.util.Vector<java.util.List<Block>>();
    for (    Block block : blocks) {
      java.util.List<Block> lb=getBlockPath(block);
      if (lb != null && lb.size() > 0) {
        listOfBlocks.add(lb);
      }
    }
    int pos=-1;
    java.util.List<Block> refblocks=listOfBlocks.get(0);
    for (int j=0; j < refblocks.size(); j++) {
      boolean f_same=true;
      Block ref=refblocks.get(j);
      for (int i=1; f_same && i < listOfBlocks.size(); i++) {
        java.util.List<Block> lb=listOfBlocks.get(i);
        if (lb.size() <= j || ref != lb.get(j)) {
          f_same=false;
        }
      }
      if (f_same) {
        pos=j;
      }
    }
    if (pos != -1) {
      ret=refblocks.get(pos);
    }
  }
  return (ret);
}