Program: 41069
Project: 41069
Buggy source:
public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,final MessageAnnotationsDescribedType messageAnnotationsDescribedType,final PropertiesDescribedType propertiesDescribedType,ApplicationPropertiesDescribedType appPropertiesDescribedType,final DescribedType content,final int count,final boolean drain,final boolean sendDrainFlowResponse,Matcher<UnsignedInteger> creditMatcher,final Integer nextIncomingId,final boolean sendSettled,boolean addMessageNumberProperty){
  if (nextIncomingId == null && count > 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Matcher<Boolean> drainMatcher=null;
  if (drain) {
    drainMatcher=equalTo(true);
  }
 else {
    drainMatcher=Matchers.anyOf(equalTo(false),nullValue());
  }
  Matcher<UnsignedInteger> remoteNextIncomingIdMatcher=null;
  if (nextIncomingId != null) {
    remoteNextIncomingIdMatcher=Matchers.equalTo(UnsignedInteger.valueOf(nextIncomingId));
  }
 else {
    remoteNextIncomingIdMatcher=Matchers.greaterThanOrEqualTo(UnsignedInteger.ONE);
  }
  final FlowMatcher flowMatcher=new FlowMatcher().withLinkCredit(Matchers.greaterThanOrEqualTo(UnsignedInteger.valueOf(count))).withDrain(drainMatcher).withNextIncomingId(remoteNextIncomingIdMatcher);
  CompositeAmqpPeerRunnable composite=new CompositeAmqpPeerRunnable();
  boolean addComposite=false;
  if (appPropertiesDescribedType == null && addMessageNumberProperty) {
    appPropertiesDescribedType=new ApplicationPropertiesDescribedType();
  }
  for (int i=0; i < count; i++) {
    final int nextId=nextIncomingId + i;
    String tagString="String_Node_Str" + nextId;
    Binary dtag=new Binary(tagString.getBytes());
    if (addMessageNumberProperty) {
      appPropertiesDescribedType.setApplicationProperty(MESSAGE_NUMBER,i);
    }
    final TransferFrame transferResponse=new TransferFrame().setDeliveryId(UnsignedInteger.valueOf(nextId)).setDeliveryTag(dtag).setMessageFormat(UnsignedInteger.ZERO).setSettled(sendSettled);
    Binary payload=prepareTransferPayload(headerDescribedType,messageAnnotationsDescribedType,propertiesDescribedType,appPropertiesDescribedType,content);
    final FrameSender transferResponseSender=new FrameSender(this,FrameType.AMQP,-1,transferResponse,payload);
    transferResponseSender.setValueProvider(new ValueProvider(){
      @Override public void setValues(){
        transferResponse.setHandle(flowMatcher.getReceivedHandle());
        transferResponseSender.setChannel(flowMatcher.getActualChannel());
      }
    }
);
    addComposite=true;
    composite.add(transferResponseSender);
  }
  if (drain && sendDrainFlowResponse) {
    final FlowFrame drainResponse=new FlowFrame();
    drainResponse.setOutgoingWindow(UnsignedInteger.ZERO);
    drainResponse.setIncomingWindow(UnsignedInteger.valueOf(Integer.MAX_VALUE));
    drainResponse.setLinkCredit(UnsignedInteger.ZERO);
    drainResponse.setDrain(true);
    final FrameSender flowResponseSender=new FrameSender(this,FrameType.AMQP,-1,drainResponse,null);
    flowResponseSender.setValueProvider(new ValueProvider(){
      @Override public void setValues(){
        flowResponseSender.setChannel(flowMatcher.getActualChannel());
        drainResponse.setHandle(flowMatcher.getReceivedHandle());
        drainResponse.setDeliveryCount(calculateNewDeliveryCount(flowMatcher));
        drainResponse.setNextOutgoingId(calculateNewOutgoingId(flowMatcher,count));
        drainResponse.setNextIncomingId(flowMatcher.getReceivedNextOutgoingId());
      }
    }
);
    addComposite=true;
    composite.add(flowResponseSender);
  }
  if (addComposite) {
    flowMatcher.onCompletion(composite);
  }
  addHandler(flowMatcher);
}

Fixed version (ground truth):
public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType,final MessageAnnotationsDescribedType messageAnnotationsDescribedType,final PropertiesDescribedType propertiesDescribedType,ApplicationPropertiesDescribedType appPropertiesDescribedType,final DescribedType content,final int count,final boolean drain,final boolean sendDrainFlowResponse,Matcher<UnsignedInteger> creditMatcher,final Integer nextIncomingId,final boolean sendSettled,boolean addMessageNumberProperty){
  if (nextIncomingId == null && count > 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Matcher<Boolean> drainMatcher=null;
  if (drain) {
    drainMatcher=equalTo(true);
  }
 else {
    drainMatcher=Matchers.anyOf(equalTo(false),nullValue());
  }
  Matcher<UnsignedInteger> remoteNextIncomingIdMatcher=null;
  if (nextIncomingId != null) {
    remoteNextIncomingIdMatcher=Matchers.equalTo(UnsignedInteger.valueOf(nextIncomingId));
  }
 else {
    remoteNextIncomingIdMatcher=Matchers.greaterThanOrEqualTo(UnsignedInteger.ONE);
  }
  final FlowMatcher flowMatcher=new FlowMatcher().withLinkCredit(creditMatcher).withDrain(drainMatcher).withNextIncomingId(remoteNextIncomingIdMatcher);
  CompositeAmqpPeerRunnable composite=new CompositeAmqpPeerRunnable();
  boolean addComposite=false;
  if (appPropertiesDescribedType == null && addMessageNumberProperty) {
    appPropertiesDescribedType=new ApplicationPropertiesDescribedType();
  }
  for (int i=0; i < count; i++) {
    final int nextId=nextIncomingId + i;
    String tagString="String_Node_Str" + nextId;
    Binary dtag=new Binary(tagString.getBytes());
    if (addMessageNumberProperty) {
      appPropertiesDescribedType.setApplicationProperty(MESSAGE_NUMBER,i);
    }
    final TransferFrame transferResponse=new TransferFrame().setDeliveryId(UnsignedInteger.valueOf(nextId)).setDeliveryTag(dtag).setMessageFormat(UnsignedInteger.ZERO).setSettled(sendSettled);
    Binary payload=prepareTransferPayload(headerDescribedType,messageAnnotationsDescribedType,propertiesDescribedType,appPropertiesDescribedType,content);
    final FrameSender transferResponseSender=new FrameSender(this,FrameType.AMQP,-1,transferResponse,payload);
    transferResponseSender.setValueProvider(new ValueProvider(){
      @Override public void setValues(){
        transferResponse.setHandle(flowMatcher.getReceivedHandle());
        transferResponseSender.setChannel(flowMatcher.getActualChannel());
      }
    }
);
    addComposite=true;
    composite.add(transferResponseSender);
  }
  if (drain && sendDrainFlowResponse) {
    final FlowFrame drainResponse=new FlowFrame();
    drainResponse.setOutgoingWindow(UnsignedInteger.ZERO);
    drainResponse.setIncomingWindow(UnsignedInteger.valueOf(Integer.MAX_VALUE));
    drainResponse.setLinkCredit(UnsignedInteger.ZERO);
    drainResponse.setDrain(true);
    final FrameSender flowResponseSender=new FrameSender(this,FrameType.AMQP,-1,drainResponse,null);
    flowResponseSender.setValueProvider(new ValueProvider(){
      @Override public void setValues(){
        flowResponseSender.setChannel(flowMatcher.getActualChannel());
        drainResponse.setHandle(flowMatcher.getReceivedHandle());
        drainResponse.setDeliveryCount(calculateNewDeliveryCount(flowMatcher));
        drainResponse.setNextOutgoingId(calculateNewOutgoingId(flowMatcher,count));
        drainResponse.setNextIncomingId(flowMatcher.getReceivedNextOutgoingId());
      }
    }
);
    addComposite=true;
    composite.add(flowResponseSender);
  }
  if (addComposite) {
    flowMatcher.onCompletion(composite);
  }
  addHandler(flowMatcher);
}