nus-yam/ex-repair huggingface dataset:
Program: 2367
Project: 2367
Buggy source:
protected void addAsyncDiscardMethod(){
  GProtocolName gpn=this.apigen.getGProtocolName();
  IOAction first=this.curr.getAcceptable().iterator().next();
  MethodBuilder mb=this.ib.newAbstractMethod();
  ReceiveSocketGenerator.setAsyncDiscardHeaderWithoutReturnType(this.apigen,first,mb,InputFutureGenerator.getInputFutureName(this.apigen.getSocketClassName(this.curr)));
  this.ib.addImports(SessionApiGenerator.getOpsPackageName(gpn) + "String_Node_Str");
  EndpointState succ=this.curr.accept(first);
  if (succ.isTerminal()) {
    ScribSocketGenerator.setNextSocketReturnType(this.apigen,mb,succ);
  }
 else {
    mb.setReturn("String_Node_Str");
  }
}

Fixed version (ground truth):
protected void addAsyncDiscardMethod(){
  GProtocolName gpn=this.apigen.getGProtocolName();
  IOAction first=this.curr.getTakeable().iterator().next();
  MethodBuilder mb=this.ib.newAbstractMethod();
  ReceiveSocketGenerator.setAsyncDiscardHeaderWithoutReturnType(this.apigen,first,mb,InputFutureGenerator.getInputFutureName(this.apigen.getSocketClassName(this.curr)));
  this.ib.addImports(SessionApiGenerator.getOpsPackageName(gpn) + "String_Node_Str");
  EndpointState succ=this.curr.take(first);
  if (succ.isTerminal()) {
    ScribSocketGenerator.setNextSocketReturnType(this.apigen,mb,succ);
  }
 else {
    mb.setReturn("String_Node_Str");
  }
}
Program: 2368
Project: 2368
Buggy source:
public boolean isSafeTermination(){
  for (  Role r : this.states.keySet()) {
    EndpointState s=this.states.get(r);
    if ((s.isTerminal() && !this.buffs.isEmpty(r)) || (!s.isTerminal() && (!(s.getStateKind().equals(Kind.UNARY_INPUT) && s.getAcceptable().iterator().next().isAccept()) || this.states.keySet().stream().anyMatch((rr) -> !r.equals(rr) && this.buffs.isConnected(r,rr))))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean isSafeTermination(){
  for (  Role r : this.states.keySet()) {
    if (!canSafelyTerminate(r)) {
      return false;
    }
  }
  return true;
}
Program: 2369
Project: 2369
Buggy source:
private static Set<Send> checkMessageLiveness(WFState init,Set<WFState> termset) throws ScribbleException {
  Set<Send> res=new HashSet<>();
  Set<Role> roles=termset.iterator().next().config.states.keySet();
  Iterator<WFState> i=termset.iterator();
  Set<Send> seen=new HashSet<>();
  while (i.hasNext()) {
    WFState s=i.next();
    Set<Send> ms=roles.stream().flatMap((r) -> s.config.buffs.get(r).values().stream().filter((v) -> v != null)).collect(Collectors.toSet());
    for (    Send m : ms) {
      if (!seen.contains(m)) {
        res.add(m);
      }
    }
    for (    Send m : new HashSet<>(res)) {
      if (!ms.contains(m)) {
        seen.add(m);
        res.remove(m);
      }
    }
  }
  return res;
}

Fixed version (ground truth):
private static Map<Role,Set<Send>> checkMessageLiveness(WFState init,Set<WFState> termset) throws ScribbleException {
  Set<Role> roles=termset.iterator().next().config.states.keySet();
  Iterator<WFState> i=termset.iterator();
  Map<Role,Map<Role,Send>> b0=i.next().config.buffs.getBuffers();
  while (i.hasNext()) {
    WFState s=i.next();
    WFBuffers b=s.config.buffs;
    for (    Role r1 : roles) {
      for (      Role r2 : roles) {
        Send s0=b0.get(r1).get(r2);
        if (s0 != null) {
          Send tmp=b.get(r1).get(r2);
          if (tmp == null) {
            b0.get(r1).put(r2,null);
          }
        }
      }
    }
  }
  Map<Role,Set<Send>> res=new HashMap<>();
  for (  Role r1 : roles) {
    for (    Role r2 : roles) {
      Send m=b0.get(r1).get(r2);
      if (m != null) {
        Set<Send> tmp=res.get(r2);
        if (tmp == null) {
          tmp=new HashSet<>();
          res.put(r2,tmp);
        }
        tmp.add(m);
      }
    }
  }
  return res;
}
Program: 2370
Project: 2370
Buggy source:
private static void checkTerminalSet(WFState init,Set<WFState> termset,Set<Role> safety,Set<Role> liveness) throws ScribbleException {
  Iterator<WFState> i=termset.iterator();
  WFState s=i.next();
  Map<Role,EndpointState> ss=new HashMap<>(s.config.states);
  while (i.hasNext()) {
    WFState next=i.next();
    Map<Role,EndpointState> tmp=next.config.states;
    for (    Role r : tmp.keySet()) {
      if (ss.get(r) != null) {
{
          for (          GIOAction a : next.getActions()) {
            if (a.containsRole(r)) {
              ss.put(r,null);
              break;
            }
          }
        }
      }
    }
  }
  for (  Role r : ss.keySet()) {
    EndpointState tmp=ss.get(r);
    if (tmp != null) {
      if (!tmp.isTerminal()) {
        if (s.config.buffs.get(r).values().stream().allMatch((v) -> v == null)) {
          liveness.add(r);
        }
      }
    }
  }
}

Fixed version (ground truth):
private static void checkTerminalSet(WFState init,Set<WFState> termset,Set<Role> safety,Set<Role> liveness) throws ScribbleException {
  Iterator<WFState> i=termset.iterator();
  WFState s=i.next();
  Map<Role,WFState> ss=new HashMap<>();
  s.config.states.keySet().forEach((r) -> ss.put(r,s));
  while (i.hasNext()) {
    WFState next=i.next();
    Map<Role,EndpointState> tmp=next.config.states;
    for (    Role r : tmp.keySet()) {
      if (ss.get(r) != null) {
{
          for (          GIOAction a : next.getActions()) {
            if (a.containsRole(r)) {
              ss.put(r,null);
              break;
            }
          }
        }
      }
    }
  }
  for (  Role r : ss.keySet()) {
    WFState foo=ss.get(r);
    if (foo != null) {
      EndpointState tmp=foo.config.states.get(r);
      if (tmp != null) {
        if (!foo.config.canSafelyTerminate(r)) {
          if (s.config.buffs.get(r).values().stream().allMatch((v) -> v == null)) {
            liveness.add(r);
          }
        }
      }
    }
  }
}
Program: 2372
Project: 2372
Buggy source:
@Override public LContinue leaveEndpointGraphBuilding(ScribNode parent,ScribNode child,EndpointGraphBuilder graph,ScribNode visited) throws ScribbleException {
  LContinue lr=(LContinue)visited;
  RecVar rv=lr.recvar.toName();
  if (graph.builder.isUnguardedInChoice()) {
    graph.builder.addContinueEdge(graph.builder.getEntry(),rv);
  }
 else {
    Iterator<EndpointState> preds=graph.builder.getPredecessors().iterator();
    Iterator<IOAction> prevs=graph.builder.getPreviousActions().iterator();
    EndpointState entry=graph.builder.getEntry();
    while (preds.hasNext()) {
      EndpointState pred=preds.next();
      IOAction prev=prevs.next();
      graph.builder.removeEdge(pred,prev,entry);
      graph.builder.addEdge(pred,prev,graph.builder.getRecursionEntry(rv));
    }
  }
  return (LContinue)super.leaveEndpointGraphBuilding(parent,child,graph,lr);
}

Fixed version (ground truth):
@Override public LContinue leaveEndpointGraphBuilding(ScribNode parent,ScribNode child,EndpointGraphBuilder graph,ScribNode visited) throws ScribbleException {
  LContinue lr=(LContinue)visited;
  RecVar rv=lr.recvar.toName();
  if (graph.builder.isUnguardedInChoice()) {
    graph.builder.addContinueEdge(graph.builder.getEntry(),rv);
  }
 else {
    Iterator<EndpointState> preds=graph.builder.getPredecessors().iterator();
    Iterator<IOAction> prevs=graph.builder.getPreviousActions().iterator();
    EndpointState entry=graph.builder.getEntry();
    Set<List<Object>> removed=new HashSet<>();
    while (preds.hasNext()) {
      EndpointState pred=preds.next();
      IOAction prev=prevs.next();
      List<Object> tmp=Arrays.asList(pred,prev,entry);
      if (!removed.contains(tmp)) {
        removed.add(tmp);
        graph.builder.removeEdge(pred,prev,entry);
      }
      graph.builder.addEdge(pred,prev,graph.builder.getRecursionEntry(rv));
    }
  }
  return (LContinue)super.leaveEndpointGraphBuilding(parent,child,graph,lr);
}
Program: 2373
Project: 2373
Buggy source:
public Map<Role,Receive> getStuckMessages(){
  Map<Role,Receive> res=new HashMap<>();
  for (  Role r : this.states.keySet()) {
    EndpointState s=this.states.get(r);
    Kind k=s.getStateKind();
    if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
      Role peer=s.getAllTakeable().iterator().next().peer;
      Send send=this.buffs.get(r).get(peer);
      if (send != null) {
        Receive recv=send.toDual(peer);
        if (!s.isTakeable(recv))         res.put(r,recv);
      }
    }
  }
  return res;
}

Fixed version (ground truth):
public Map<Role,Receive> getStuckMessages(){
  Map<Role,Receive> res=new HashMap<>();
  for (  Role r : this.states.keySet()) {
    EndpointFSM s=this.states.get(r);
    Kind k=s.getStateKind();
    if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
      Role peer=s.getAllTakeable().iterator().next().peer;
      Send send=this.buffs.get(r).get(peer);
      if (send != null) {
        Receive recv=send.toDual(peer);
        if (!s.isTakeable(recv))         res.put(r,recv);
      }
    }
  }
  return res;
}
Program: 2375
Project: 2375
Buggy source:
public List<WFConfig> sync(Role r1,IOAction a1,Role r2,IOAction a2){
  List<WFConfig> res=new LinkedList<>();
  List<EndpointState> succs1=this.states.get(r1).takeAll(a1);
  List<EndpointState> succs2=this.states.get(r2).takeAll(a2);
  for (  EndpointState succ1 : succs1) {
    for (    EndpointState succ2 : succs2) {
      Map<Role,EndpointState> tmp1=new HashMap<>(this.states);
      tmp1.put(r1,succ1);
      tmp1.put(r2,succ2);
      WFBuffers tmp2;
      if (((a1.isConnect() && a2.isAccept()) || (a1.isAccept() && a2.isConnect()))) {
        tmp2=this.buffs.connect(r1,r2);
      }
 else {
        throw new RuntimeException("String_Node_Str" + a1 + "String_Node_Str"+ a2);
      }
      res.add(new WFConfig(tmp1,tmp2));
    }
  }
  return res;
}

Fixed version (ground truth):
public List<WFConfig> sync(Role r1,IOAction a1,Role r2,IOAction a2){
  List<WFConfig> res=new LinkedList<>();
  List<EndpointFSM> succs1=this.states.get(r1).takeAll(a1);
  List<EndpointFSM> succs2=this.states.get(r2).takeAll(a2);
  for (  EndpointFSM succ1 : succs1) {
    for (    EndpointFSM succ2 : succs2) {
      Map<Role,EndpointFSM> tmp1=new HashMap<>(this.states);
      tmp1.put(r1,succ1);
      tmp1.put(r2,succ2);
      WFBuffers tmp2;
      if (((a1.isConnect() && a2.isAccept()) || (a1.isAccept() && a2.isConnect()))) {
        tmp2=this.buffs.connect(r1,r2);
      }
 else {
        throw new RuntimeException("String_Node_Str" + a1 + "String_Node_Str"+ a2);
      }
      res.add(new WFConfig(tmp1,tmp2));
    }
  }
  return res;
}
Program: 2376
Project: 2376
Buggy source:
public Map<Role,Set<Send>> getOrphanMessages(){
  Map<Role,Set<Send>> res=new HashMap<>();
  for (  Role r : this.states.keySet()) {
    EndpointState s=this.states.get(r);
    if (s.isTerminal()) {
      Set<Send> orphs=this.buffs.get(r).values().stream().filter((v) -> v != null).collect(Collectors.toSet());
      if (!orphs.isEmpty()) {
        Set<Send> tmp=res.get(r);
        if (tmp == null) {
          tmp=new HashSet<>();
          res.put(r,tmp);
        }
        tmp.addAll(orphs);
      }
    }
 else {
      this.states.keySet().forEach((rr) -> {
        if (!rr.equals(r)) {
          if (!this.buffs.isConnected(r,rr)) {
            Send send=this.buffs.get(r).get(rr);
            if (send != null) {
              Set<Send> tmp=res.get(r);
              if (tmp == null) {
                tmp=new HashSet<>();
                res.put(r,tmp);
              }
              tmp.add(send);
            }
          }
        }
      }
);
    }
  }
  return res;
}

Fixed version (ground truth):
public Map<Role,Set<Send>> getOrphanMessages(){
  Map<Role,Set<Send>> res=new HashMap<>();
  for (  Role r : this.states.keySet()) {
    EndpointFSM s=this.states.get(r);
    if (s.isTerminal()) {
      Set<Send> orphs=this.buffs.get(r).values().stream().filter((v) -> v != null).collect(Collectors.toSet());
      if (!orphs.isEmpty()) {
        Set<Send> tmp=res.get(r);
        if (tmp == null) {
          tmp=new HashSet<>();
          res.put(r,tmp);
        }
        tmp.addAll(orphs);
      }
    }
 else {
      this.states.keySet().forEach((rr) -> {
        if (!rr.equals(r)) {
          if (!this.buffs.isConnected(r,rr)) {
            Send send=this.buffs.get(r).get(rr);
            if (send != null) {
              Set<Send> tmp=res.get(r);
              if (tmp == null) {
                tmp=new HashSet<>();
                res.put(r,tmp);
              }
              tmp.add(send);
            }
          }
        }
      }
);
    }
  }
  return res;
}
Program: 2377
Project: 2377
Buggy source:
public WFConfig(Map<Role,EndpointState> state,WFBuffers buffs){
  this.states=Collections.unmodifiableMap(state);
  this.buffs=buffs;
}

Fixed version (ground truth):
public WFConfig(Map<Role,EndpointFSM> state,WFBuffers buffs){
  this.states=Collections.unmodifiableMap(state);
  this.buffs=buffs;
}
Program: 2378
Project: 2378
Buggy source:
public List<WFConfig> accept(Role r,IOAction a){
  List<WFConfig> res=new LinkedList<>();
  List<EndpointState> succs=this.states.get(r).takeAll(a);
  for (  EndpointState succ : succs) {
    Map<Role,EndpointState> tmp1=new HashMap<>(this.states);
    tmp1.put(r,succ);
    WFBuffers tmp2=a.isSend() ? this.buffs.send(r,(Send)a) : a.isReceive() ? this.buffs.receive(r,(Receive)a) : a.isDisconnect() ? this.buffs.disconnect(r,(Disconnect)a) : null;
    if (tmp2 == null) {
      throw new RuntimeException("String_Node_Str" + a);
    }
    res.add(new WFConfig(tmp1,tmp2));
  }
  return res;
}

Fixed version (ground truth):
public List<WFConfig> accept(Role r,IOAction a){
  List<WFConfig> res=new LinkedList<>();
  List<EndpointFSM> succs=this.states.get(r).takeAll(a);
  for (  EndpointFSM succ : succs) {
    Map<Role,EndpointFSM> tmp1=new HashMap<>(this.states);
    tmp1.put(r,succ);
    WFBuffers tmp2=a.isSend() ? this.buffs.send(r,(Send)a) : a.isReceive() ? this.buffs.receive(r,(Receive)a) : a.isDisconnect() ? this.buffs.disconnect(r,(Disconnect)a) : null;
    if (tmp2 == null) {
      throw new RuntimeException("String_Node_Str" + a);
    }
    res.add(new WFConfig(tmp1,tmp2));
  }
  return res;
}
Program: 2379
Project: 2379
Buggy source:
private Set<Role> isWaitingFor(Role r){
  EndpointState s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllTakeable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
 else   if (k == Kind.OUTPUT) {
    if (s.isConnectOnly()) {
      List<IOAction> all=s.getAllTakeable();
      return all.stream().map((x) -> x.peer).collect(Collectors.toSet());
    }
  }
  return null;
}

Fixed version (ground truth):
private Set<Role> isWaitingFor(Role r){
  EndpointFSM s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllTakeable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
 else   if (k == Kind.ACCEPT) {
    if (!s.isInitial()) {
      List<IOAction> all=s.getAllTakeable();
      Set<Role> rs=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (rs.stream().noneMatch((x) -> this.states.get(x).getAllTakeable().contains(new Connect(r)))) {
        return rs;
      }
    }
  }
 else   if (k == Kind.OUTPUT) {
    if (s.isConnectOnly()) {
      List<IOAction> all=s.getAllTakeable();
      Set<Role> rs=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (rs.stream().noneMatch((x) -> this.states.get(x).getAllTakeable().contains(new Accept(r)))) {
        return rs;
      }
    }
  }
  return null;
}
Program: 2380
Project: 2380
Buggy source:
public boolean canSafelyTerminate(Role r){
  EndpointState s=this.states.get(r);
  return !((s.isTerminal() && !this.buffs.isEmpty(r)) || (!s.isTerminal() && (!s.getStateKind().equals(Kind.ACCEPT) || this.states.keySet().stream().anyMatch((rr) -> !r.equals(rr) && this.buffs.isConnected(r,rr)))));
}

Fixed version (ground truth):
public boolean canSafelyTerminate(Role r){
  EndpointFSM s=this.states.get(r);
  return !((s.isTerminal() && !this.buffs.isEmpty(r)) || (!s.isTerminal() && (!(s.getStateKind().equals(Kind.ACCEPT) && s.isInitial()) || this.states.keySet().stream().anyMatch((rr) -> !r.equals(rr) && this.buffs.isConnected(r,rr)))));
}
Program: 2381
Project: 2381
Buggy source:
public WFStateErrors getErrors(){
  Map<Role,Receive> stuck=this.config.getStuckMessages();
  Set<Set<Role>> waitfor=this.config.getInputCycles();
  Map<Role,Set<Send>> orphs=this.config.getOrphanMessages();
  return new WFStateErrors(stuck,waitfor,orphs);
}

Fixed version (ground truth):
public WFStateErrors getErrors(){
  Map<Role,Receive> stuck=this.config.getStuckMessages();
  Set<Set<Role>> waitfor=this.config.getWaitForErrors();
  Map<Role,Set<Send>> orphs=this.config.getOrphanMessages();
  return new WFStateErrors(stuck,waitfor,orphs);
}
Program: 2382
Project: 2382
Buggy source:
public Kind getStateKind(){
  List<IOAction> as=this.getAllAcceptable();
  if (as.size() == 0) {
    return Kind.TERMINAL;
  }
 else {
    IOAction a=as.iterator().next();
    return (a.isSend() || a.isConnect() || a.isDisconnect()) ? Kind.OUTPUT : (as.size() > 1) ? Kind.POLY_INPUT : Kind.UNARY_INPUT;
  }
}

Fixed version (ground truth):
public Kind getStateKind(){
  List<IOAction> as=this.getAllAcceptable();
  if (as.size() == 0) {
    return Kind.TERMINAL;
  }
 else {
    IOAction a=as.iterator().next();
    return (a.isSend() || a.isDisconnect()) ? Kind.OUTPUT : (a.isConnect() || a.isAccept()) ? Kind.CONNECTION : (as.size() > 1) ? Kind.POLY_INPUT : Kind.UNARY_INPUT;
  }
}
Program: 2383
Project: 2383
Buggy source:
private Set<Role> isInputBlocked(Role r){
  EndpointState s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllAcceptable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private Set<Role> isInputBlocked(Role r){
  EndpointState s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllAcceptable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
 else   if (k == Kind.CONNECTION) {
    List<IOAction> all=s.getAllAcceptable();
    return all.stream().map((x) -> x.peer).collect(Collectors.toSet());
  }
  return null;
}
Program: 2385
Project: 2385
Buggy source:
public Kind getStateKind(){
  List<IOAction> as=this.getAllTakeable();
  if (as.size() == 0) {
    return Kind.TERMINAL;
  }
 else {
    IOAction a=as.iterator().next();
    return (a.isSend() || a.isDisconnect()) ? Kind.OUTPUT : (a.isConnect()) ? Kind.CONNECT : (a.isAccept()) ? Kind.ACCEPT : (as.size() > 1) ? Kind.POLY_INPUT : Kind.UNARY_INPUT;
  }
}

Fixed version (ground truth):
public Kind getStateKind(){
  List<IOAction> as=this.getAllTakeable();
  if (as.size() == 0) {
    return Kind.TERMINAL;
  }
 else {
    IOAction a=as.iterator().next();
    return (a.isSend() || a.isConnect() || a.isDisconnect()) ? Kind.OUTPUT : (a.isAccept()) ? Kind.ACCEPT : (as.size() > 1) ? Kind.POLY_INPUT : Kind.UNARY_INPUT;
  }
}
Program: 2387
Project: 2387
Buggy source:
private Set<Role> isInputBlocked(Role r){
  EndpointState s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllTakeable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
 else   if (k == Kind.CONNECT) {
    List<IOAction> all=s.getAllTakeable();
    return all.stream().map((x) -> x.peer).collect(Collectors.toSet());
  }
  return null;
}

Fixed version (ground truth):
private Set<Role> isInputBlocked(Role r){
  EndpointState s=this.states.get(r);
  Kind k=s.getStateKind();
  if (k == Kind.UNARY_INPUT || k == Kind.POLY_INPUT) {
    List<IOAction> all=s.getAllTakeable();
    IOAction a=all.get(0);
    if (a.isReceive()) {
      Set<Role> peers=all.stream().map((x) -> x.peer).collect(Collectors.toSet());
      if (peers.stream().noneMatch((p) -> this.buffs.get(r).get(p) != null)) {
        return peers;
      }
    }
  }
 else   if (k == Kind.OUTPUT) {
    if (s.isConnectOnly()) {
      List<IOAction> all=s.getAllTakeable();
      return all.stream().map((x) -> x.peer).collect(Collectors.toSet());
    }
  }
  return null;
}
Program: 2388
Project: 2388
Buggy source:
public Set<Role> isWaitForCycle(Role orig){
  Set<Role> candidate=new HashSet<>();
  Set<Role> todo=new HashSet<>(Arrays.asList(orig));
  while (!todo.isEmpty()) {
    Role r=todo.iterator().next();
    todo.remove(r);
    candidate.add(r);
    EndpointState s=this.states.get(r);
    if (s.getStateKind() == Kind.OUTPUT) {
      return null;
    }
    if (s.isTerminal()) {
      if (todo.isEmpty()) {
        return candidate;
      }
      continue;
    }
    Set<Role> blocked=isInputBlocked(r);
    if (blocked == null) {
      return null;
    }
    if (todo.isEmpty() && candidate.containsAll(blocked)) {
      return candidate;
    }
    blocked.forEach((x) -> {
      if (!candidate.contains(x)) {
        todo.add(x);
      }
    }
);
  }
  return null;
}

Fixed version (ground truth):
public Set<Role> isWaitForCycle(Role orig){
  Set<Role> candidate=new HashSet<>();
  Set<Role> todo=new HashSet<>(Arrays.asList(orig));
  while (!todo.isEmpty()) {
    Role r=todo.iterator().next();
    todo.remove(r);
    candidate.add(r);
    EndpointState s=this.states.get(r);
    if (s.getStateKind() == Kind.OUTPUT && !s.isConnectOnly()) {
      return null;
    }
    if (s.isTerminal()) {
      if (todo.isEmpty()) {
        return candidate;
      }
      continue;
    }
    Set<Role> blocked=isInputBlocked(r);
    if (blocked == null) {
      return null;
    }
    if (todo.isEmpty() && candidate.containsAll(blocked)) {
      return candidate;
    }
    blocked.forEach((x) -> {
      if (!candidate.contains(x)) {
        todo.add(x);
      }
    }
);
  }
  return null;
}
Program: 2389
Project: 2389
Buggy source:
private void runProjectionContextBuildingPasses() throws ScribbleException {
  runVisitorPassOnProjectedModules(ModuleContextBuilder.class);
  runVisitorPassOnProjectedModules(ProtocolDeclContextBuilder.class);
  runVisitorPassOnProjectedModules(RoleCollector.class);
  runVisitorPassOnProjectedModules(ProjectedChoiceDoPruner.class);
  runVisitorPassOnProjectedModules(ProjectedChoiceSubjectFixer.class);
  runVisitorPassOnProjectedModules(ProjectedRoleDeclFixer.class);
  runVisitorPassOnProjectedModules(ProtocolDefInliner.class);
  runVisitorPassOnProjectedModules(InlinedProtocolUnfolder.class);
}

Fixed version (ground truth):
private void runProjectionContextBuildingPasses() throws ScribbleException {
  runVisitorPassOnProjectedModules(ModuleContextBuilder.class);
  runVisitorPassOnProjectedModules(ProtocolDeclContextBuilder.class);
  runVisitorPassOnProjectedModules(RoleCollector.class);
  runVisitorPassOnProjectedModules(ProjectedChoiceDoPruner.class);
  runVisitorPassOnProjectedModules(ProjectedRoleDeclFixer.class);
  runVisitorPassOnProjectedModules(ProtocolDefInliner.class);
  runVisitorPassOnProjectedModules(InlinedProtocolUnfolder.class);
}
Program: 2390
Project: 2390
Buggy source:
protected ProtocolDecl<?> getTargetProtocolDecl(Do<?> parent,NameDisambiguator disamb) throws ScribbleException {
  ModuleContext mc=disamb.getModuleContext();
  JobContext jc=disamb.getJobContext();
  Do<?> doo=(Do<?>)parent;
  ProtocolName<?> simpname=doo.proto.toName();
  ProtocolName<?> fullname=mc.getVisibleProtocolDeclFullName(simpname);
  return jc.getModule(fullname.getPrefix()).getProtocolDecl(simpname);
}

Fixed version (ground truth):
protected ProtocolDecl<?> getTargetProtocolDecl(Do<?> parent,NameDisambiguator disamb) throws ScribbleException {
  ModuleContext mc=disamb.getModuleContext();
  JobContext jc=disamb.getJobContext();
  Do<?> doo=(Do<?>)parent;
  ProtocolName<?> pn=doo.proto.toName();
  ProtocolName<?> fullname=mc.getVisibleProtocolDeclFullName(pn);
  return jc.getModule(fullname.getPrefix()).getProtocolDecl(pn.getSimpleName());
}
Program: 2391
Project: 2391
Buggy source:
private void outputGlobalModel(Job job) throws ScribbleException {
  JobContext jcontext=job.getContext();
  String[] args=this.args.get(ArgFlag.GLOBAL_MODEL);
  for (int i=0; i < args.length; i+=1) {
    GProtocolName fullname=checkGlobalProtocolArg(jcontext,args[i]);
    System.out.println("String_Node_Str" + jcontext.getGlobalModel(fullname).toDot());
  }
}

Fixed version (ground truth):
private void outputGlobalModel(Job job) throws ScribbleException {
  JobContext jcontext=job.getContext();
  String[] args=this.args.get(ArgFlag.GLOBAL_MODEL);
  for (int i=0; i < args.length; i+=1) {
    GProtocolName fullname=checkGlobalProtocolArg(jcontext,args[i]);
    WFState model=jcontext.getGlobalModel(fullname);
    if (model == null) {
      throw new ScribbleException("String_Node_Str" + fullname);
    }
    System.out.println("String_Node_Str" + model.toDot());
  }
}
Program: 2392
Project: 2392
Buggy source:
private void drawGlobalModel(Job job) throws ScribbleException {
  JobContext jcontext=job.getContext();
  String[] args=this.args.get(ArgFlag.GLOBAL_MODEL_DOT);
  for (int i=0; i < args.length; i+=2) {
    GProtocolName fullname=checkGlobalProtocolArg(jcontext,args[i]);
    String png=args[i + 1];
    WFState model=jcontext.getGlobalModel(fullname);
    runDot(model.toDot(),png);
  }
}

Fixed version (ground truth):
private void drawGlobalModel(Job job) throws ScribbleException {
  JobContext jcontext=job.getContext();
  String[] args=this.args.get(ArgFlag.GLOBAL_MODEL_DOT);
  for (int i=0; i < args.length; i+=2) {
    GProtocolName fullname=checkGlobalProtocolArg(jcontext,args[i]);
    String png=args[i + 1];
    WFState model=jcontext.getGlobalModel(fullname);
    if (model == null) {
      throw new ScribbleException("String_Node_Str" + fullname);
    }
    runDot(model.toDot(),png);
  }
}
Program: 2393
Project: 2393
Buggy source:
private void addRolePair(Role dest,Role src){
  if (!this.map.containsKey(dest)) {
    Map<Role,Boolean> map=new HashMap<>();
    this.map.put(dest,map);
    map.put(src,false);
  }
 else   if (!this.map.get(dest).containsKey(src)) {
    this.map.get(dest).put(src,false);
  }
}

Fixed version (ground truth):
private void addRolePair(Role dest,Role src){
  if (!this.map.containsKey(dest)) {
    Map<Role,ConnectedStatus> map=new HashMap<>();
    this.map.put(dest,map);
    map.put(src,ConnectedStatus.FALSE);
  }
 else   if (!this.map.get(dest).containsKey(src)) {
    this.map.get(dest).put(src,ConnectedStatus.FALSE);
  }
}
Program: 2394
Project: 2394
Buggy source:
public boolean isConnected(Role dest,Role src){
  Map<Role,Boolean> tmp=this.map.get(dest);
  if (tmp != null) {
    Boolean b=tmp.get(src);
    return b != null && b;
  }
  return false;
}

Fixed version (ground truth):
public boolean isConnected(Role dest,Role src){
  Map<Role,ConnectedStatus> tmp=this.map.get(dest);
  if (tmp != null) {
    ConnectedStatus b=tmp.get(src);
    return b == ConnectedStatus.TRUE;
  }
  return false;
}
Program: 2395
Project: 2395
Buggy source:
public void setConnected(Role dest,Role src,boolean isConnected){
  addRolePair(dest,src);
  this.map.get(dest).put(src,isConnected);
  addRolePair(src,dest);
  this.map.get(src).put(dest,isConnected);
}

Fixed version (ground truth):
public void setConnected(Role dest,Role src,boolean isConnected){
  setConnected(dest,src,convertStatus(isConnected));
}
Program: 2396
Project: 2396
Buggy source:
public void buildGraph(GProtocolName fullname,Role role) throws ScribbleException {
  debugPrintPass("String_Node_Str" + EndpointGraphBuilder.class + "String_Node_Str"+ fullname+ "String_Node_Str"+ role);
  this.jcontext.getProjection(fullname,role).accept(new EndpointGraphBuilder(this));
}

Fixed version (ground truth):
public void buildGraph(GProtocolName fullname,Role role) throws ScribbleException {
  debugPrintPass("String_Node_Str" + EndpointGraphBuilder.class + "String_Node_Str"+ fullname+ "String_Node_Str"+ role);
  Module proj=this.jcontext.getProjection(fullname,role);
  if (proj == null) {
    throw new ScribbleException("String_Node_Str" + fullname);
  }
  proj.accept(new EndpointGraphBuilder(this));
}
Program: 2397
Project: 2397
Buggy source:
@Override public WFChoiceEnv mergeContexts(List<WFChoiceEnv> children){
  WFChoiceEnv copy=copy();
  for (  WFChoiceEnv child : children) {
    merge(this,copy.initial,child.initial);
    merge(this,copy.connected,child.connected);
  }
  return copy;
}

Fixed version (ground truth):
@Override public WFChoiceEnv mergeContexts(List<WFChoiceEnv> children){
  WFChoiceEnv copy=copy();
  for (  WFChoiceEnv child : children) {
    merge(this,copy.initial,child.initial);
  }
  ConnectedMap cm=children.get(0).getConnected();
  for (  WFChoiceEnv e : children.subList(1,children.size())) {
    cm=cm.merge(e.getConnected());
  }
  copy.connected=cm;
  return copy;
}
Program: 2398
Project: 2398
Buggy source:
private static void merge(WFChoiceEnv parent,ConnectedMap foo,ConnectedMap child){
  for (  Role dest : child.getDestinations()) {
    for (    Role src : child.getSources(dest)) {
      if (!parent.isConnected(src,dest)) {
        foo.setConnected(dest,src,child.isConnected(dest,src));
      }
    }
  }
}

Fixed version (ground truth):
private static void merge(WFChoiceEnv parent,MessageIdMap foo,MessageIdMap child){
  for (  Role dest : child.getDestinations()) {
    for (    Role src : child.getSources(dest)) {
      if (!parent.isEnabled(dest)) {
        foo.putMessages(dest,src,child.getMessages(dest,src));
      }
    }
  }
}
Program: 2399
Project: 2399
Buggy source:
public static void main(String[] args) throws ScribbleException {
  try {
    new CommandLine(args).run();
  }
 catch (  ScribbleException e) {
    System.err.println(e.getMessage());
    System.exit(1);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws ScribbleException {
  new CommandLine(args).run();
}
Program: 2400
Project: 2400
Buggy source:
public void run() throws ScribbleException {
  Job job=newJob(newMainContext());
  ScribbleException fail=null;
  try {
    job.checkWellFormedness();
  }
 catch (  ScribbleException x) {
    fail=x;
  }
  try {
    if (this.args.containsKey(ArgFlag.PROJECT)) {
      outputProjections(job);
    }
    if (this.args.containsKey(ArgFlag.FSM)) {
      outputGraph(job);
    }
    if (this.args.containsKey(ArgFlag.SESS_API)) {
      outputSessionApi(job);
    }
    if (this.args.containsKey(ArgFlag.SCHAN_API)) {
      outputStateChannelApi(job);
    }
    if (this.args.containsKey(ArgFlag.EP_API)) {
      outputEndpointApi(job);
    }
    if (this.args.containsKey(ArgFlag.GLOBAL_MODEL)) {
      if (job.useOldWf) {
        throw new RuntimeException("String_Node_Str" + CommandLineArgParser.GLOBAL_MODEL_FLAG + "String_Node_Str"+ CommandLineArgParser.OLD_WF_FLAG);
      }
      outputGlobalModel(job);
    }
  }
 catch (  ScribbleException x) {
    if (fail == null) {
      fail=x;
    }
  }
  if (fail != null) {
    throw fail;
  }
}

Fixed version (ground truth):
public void run() throws ScribbleException {
  try {
    Job job=newJob(newMainContext());
    ScribbleException fail=null;
    try {
      job.checkWellFormedness();
    }
 catch (    ScribbleException x) {
      fail=x;
    }
    try {
      if (this.args.containsKey(ArgFlag.PROJECT)) {
        outputProjections(job);
      }
      if (this.args.containsKey(ArgFlag.FSM)) {
        outputGraph(job);
      }
      if (this.args.containsKey(ArgFlag.SESS_API)) {
        outputSessionApi(job);
      }
      if (this.args.containsKey(ArgFlag.SCHAN_API)) {
        outputStateChannelApi(job);
      }
      if (this.args.containsKey(ArgFlag.EP_API)) {
        outputEndpointApi(job);
      }
      if (this.args.containsKey(ArgFlag.GLOBAL_MODEL)) {
        if (job.useOldWf) {
          throw new RuntimeException("String_Node_Str" + CommandLineArgParser.GLOBAL_MODEL_FLAG + "String_Node_Str"+ CommandLineArgParser.OLD_WF_FLAG);
        }
        outputGlobalModel(job);
      }
    }
 catch (    ScribbleException x) {
      if (fail == null) {
        fail=x;
      }
    }
    if (fail != null) {
      throw fail;
    }
  }
 catch (  ScribbleException e) {
    if (this.args.containsKey(ArgFlag.JUNIT) || this.args.containsKey(ArgFlag.VERBOSE)) {
      throw e;
    }
 else {
      System.err.println(e.getMessage());
      System.exit(1);
    }
  }
}
Program: 2401
Project: 2401
Buggy source:
private int parseFlag(int i){
  String flag=this.args[i];
switch (flag) {
case CommandLineArgParser.VERBOSE_FLAG:
{
      this.parsed.put(CommandLine.ArgFlag.VERBOSE,new String[0]);
      return i;
    }
case CommandLineArgParser.PATH_FLAG:
{
    return parsePath(i);
  }
case CommandLineArgParser.PROJECT_FLAG:
{
  return parseProject(i);
}
case CommandLineArgParser.FSM_FLAG:
{
return parseFsm(i);
}
case CommandLineArgParser.SESSION_FLAG:
{
return parseSession(i);
}
case CommandLineArgParser.STATECHAN_FLAG:
{
return parseStateChannels(i);
}
case CommandLineArgParser.API_FLAG:
{
return parseApi(i);
}
case CommandLineArgParser.OUTPUT_FLAG:
{
return parseOutput(i);
}
case CommandLineArgParser.STATECHANSUBTYPES_FLAG:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.STATECHANSUBTYPES_FLAG),new String[0]);
return i;
}
case CommandLineArgParser.GLOBAL_MODEL_FLAG:
{
return parseGlobalModel(i);
}
case CommandLineArgParser.OLD_WF_FLAG:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.OLD_WF_FLAG),new String[0]);
return i;
}
case CommandLineArgParser.NO_LIVENESS:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.NO_LIVENESS),new String[0]);
return i;
}
default :
{
throw new RuntimeException(flag);
}
}
}

Fixed version (ground truth):
private int parseFlag(int i){
  String flag=this.args[i];
switch (flag) {
case CommandLineArgParser.JUNIT_FLAG:
{
      this.parsed.put(CommandLine.ArgFlag.JUNIT,new String[0]);
      return i;
    }
case CommandLineArgParser.VERBOSE_FLAG:
{
    this.parsed.put(CommandLine.ArgFlag.VERBOSE,new String[0]);
    return i;
  }
case CommandLineArgParser.PATH_FLAG:
{
  return parsePath(i);
}
case CommandLineArgParser.PROJECT_FLAG:
{
return parseProject(i);
}
case CommandLineArgParser.FSM_FLAG:
{
return parseFsm(i);
}
case CommandLineArgParser.SESSION_FLAG:
{
return parseSession(i);
}
case CommandLineArgParser.STATECHAN_FLAG:
{
return parseStateChannels(i);
}
case CommandLineArgParser.API_FLAG:
{
return parseApi(i);
}
case CommandLineArgParser.OUTPUT_FLAG:
{
return parseOutput(i);
}
case CommandLineArgParser.STATECHANSUBTYPES_FLAG:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.STATECHANSUBTYPES_FLAG),new String[0]);
return i;
}
case CommandLineArgParser.GLOBAL_MODEL_FLAG:
{
return parseGlobalModel(i);
}
case CommandLineArgParser.OLD_WF_FLAG:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.OLD_WF_FLAG),new String[0]);
return i;
}
case CommandLineArgParser.NO_LIVENESS:
{
this.parsed.put(CommandLineArgParser.FLAGS.get(CommandLineArgParser.NO_LIVENESS),new String[0]);
return i;
}
default :
{
throw new RuntimeException(flag);
}
}
}
Program: 2402
Project: 2402
Buggy source:
@Test public void tests() throws IOException, InterruptedException, ExecutionException {
  try {
    URL url=ClassLoader.getSystemResource(GOOD_ROOT);
    String dir=url.getFile().substring(0,url.getFile().length() - ("String_Node_Str" + GOOD_ROOT).length());
    if (File.separator.equals("String_Node_Str")) {
      dir=dir.substring(1).replace("String_Node_Str","String_Node_Str");
    }
    new CommandLine(this.example,CommandLineArgParser.PATH_FLAG,dir).run();
    Assert.assertFalse("String_Node_Str",this.isBadTest);
  }
 catch (  ScribbleException e) {
    Assert.assertTrue("String_Node_Str" + e.getMessage() + "String_Node_Str",this.isBadTest);
  }
}

Fixed version (ground truth):
@Test public void tests() throws IOException, InterruptedException, ExecutionException {
  try {
    URL url=ClassLoader.getSystemResource(GOOD_ROOT);
    String dir=url.getFile().substring(0,url.getFile().length() - ("String_Node_Str" + GOOD_ROOT).length());
    if (File.separator.equals("String_Node_Str")) {
      dir=dir.substring(1).replace("String_Node_Str","String_Node_Str");
    }
    new CommandLine(this.example,CommandLineArgParser.JUNIT_FLAG,CommandLineArgParser.PATH_FLAG,dir).run();
    Assert.assertFalse("String_Node_Str",this.isBadTest);
  }
 catch (  ScribbleException e) {
    Assert.assertTrue("String_Node_Str" + e.getMessage() + "String_Node_Str",this.isBadTest);
  }
}
Program: 2403
Project: 2403
Buggy source:
public ScribbleException testWellFormednessCheck() throws ScribbleException {
  try {
    checkWellFormedness();
  }
 catch (  ScribbleException x) {
    return x;
  }
  return null;
}

Fixed version (ground truth):
public ScribbleException testWellFormednessCheck(){
  try {
    checkWellFormedness();
  }
 catch (  ScribbleException x) {
    return x;
  }
  return null;
}
Program: 2404
Project: 2404
Buggy source:
@Override public GChoice leaveInlinedWFChoiceCheck(ScribNode parent,ScribNode child,WFChoiceChecker checker,ScribNode visited) throws ScribbleException {
  GChoice cho=(GChoice)visited;
  Role subj=cho.subj.toName();
  System.out.println("String_Node_Str" + subj + "String_Node_Str"+ checker.peekEnv()+ "String_Node_Str"+ checker.peekParentEnv());
  if (!checker.peekParentEnv().isEnabled(subj)) {
    throw new ScribbleException("String_Node_Str" + subj);
  }
  List<WFChoiceEnv> all=cho.getBlocks().stream().map((b) -> (WFChoiceEnv)b.del().env()).collect(Collectors.toList());
  if (all.size() > 1) {
    try {
      WFChoiceEnv benv0=all.get(0);
      List<WFChoiceEnv> benvs=all.subList(1,all.size());
      Set<Role> dests=benv0.getEnabled().getDestinations();
      dests.remove(subj);
      for (      Role dest : dests) {
        Set<MessageId<?>> mids=benv0.getEnabled().getMessages(dest);
        benvs.stream().map((e) -> e.getEnabled().getMessages(dest)).forEach((ms) -> {
          if (!Collections.disjoint(mids,ms)) {
            throw new RuntimeScribbleException("String_Node_Str" + dest + "String_Node_Str"+ mids+ "String_Node_Str"+ ms);
          }
          mids.addAll(ms);
        }
);
      }
    }
 catch (    RuntimeScribbleException rse) {
      throw new ScribbleException(rse.getMessage(),rse.getCause());
    }
  }
  WFChoiceEnv merged=checker.popEnv().mergeContexts(all);
  checker.pushEnv(merged);
  return (GChoice)super.leaveInlinedWFChoiceCheck(parent,child,checker,visited);
}

Fixed version (ground truth):
@Override public GChoice leaveInlinedWFChoiceCheck(ScribNode parent,ScribNode child,WFChoiceChecker checker,ScribNode visited) throws ScribbleException {
  GChoice cho=(GChoice)visited;
  Role subj=cho.subj.toName();
  if (!checker.peekParentEnv().isEnabled(subj)) {
    throw new ScribbleException("String_Node_Str" + subj);
  }
  List<WFChoiceEnv> all=cho.getBlocks().stream().map((b) -> (WFChoiceEnv)b.del().env()).collect(Collectors.toList());
  if (all.size() > 1) {
    try {
      WFChoiceEnv benv0=all.get(0);
      List<WFChoiceEnv> benvs=all.subList(1,all.size());
      Set<Role> dests=benv0.getEnabled().getDestinations();
      dests.remove(subj);
      for (      Role dest : dests) {
        Set<MessageId<?>> mids=benv0.getEnabled().getMessages(dest);
        benvs.stream().map((e) -> e.getEnabled().getMessages(dest)).forEach((ms) -> {
          if (!Collections.disjoint(mids,ms)) {
            throw new RuntimeScribbleException("String_Node_Str" + dest + "String_Node_Str"+ mids+ "String_Node_Str"+ ms);
          }
          mids.addAll(ms);
        }
);
      }
    }
 catch (    RuntimeScribbleException rse) {
      throw new ScribbleException(rse.getMessage(),rse.getCause());
    }
  }
  WFChoiceEnv merged=checker.popEnv().mergeContexts(all);
  checker.pushEnv(merged);
  return (GChoice)super.leaveInlinedWFChoiceCheck(parent,child,checker,visited);
}
Program: 2405
Project: 2405
Buggy source:
@Override public void enterInlinedWFChoiceCheck(ScribNode parent,ScribNode child,WFChoiceChecker checker) throws ScribbleException {
  WFChoiceEnv env=checker.peekEnv().enterContext();
  env=env.clear();
  env=env.enableChoiceSubject(((GChoice)child).subj.toName());
  checker.pushEnv(env);
  System.out.println("String_Node_Str" + env);
}

Fixed version (ground truth):
@Override public void enterInlinedWFChoiceCheck(ScribNode parent,ScribNode child,WFChoiceChecker checker) throws ScribbleException {
  WFChoiceEnv env=checker.peekEnv().enterContext();
  env=env.clear();
  env=env.enableChoiceSubject(((GChoice)child).subj.toName());
  checker.pushEnv(env);
}
Program: 2406
Project: 2406
Buggy source:
public T peekParentEnv(){
  return this.envs.get(this.envs.size() - 2);
}

Fixed version (ground truth):
public T peekParentEnv(){
  return this.envs.get(1);
}
Program: 2407
Project: 2407
Buggy source:
@Override public GChoice leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GChoice gc=(GChoice)visited;
  List<LProtocolBlock> blocks=gc.getBlocks().stream().map((b) -> (LProtocolBlock)((ProjectionEnv)b.del().env()).getProjection()).collect(Collectors.toList());
  LChoice projection=null;
  if (blocks.stream().filter((b) -> !b.isEmpty()).count() > 0) {
    List<LChoice> cs=blocks.stream().map((b) -> AstFactoryImpl.FACTORY.LChoice(AstFactoryImpl.FACTORY.DummyProjectionRoleNode(),Arrays.asList(b))).collect(Collectors.toList());
    LChoice merged=cs.get(0);
    for (int i=1; i < cs.size(); i++) {
      merged=merged.merge(cs.get(i));
    }
    projection=merged;
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GChoice)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gc);
}

Fixed version (ground truth):
@Override public GChoice leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GChoice gc=(GChoice)visited;
  List<LProtocolBlock> blocks=gc.getBlocks().stream().map((b) -> (LProtocolBlock)((ProjectionEnv)b.del().env()).getProjection()).collect(Collectors.toList());
  LChoice projection=null;
  blocks=blocks.stream().filter((b) -> !b.isEmpty()).collect(Collectors.toList());
  if (!blocks.isEmpty()) {
    List<LChoice> cs=blocks.stream().map((b) -> AstFactoryImpl.FACTORY.LChoice(AstFactoryImpl.FACTORY.DummyProjectionRoleNode(),Arrays.asList(b))).collect(Collectors.toList());
    LChoice merged=cs.get(0);
    for (int i=1; i < cs.size(); i++) {
      merged=merged.merge(cs.get(i));
    }
    projection=merged;
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GChoice)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gc);
}
Program: 2408
Project: 2408
Buggy source:
@Override public GChoice leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GChoice gc=(GChoice)visited;
  List<LProtocolBlock> blocks=gc.getBlocks().stream().map((b) -> (LProtocolBlock)((ProjectionEnv)b.del().env()).getProjection()).collect(Collectors.toList());
  LChoice projection=null;
  if (blocks.size() == 1) {
    if (!blocks.get(0).isEmpty()) {
      RoleNode subj=AstFactoryImpl.FACTORY.DummyProjectionRoleNode();
      projection=AstFactoryImpl.FACTORY.LChoice(subj,blocks);
    }
  }
 else {
    List<LChoice> cs=blocks.stream().map((b) -> AstFactoryImpl.FACTORY.LChoice(AstFactoryImpl.FACTORY.DummyProjectionRoleNode(),Arrays.asList(b))).collect(Collectors.toList());
    LChoice merged=cs.get(0);
    for (int i=1; i < cs.size(); i++) {
      merged=merged.merge(cs.get(i));
    }
    projection=merged;
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GChoice)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gc);
}

Fixed version (ground truth):
@Override public GChoice leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GChoice gc=(GChoice)visited;
  List<LProtocolBlock> blocks=gc.getBlocks().stream().map((b) -> (LProtocolBlock)((ProjectionEnv)b.del().env()).getProjection()).collect(Collectors.toList());
  LChoice projection=null;
  if (blocks.stream().filter((b) -> !b.isEmpty()).count() > 0) {
    List<LChoice> cs=blocks.stream().map((b) -> AstFactoryImpl.FACTORY.LChoice(AstFactoryImpl.FACTORY.DummyProjectionRoleNode(),Arrays.asList(b))).collect(Collectors.toList());
    LChoice merged=cs.get(0);
    for (int i=1; i < cs.size(); i++) {
      merged=merged.merge(cs.get(i));
    }
    projection=merged;
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GChoice)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gc);
}
Program: 2409
Project: 2409
Buggy source:
@Override public GRecursion leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GRecursion gr=(GRecursion)visited;
  RecVarNode recvar=gr.recvar.clone();
  LProtocolBlock block=(LProtocolBlock)((ProjectionEnv)gr.block.del().env()).getProjection();
  LRecursion projection=null;
  Set<RecVar> rvs=new HashSet<>();
  rvs.add(recvar.toName());
  LProtocolBlock pruned=prune(block,rvs);
  if (!pruned.isEmpty()) {
    projection=AstFactoryImpl.FACTORY.LRecursion(recvar,pruned);
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GRecursion)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gr);
}

Fixed version (ground truth):
@Override public GRecursion leaveProjection(ScribNode parent,ScribNode child,Projector proj,ScribNode visited) throws ScribbleException {
  GRecursion gr=(GRecursion)visited;
  RecVarNode recvar=gr.recvar.clone();
  LRecursion projection=null;
  Set<RecVar> rvs=new HashSet<>();
  rvs.add(recvar.toName());
  LProtocolBlock pruned=prune((LProtocolBlock)((ProjectionEnv)gr.block.del().env()).getProjection(),rvs);
  if (!pruned.isEmpty()) {
    projection=AstFactoryImpl.FACTORY.LRecursion(recvar,pruned);
  }
  proj.pushEnv(proj.popEnv().setProjection(projection));
  return (GRecursion)GCompoundInteractionNodeDel.super.leaveProjection(parent,child,proj,gr);
}
Program: 2410
Project: 2410
Buggy source:
public void wrapChannel(BinaryChannelEndpoint c){
  this.se=c.se;
  this.c=c.c;
  this.bb=c.bb;
}

Fixed version (ground truth):
public void wrapChannel(BinaryChannelEndpoint c) throws IOException {
  this.se=c.se;
  this.c=c.c;
  this.bb=c.bb;
}
Program: 2411
Project: 2411
Buggy source:
public synchronized CompletableFuture<ScribMessage> getFuture(){
  final int ticket=getTicket();
  CompletableFuture<ScribMessage> fut=CompletableFuture.supplyAsync(() -> {
    try {
      ScribMessage m=read(ticket);
      if (m instanceof ScribInterrupt) {
        throw new RuntimeScribbleException((Throwable)((ScribInterrupt)m).payload[0]);
      }
      return m;
    }
 catch (    IOException e) {
      throw new RuntimeScribbleException(e);
    }
 finally {
      this.pending.remove(this);
    }
  }
);
  this.pending.add(fut);
  return fut;
}

Fixed version (ground truth):
public synchronized CompletableFuture<ScribMessage> getFuture(){
  final int ticket=getTicket();
  CompletableFuture<ScribMessage> fut=CompletableFuture.supplyAsync(() -> {
    try {
      ScribMessage m=read(ticket);
      if (m instanceof ScribInterrupt) {
        throw new RuntimeScribbleException((Throwable)((ScribInterrupt)m).payload[0]);
      }
      return m;
    }
 catch (    IOException e) {
      throw new RuntimeScribbleException(e);
    }
 finally {
      this.pending.remove(0);
    }
  }
);
synchronized (this.pending) {
    this.pending.add(fut);
  }
  return fut;
}