nus-yam/ex-repair huggingface dataset:
Program: 167650
Project: 167650
Buggy source:
public void list() throws IOException {
  HttpServletRequest req=ServletActionContext.getRequest();
  HttpServletResponse resp=ServletActionContext.getResponse();
  int offset, pageSize;
  List<Node> nodeList=null;
  try {
    offset=Integer.valueOf(req.getParameter("String_Node_Str"));
    pageSize=Integer.valueOf(req.getParameter("String_Node_Str"));
    nodeList=nodeService.getWithType(Constants.QUEUE_TYPE,offset,pageSize);
    String jsonArr=gson.toJson(nodeList);
    jsonArr=generateListWithPagingSuccessJSONStr(jsonArr,nodeService.countAvailableQueues());
    responseJTableData(resp,jsonArr);
  }
 catch (  NumberFormatException e) {
    nodeList=nodeService.getWithType(Constants.QUEUE_TYPE,0,Integer.MAX_VALUE);
    String jsonArr=gson.toJson(nodeList);
    jsonArr=generateListSuccessJSONStr(jsonArr);
    responseJTableData(resp,jsonArr);
  }
}

Fixed version (ground truth):
public void list() throws IOException {
  HttpServletRequest req=ServletActionContext.getRequest();
  HttpServletResponse resp=ServletActionContext.getResponse();
  int offset, pageSize;
  List<Node> nodeList=null;
  try {
    offset=Integer.parseInt(req.getParameter("String_Node_Str"));
    pageSize=Integer.parseInt(req.getParameter("String_Node_Str"));
    nodeList=nodeService.getWithType(Constants.QUEUE_TYPE,offset,pageSize);
    String jsonArr=gson.toJson(nodeList);
    jsonArr=generateListWithPagingSuccessJSONStr(jsonArr,nodeService.countAvailableQueues());
    responseJTableData(resp,jsonArr);
  }
 catch (  NumberFormatException e) {
    nodeList=nodeService.getWithType(Constants.QUEUE_TYPE,0,Integer.MAX_VALUE);
    String jsonArr=gson.toJson(nodeList);
    jsonArr=generateListSuccessJSONStr(jsonArr);
    responseJTableData(resp,jsonArr);
  }
}
Program: 167651
Project: 167651
Buggy source:
public void receivepermission() throws IOException {
  HttpServletRequest req=ServletActionContext.getRequest();
  HttpServletResponse resp=ServletActionContext.getResponse();
  String joinedGrantIds=req.getParameter("String_Node_Str");
  String targetIdStr=req.getParameter("String_Node_Str");
  String originalGrantIds=req.getParameter("String_Node_Str");
  if (joinedGrantIds == null) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  if (originalGrantIds == null) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  if (Strings.isNullOrEmpty(targetIdStr)) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  int targetId=Integer.valueOf(targetIdStr);
  Map<String,List<Integer>> filterMap=this.filterGrantIds(originalGrantIds,joinedGrantIds);
  ReceivePermission receivePermission=new ReceivePermission();
  receivePermission.setTargetId(targetId);
  try {
    for (    Integer deletingGrantId : filterMap.get("String_Node_Str")) {
      receivePermissionService.remove(targetId,deletingGrantId);
    }
    for (    Integer insertingGrantId : filterMap.get("String_Node_Str")) {
      receivePermission.setGrantId(insertingGrantId);
      receivePermissionService.save(receivePermission);
    }
    responseJTableData(resp,generateUpdateSuccessJSONStr());
  }
 catch (  SQLException e) {
    logger.error("String_Node_Str" + e.getMessage());
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
  }
}

Fixed version (ground truth):
public void receivepermission() throws IOException {
  HttpServletRequest req=ServletActionContext.getRequest();
  HttpServletResponse resp=ServletActionContext.getResponse();
  String joinedGrantIds=req.getParameter("String_Node_Str");
  String targetIdStr=req.getParameter("String_Node_Str");
  String originalGrantIds=req.getParameter("String_Node_Str");
  if (joinedGrantIds == null) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  if (originalGrantIds == null) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  if (Strings.isNullOrEmpty(targetIdStr)) {
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
    return;
  }
  int targetId=Integer.parseInt(targetIdStr);
  Map<String,List<Integer>> filterMap=this.filterGrantIds(originalGrantIds,joinedGrantIds);
  ReceivePermission receivePermission=new ReceivePermission();
  receivePermission.setTargetId(targetId);
  try {
    for (    Integer deletingGrantId : filterMap.get("String_Node_Str")) {
      receivePermissionService.remove(targetId,deletingGrantId);
    }
    for (    Integer insertingGrantId : filterMap.get("String_Node_Str")) {
      receivePermission.setGrantId(insertingGrantId);
      receivePermissionService.save(receivePermission);
    }
    responseJTableData(resp,generateUpdateSuccessJSONStr());
  }
 catch (  SQLException e) {
    logger.error("String_Node_Str" + e.getMessage());
    responseJTableData(resp,generateErrorJSONStr("String_Node_Str"));
  }
}
Program: 167652
Project: 167652
Buggy source:
private static void prepareEnv(String configFilePathStr){
  logger.info("String_Node_Str");
  ConfigurationLoader configurationLoader=ConfigurationLoader.defaultLoader();
  configurationLoader.setConfigFilePathStr(configFilePathStr);
  try {
    configurationLoader.launch();
  }
 catch (  IOException e) {
    ExceptionHelper.logException(logger,e,"String_Node_Str");
    logger.error("String_Node_Str" + e.getMessage());
    logger.error("String_Node_Str");
    System.exit(1);
  }
  config=configurationLoader.getConfigProperties();
  String zkHost=config.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_HOST);
  int zkPort=Integer.valueOf(config.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_PORT));
  globalZKExchangeManager=ExchangerManager.defaultExchangerManager(zkHost,zkPort);
}

Fixed version (ground truth):
private static void prepareEnv(String configFilePathStr){
  logger.info("String_Node_Str");
  ConfigurationLoader configurationLoader=ConfigurationLoader.defaultLoader();
  configurationLoader.setConfigFilePathStr(configFilePathStr);
  try {
    configurationLoader.launch();
  }
 catch (  IOException e) {
    ExceptionHelper.logException(logger,e,"String_Node_Str");
    logger.error("String_Node_Str" + e.getMessage());
    logger.error("String_Node_Str");
    System.exit(1);
  }
  config=configurationLoader.getConfigProperties();
  String zkHost=config.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_HOST);
  int zkPort=Integer.parseInt(config.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_PORT));
  globalZKExchangeManager=ExchangerManager.defaultExchangerManager(zkHost,zkPort);
}
Program: 167653
Project: 167653
Buggy source:
private static void buildCommonClient(Map<String,Object> context) throws MessagebusConnectedFailedException {
  Properties serverConfig=(Properties)context.get(Constants.KEY_SERVER_CONFIG);
  String appId=serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_APP_ID);
  Messagebus commonClient=Messagebus.createClient(appId);
  String zkHost=serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_HOST);
  int zkPort=Integer.valueOf(serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_PORT));
  commonClient.setZkHost(zkHost);
  commonClient.setZkPort(zkPort);
  commonClient.open();
  context.put(Constants.GLOBAL_CLIENT_OBJECT,commonClient);
}

Fixed version (ground truth):
private static void buildCommonClient(Map<String,Object> context) throws MessagebusConnectedFailedException {
  Properties serverConfig=(Properties)context.get(Constants.KEY_SERVER_CONFIG);
  String appId=serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_APP_ID);
  Messagebus commonClient=Messagebus.createClient(appId);
  String zkHost=serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_HOST);
  int zkPort=Integer.parseInt(serverConfig.getProperty(Constants.KEY_MESSAGEBUS_SERVER_ZK_PORT));
  commonClient.setZkHost(zkHost);
  commonClient.setZkPort(zkPort);
  commonClient.open();
  context.put(Constants.GLOBAL_CLIENT_OBJECT,commonClient);
}
Program: 167654
Project: 167654
Buggy source:
public MsgLogService(Map<String,Object> context){
  super(context);
  serverConfig=(Properties)this.context.get(Constants.KEY_SERVER_CONFIG);
  client=(Messagebus)this.context.get(Constants.GLOBAL_CLIENT_OBJECT);
}

Fixed version (ground truth):
public MsgLogService(Map<String,Object> context){
  super(context);
  client=(Messagebus)this.context.get(Constants.GLOBAL_CLIENT_OBJECT);
}
Program: 167655
Project: 167655
Buggy source:
/** 
 * close the messagebus client and release all used resources pls invoke this method after making sure you will not use the client in current context.
 */
public synchronized void close(){
  try {
    this.configManager.destroy();
    if (this.useChannelPool)     pool.destroy();
    if (this.connection.isOpen())     this.connection.close();
    this.zookeeper.close();
    boolean success=this.isOpen.compareAndSet(true,false);
    if (!success) {
      logger.error("String_Node_Str");
    }
  }
 catch (  IOException e) {
    logger.error("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * close the messagebus client and release all used resources pls invoke this method after making sure you will not use the client in current context.
 */
public synchronized void close(){
  try {
    if (this.configManager != null)     this.configManager.destroy();
    if (this.useChannelPool && pool != null)     pool.destroy();
    if (this.connection.isOpen())     this.connection.close();
    this.zookeeper.close();
    boolean success=this.isOpen.compareAndSet(true,false);
    if (!success) {
      logger.error("String_Node_Str");
    }
  }
 catch (  IOException e) {
    logger.error("String_Node_Str" + e.getMessage());
  }
}
Program: 167656
Project: 167656
Buggy source:
public static ExecResult exec(@NotNull String cmdStr) throws IOException, InterruptedException {
  String[] splitedParts=new String[]{"String_Node_Str","String_Node_Str",cmdStr};
  Process process=Runtime.getRuntime().exec(splitedParts);
  process.waitFor();
  String errStr=translateFromStream(process.getErrorStream());
  String infoStr=translateFromStream(process.getInputStream());
  ExecResult execResult=new ExecResult();
  execResult.setError(errStr);
  execResult.setInfo(infoStr);
  logger.debug("String_Node_Str" + "String_Node_Str" + errStr + "String_Node_Str"+ cmdStr);
  logger.debug("String_Node_Str" + infoStr);
  return execResult;
}

Fixed version (ground truth):
public static ExecResult exec(@NotNull String cmdStr) throws IOException, InterruptedException {
  String[] cmd={"String_Node_Str","String_Node_Str",cmdStr};
  Process process=Runtime.getRuntime().exec(cmd);
  process.waitFor();
  String errStr=translateFromStream(process.getErrorStream());
  String infoStr=translateFromStream(process.getInputStream());
  ExecResult execResult=new ExecResult();
  execResult.setError(errStr);
  execResult.setInfo(infoStr);
  logger.debug("String_Node_Str" + "String_Node_Str" + errStr + "String_Node_Str"+ cmdStr);
  logger.debug("String_Node_Str" + infoStr);
  return execResult;
}
Program: 167657
Project: 167657
Buggy source:
private static ZooKeeper createZKClient(){
  try {
    return new ZooKeeper(host + port,30000,new SessionWatcher());
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
private static ZooKeeper createZKClient(){
  try {
    return new ZooKeeper(host + "String_Node_Str" + port,30000,new SessionWatcher());
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str" + e.getMessage());
  }
}
Program: 167658
Project: 167658
Buggy source:
public void testSimpleProduceAndConsume() throws Exception {
  Messagebus client=Messagebus.getInstance();
  client.setZkHost("String_Node_Str");
  client.setZkPort(2181);
  client.open();
  appkey=java.util.UUID.randomUUID().toString();
  msgType="String_Node_Str";
  String queueName="String_Node_Str";
  IConsumerCloser closer=client.getConsumer().consume(appkey,msgType,queueName,new IMessageReceiveListener(){
    @Override public void onMessage(    Message msg,    MessageFormat format){
switch (format) {
case Text:
{
          TextMessage txtMsg=(TextMessage)msg;
          logger.debug("String_Node_Str" + txtMsg.getMessageBody());
        }
      break;
case Object:
{
      ObjectMessage objMsg=(ObjectMessage)msg;
      SimpleObjectMessagePOJO realObj=(SimpleObjectMessagePOJO)objMsg.getObject();
      logger.debug("String_Node_Str" + realObj.getTxt());
    }
  break;
}
}
}
);
TextMessagePOJO msg=new TextMessagePOJO();
msg.setMessageBody("String_Node_Str");
client.getProducer().produce(msg,MessageFormat.Text,appkey,queueName,msgType);
ObjectMessagePOJO objMsg=new ObjectMessagePOJO();
SimpleObjectMessagePOJO soPojo=new SimpleObjectMessagePOJO();
soPojo.setTxt("String_Node_Str");
objMsg.setObject(soPojo);
client.getProducer().produce(objMsg,MessageFormat.Object,appkey,queueName,msgType);
Thread.sleep(10000);
closer.closeConsumer();
client.close();
}

Fixed version (ground truth):
public void testSimpleProduceAndConsume() throws Exception {
  appkey=java.util.UUID.randomUUID().toString();
  msgType="String_Node_Str";
  String queueName="String_Node_Str";
  IConsumerCloser closer=client.getConsumer().consume(appkey,msgType,queueName,new IMessageReceiveListener(){
    @Override public void onMessage(    Message msg,    MessageFormat format){
switch (format) {
case Text:
{
          TextMessage txtMsg=(TextMessage)msg;
          logger.debug("String_Node_Str" + txtMsg.getMessageBody());
        }
      break;
case Object:
{
      ObjectMessage objMsg=(ObjectMessage)msg;
      SimpleObjectMessagePOJO realObj=(SimpleObjectMessagePOJO)objMsg.getObject();
      logger.debug("String_Node_Str" + realObj.getTxt());
    }
  break;
}
}
}
);
TextMessagePOJO msg=new TextMessagePOJO();
msg.setMessageBody("String_Node_Str");
client.getProducer().produce(msg,MessageFormat.Text,appkey,queueName,msgType);
ObjectMessagePOJO objMsg=new ObjectMessagePOJO();
SimpleObjectMessagePOJO soPojo=new SimpleObjectMessagePOJO();
soPojo.setTxt("String_Node_Str");
objMsg.setObject(soPojo);
client.getProducer().produce(objMsg,MessageFormat.Object,appkey,queueName,msgType);
Thread.sleep(10000);
closer.closeConsumer();
client.close();
}
Program: 167659
Project: 167659
Buggy source:
public Config find(long id);

Fixed version (ground truth):
@Select("String_Node_Str") public Config find(long id);
Program: 167660
Project: 167660
Buggy source:
public void save(Config configItem);

Fixed version (ground truth):
@Insert("String_Node_Str") public void save(Config configItem);
Program: 167661
Project: 167661
Buggy source:
public void update(Config config);

Fixed version (ground truth):
@Update("String_Node_Str") public void update(Config config);
Program: 167662
Project: 167662
Buggy source:
public void delete(long id);

Fixed version (ground truth):
@Delete("String_Node_Str") public void delete(long id);
Program: 167663
Project: 167663
Buggy source:
@Override protected void onDraw(Canvas canvas){
  getDrawingRect(mRect);
  mRect.left+=getPaddingLeft() + mPadding;
  mRect.top+=getPaddingTop() + mPadding;
  mRect.right-=getPaddingRight() + mPadding;
  mRect.bottom-=getPaddingBottom() + mPadding;
  mRectF.set(mRect);
  mPaint.setAntiAlias(true);
  mPaint.setStrokeCap(Paint.Cap.BUTT);
  mPaint.setColor(mColor);
  canvas.drawArc(mRectF,-60,mProgress < 0 ? getMax() - 60 : mProgress * 300 / getMax(),!mHollow,mPaint);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  getDrawingRect(mRect);
  mRect.left+=getPaddingLeft() + mPadding;
  mRect.top+=getPaddingTop() + mPadding;
  mRect.right-=getPaddingRight() + mPadding;
  mRect.bottom-=getPaddingBottom() + mPadding;
  mRectF.set(mRect);
  mPaint.setAntiAlias(true);
  mPaint.setStrokeCap(Paint.Cap.BUTT);
  mPaint.setColor(mColor);
  canvas.drawArc(mRectF,-60,mProgress < 0 ? 300 : mProgress * 300 / getMax(),!mHollow,mPaint);
}
Program: 167664
Project: 167664
Buggy source:
@SuppressLint("String_Node_Str") @Override public void onCreate(){
  super.onCreate();
  Languager.setLanguage(this);
  IntentFilter filter=new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
  registerReceiver(networkReceiver,filter);
  updateConnectedFlags();
  sharedPrefs=PreferenceManager.getDefaultSharedPreferences(this);
  allowMobileData=sharedPrefs.getBoolean(SettingsFragment.PREF_KEY_MOBILE_DATA,true);
  alarmsMap=new HashMap<Integer,Alarm>();
  exchangesMap=new HashMap<String,Exchange>();
  alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
  try {
    db=new DBManager(this);
    nextAlarmID=db.getMaxID();
    alarmsMap=db.getAlarms();
    if (nextAlarmID == 0) {
    }
    if (nextAlarmID > 0) {
      for (      Alarm alarm : alarmsMap.values()) {
        alarm.setExchange(getExchange(alarm.getExchangeCode()));
        if (alarm.isOn()) {
          addToAlarmManager(alarm,0);
        }
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onCreate(){
  super.onCreate();
  Languager.setLanguage(this);
  IntentFilter filter=new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
  registerReceiver(networkReceiver,filter);
  updateConnectedFlags();
  sharedPrefs=PreferenceManager.getDefaultSharedPreferences(this);
  allowMobileData=sharedPrefs.getBoolean(SettingsFragment.PREF_KEY_MOBILE_DATA,true);
  alarmsMap=new HashMap<Integer,Alarm>();
  exchangesMap=new HashMap<String,Exchange>();
  alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
  try {
    db=new DBManager(this);
    nextAlarmID=db.getMaxID();
    alarmsMap=db.getAlarms();
    if (alarmsMap.isEmpty()) {
    }
 else {
      for (      Alarm alarm : alarmsMap.values()) {
        alarm.setExchange(getExchange(alarm.getExchangeCode()));
        if (alarm.isOn()) {
          addToAlarmManager(alarm,0);
        }
      }
    }
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e);
  }
}
Program: 167666
Project: 167666
Buggy source:
@Override protected void execute(){
  @SuppressWarnings("String_Node_Str") Packet p;
  int i=-1;
  int substream_level=0;
  while (true) {
    if (substream_level == 0) {
      try {
        i=findInputPortElementWithData(inportArray);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      if (i == -1)       return;
    }
    p=inportArray[i].receive();
    if (p.getType() == Packet.OPEN)     substream_level++;
 else     if (p.getType() == Packet.CLOSE)     substream_level--;
    outport.send(p);
  }
}

Fixed version (ground truth):
@Override protected void execute(){
  @SuppressWarnings("String_Node_Str") Packet p=null;
  int i=-1;
  int substream_level=0;
  while (true) {
    if (substream_level != 0) {
      p=inportArray[i].receive();
      if (p == null)       break;
    }
 else {
      while (true) {
        try {
          i=findInputPortElementWithData(inportArray);
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
        if (i == -1)         return;
        p=inportArray[i].receive();
        if (p != null)         break;
      }
    }
    if (p.getType() == Packet.OPEN)     substream_level++;
 else     if (p.getType() == Packet.CLOSE)     substream_level--;
    outport.send(p);
  }
}
Program: 167668
Project: 167668
Buggy source:
/** 
 * This method is called from other parts of the system to activate this Component if it needs to be. This will start its thread if needed, and if already started, will notify() it.
 */
void activate(){
  if (isTerminated()) {
    return;
  }
  if (!isAlive()) {
    setPriority(priority);
    start();
  }
 else {
    mother.traceLocks("String_Node_Str" + getName());
    try {
      goLock.lockInterruptibly();
      if (status == StatusValues.DORMANT) {
        canGo.signal();
        mother.traceLocks("String_Node_Str" + getName());
      }
    }
 catch (    InterruptedException e) {
      return;
    }
 finally {
      goLock.unlock();
      mother.traceLocks("String_Node_Str" + getName());
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is called from other parts of the system to activate this Component if it needs to be. This will start its thread if needed, and if already started, will notify() it.
 */
void activate(){
  if (isTerminated()) {
    return;
  }
  if (!isAlive()) {
    setPriority(priority);
    start();
  }
 else {
    mother.traceLocks("String_Node_Str" + getName());
    try {
      goLock.lockInterruptibly();
      if (status == StatusValues.DORMANT || status == StatusValues.SUSP_FIPE) {
        canGo.signal();
        mother.traceLocks("String_Node_Str" + getName());
      }
    }
 catch (    InterruptedException e) {
      return;
    }
 finally {
      goLock.unlock();
      mother.traceLocks("String_Node_Str" + getName());
    }
  }
}
Program: 167671
Project: 167671
Buggy source:
void buildNote(final int note,final int duration,final float sampleRate){
  double RAD=2.0 * Math.PI;
  int gap=25;
  int samples=(int)(duration * sampleRate / 1000);
  boolean note_ending=false, note_ended=false;
  int savex=0;
  for (int i=0; i < samples; i++) {
    if (note == 0) {
      x=0;
    }
 else     if (!note_ended) {
      x=(int)(32767.0 * Math.sin(RAD * note * i / sampleRate));
      if (note_ending) {
        if (Math.signum(x) != Math.signum(savex)) {
          note_ended=true;
          x=savex=0;
        }
      }
 else       if (i >= samples - gap * sampleRate / 1000) {
        note_ending=true;
        savex=x;
      }
    }
    String s=new Integer(x).toString();
    traceport.send(create(s));
    buf[curSlot + 1]=(byte)(x % 256);
    buf[curSlot + 0]=(byte)(x / 256);
    curSlot+=2;
    if (curSlot >= buf.length) {
      outport.send(create(buf));
      buf=new byte[bufferSize];
      curSlot=0;
    }
  }
}

Fixed version (ground truth):
void buildNote(final int note,final int duration,final float sampleRate){
  double RAD=2.0 * Math.PI;
  int gap=25;
  int samples=(int)(duration * sampleRate / 1000);
  boolean note_ending=false, note_ended=false;
  int savex=0;
  for (int i=0; i < samples; i++) {
    if (note == 0) {
      x=0;
    }
 else     if (!note_ended) {
      x=(int)(32767.0 * Math.sin(RAD * note * i / sampleRate));
      if (note_ending) {
        if (Math.signum(x) != Math.signum(savex)) {
          note_ended=true;
          x=savex=0;
        }
      }
 else       if (i >= samples - gap * sampleRate / 1000) {
        note_ending=true;
        savex=x;
      }
    }
    String s=new Integer(x).toString();
    buf[curSlot + 1]=(byte)(x % 256);
    buf[curSlot + 0]=(byte)(x / 256);
    curSlot+=2;
    if (curSlot >= buf.length) {
      outport.send(create(buf));
      buf=new byte[bufferSize];
      curSlot=0;
    }
  }
}
Program: 167672
Project: 167672
Buggy source:
@Override protected void define(){
  component("String_Node_Str",com.jpmorrsn.fbp.components.ReadFile.class);
  component("String_Node_Str",Text2IntArray.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.WriteToConsole.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.SoundMixer.class);
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  initialize("String_Node_Str".replace("String_Node_Str",File.separator),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override protected void define(){
  component("String_Node_Str",com.jpmorrsn.fbp.components.ReadFile.class);
  component("String_Node_Str",Text2IntArray.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.SoundMixer.class);
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  initialize("String_Node_Str".replace("String_Node_Str",File.separator),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect("String_Node_Str","String_Node_Str");
  initialize("String_Node_Str","String_Node_Str");
}
Program: 167673
Project: 167673
Buggy source:
@Override protected void define(){
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells2.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells3.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells4.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.SoundMixer.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.WriteToConsole.class);
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  initialize("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override protected void define(){
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells2.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells3.class);
  component("String_Node_Str",com.jpmorrsn.fbp.examples.components.JingleBells4.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.GenSamples.class);
  component("String_Node_Str",com.jpmorrsn.fbp.components.SoundMixer.class);
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect(component("String_Node_Str"),port("String_Node_Str"),component("String_Node_Str"),port("String_Node_Str"));
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  connect("String_Node_Str","String_Node_Str");
  initialize("String_Node_Str","String_Node_Str");
}
Program: 167674
Project: 167674
Buggy source:
public int[] read() throws InterruptedException, IOException {
  initializeConnection();
  ActionDecoder decoder=new ActionDecoder();
  final int[][] key={null};
  readingThread=Thread.currentThread();
  Consumer<Signal> prevHandler=connection.getSignalHandler();
  connection.setSignalHandler(interruptHandler);
  CountDownLatch latch=new CountDownLatch(1);
  Attributes attributes=connection.enterRawMode();
  connection.setStdinHandler(keys -> {
    decoder.add(keys);
    if (decoder.hasNext()) {
      key[0]=decoder.next().buffer().array();
      latch.countDown();
    }
  }
);
  try {
    latch.await();
  }
  finally {
    connection.setStdinHandler(null);
    connection.setSignalHandler(prevHandler);
    readingThread=null;
  }
  return key[0];
}

Fixed version (ground truth):
public int[] read() throws InterruptedException, IOException {
  initializeConnection();
  ActionDecoder decoder=new ActionDecoder();
  final int[][] key={null};
  readingThread=Thread.currentThread();
  Consumer<Signal> prevHandler=connection.getSignalHandler();
  connection.setSignalHandler(interruptHandler);
  CountDownLatch latch=new CountDownLatch(1);
  Attributes attributes=connection.enterRawMode();
  connection.setStdinHandler(keys -> {
    decoder.add(keys);
    if (decoder.hasNext()) {
      key[0]=decoder.next().buffer().array();
      connection.setStdinHandler(null);
      latch.countDown();
    }
  }
);
  try {
    latch.await();
  }
  finally {
    connection.setSignalHandler(prevHandler);
    connection.setAttributes(attributes);
    readingThread=null;
  }
  return key[0];
}
Program: 167675
Project: 167675
Buggy source:
private static void addInterfaces(Class<?> c,Set<Class<?>> interfaces){
  for (  Class<?> i : c.getInterfaces()) {
    if (!interfaces.contains(i)) {
      interfaces.add(i);
      addInterfaces(i,interfaces);
    }
  }
}

Fixed version (ground truth):
private static void addInterfaces(Class<?> c,List<Class<?>> interfaces){
  for (  Class<?> i : c.getInterfaces()) {
    if (!interfaces.contains(i)) {
      interfaces.add(i);
      addInterfaces(i,interfaces);
    }
  }
}
Program: 167676
Project: 167676
Buggy source:
@Override public void handle(CommandContext ctx) throws CommandLineException {
  final ParsedCommandLine line=ctx.getParsedCommandLine();
  if (line.getFormat() == CommandFormat.INSTANCE) {
    if (line.hasProperty("String_Node_Str") || line.hasProperty("String_Node_Str")) {
      registration.handle(line);
      return;
    }
    final String cmd=line.getOperationName();
    if ("String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd)) {
      registration.handle(line);
    }
 else {
      addLine(line);
    }
  }
 else {
    addLine(line);
  }
}

Fixed version (ground truth):
@Override public void handle(CommandContext ctx) throws CommandLineException {
  final ParsedCommandLine line=ctx.getParsedCommandLine();
  if (line.getFormat() == CommandFormat.INSTANCE) {
    if (line.hasProperty("String_Node_Str") || line.hasProperty("String_Node_Str")) {
      registration.handle(line);
      return;
    }
    final String cmd=line.getOperationName();
    if ("String_Node_Str".equals(cmd)) {
      throw new CommandFormatException("String_Node_Str");
    }
    if ("String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd)) {
      registration.handle(line);
    }
 else {
      addLine(line);
    }
  }
 else {
    addLine(line);
  }
}
Program: 167677
Project: 167677
Buggy source:
@Override public void handle(CommandContext ctx) throws CommandLineException {
  final ParsedCommandLine line=ctx.getParsedCommandLine();
  if (line.getFormat() == CommandFormat.INSTANCE) {
    if (line.hasProperty("String_Node_Str") || line.hasProperty("String_Node_Str")) {
      registration.handle(line);
      return;
    }
    final String cmd=line.getOperationName();
    if ("String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd)) {
      registration.handle(line);
    }
 else {
      addLine(line.getOriginalLine());
    }
  }
 else {
    addLine(line.getOriginalLine());
  }
}

Fixed version (ground truth):
@Override public void handle(CommandContext ctx) throws CommandLineException {
  final ParsedCommandLine line=ctx.getParsedCommandLine();
  if (line.getFormat() == CommandFormat.INSTANCE) {
    if (line.hasProperty("String_Node_Str") || line.hasProperty("String_Node_Str")) {
      registration.handle(line);
      return;
    }
    final String cmd=line.getOperationName();
    if ("String_Node_Str".equals(cmd)) {
      throw new CommandFormatException("String_Node_Str");
    }
    if ("String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd) || "String_Node_Str".equals(cmd)) {
      registration.handle(line);
    }
 else {
      addLine(line.getOriginalLine());
    }
  }
 else {
    addLine(line.getOriginalLine());
  }
}
Program: 167678
Project: 167678
Buggy source:
private void resetArgs(String cmdLine) throws CommandFormatException {
  if (cmdLine != null) {
    parsedCmd.parse(prefix,cmdLine,this);
    setOutputTarget(parsedCmd.getOutputTarget());
  }
  this.cmdLine=cmdLine;
}

Fixed version (ground truth):
private void resetArgs(String cmdLine) throws CommandFormatException {
  if (cmdLine != null) {
    parsedCmd.parse(prefix,cmdLine,this,redirection != null);
    setOutputTarget(parsedCmd.getOutputTarget());
  }
  this.cmdLine=cmdLine;
}
Program: 167679
Project: 167679
Buggy source:
public static SubstitutedLine parseLine(String commandLine,final CommandLineParser.CallbackHandler handler,boolean strict,CommandContext ctx) throws CommandFormatException {
  if (commandLine == null) {
    return null;
  }
  final ParsingStateCallbackHandler callbackHandler=getCallbackHandler(handler);
  return StateParser.parseLine(commandLine,callbackHandler,InitialState.INSTANCE,strict,ctx);
}

Fixed version (ground truth):
public static SubstitutedLine parseLine(String commandLine,final CommandLineParser.CallbackHandler handler,boolean strict,CommandContext ctx,boolean disableResolutionException) throws CommandFormatException {
  if (commandLine == null) {
    return null;
  }
  final ParsingStateCallbackHandler callbackHandler=getCallbackHandler(handler);
  return StateParser.parseLine(commandLine,callbackHandler,InitialState.INSTANCE,strict,disableResolutionException,ctx);
}
Program: 167680
Project: 167680
Buggy source:
/** 
 * Returns the string which was actually parsed with all the substitutions performed
 */
protected static SubstitutedLine doParse(String str,ParsingStateCallbackHandler callbackHandler,ParsingState initialState,boolean strict,CommandContext cmdCtx) throws CommandFormatException {
  if (str == null || str.isEmpty()) {
    return new SubstitutedLine(str);
  }
  ParsingContextImpl ctx=new ParsingContextImpl();
  ctx.initialState=initialState;
  ctx.callbackHandler=callbackHandler;
  ctx.input=str;
  ctx.strict=strict;
  ctx.cmdCtx=cmdCtx;
  ctx.substitued.substitued=ctx.parse();
  return ctx.substitued;
}

Fixed version (ground truth):
/** 
 * Returns the string which was actually parsed with all the substitutions performed
 */
protected static SubstitutedLine doParse(String str,ParsingStateCallbackHandler callbackHandler,ParsingState initialState,boolean strict,boolean disableResolutionException,CommandContext cmdCtx) throws CommandFormatException {
  if (str == null || str.isEmpty()) {
    return new SubstitutedLine(str);
  }
  ParsingContextImpl ctx=new ParsingContextImpl();
  ctx.initialState=initialState;
  ctx.callbackHandler=callbackHandler;
  ctx.input=str;
  ctx.strict=strict;
  ctx.cmdCtx=cmdCtx;
  ctx.disableResolutionException=disableResolutionException;
  ctx.substitued.substitued=ctx.parse();
  return ctx.substitued;
}
Program: 167681
Project: 167681
Buggy source:
private void substituteVariable(boolean exceptionIfNotResolved) throws UnresolvedVariableException {
  int endIndex=location + 1;
  char c=input.charAt(endIndex);
  if (endIndex >= input.length() || !(Character.isJavaIdentifierStart(c) && c != '$')) {
    return;
  }
  while (++endIndex < input.length()) {
    c=input.charAt(endIndex);
    if (!(Character.isJavaIdentifierPart(c) && c != '$')) {
      break;
    }
  }
  final String name=input.substring(location + 1,endIndex);
  final String value=cmdCtx == null ? null : cmdCtx.getVariable(name);
  if (value == null) {
    if (exceptionIfNotResolved) {
      throw new UnresolvedVariableException(name,"String_Node_Str" + name);
    }
  }
 else {
    substitued.add("String_Node_Str" + name,value,location);
    StringBuilder buf=new StringBuilder(input.length() - name.length() + value.length());
    buf.append(input.substring(0,location)).append(value);
    if (endIndex < input.length()) {
      buf.append(input.substring(endIndex));
    }
    input=buf.toString();
    ch=input.charAt(location);
  }
}

Fixed version (ground truth):
private void substituteVariable(boolean exceptionIfNotResolved) throws UnresolvedVariableException {
  int endIndex=location + 1;
  char c=input.charAt(endIndex);
  if (endIndex >= input.length() || !(Character.isJavaIdentifierStart(c) && c != '$')) {
    return;
  }
  while (++endIndex < input.length()) {
    c=input.charAt(endIndex);
    if (!(Character.isJavaIdentifierPart(c) && c != '$')) {
      break;
    }
  }
  final String name=input.substring(location + 1,endIndex);
  final String value=cmdCtx == null ? null : cmdCtx.getVariable(name);
  if (value == null) {
    if (exceptionIfNotResolved && !disableResolutionException) {
      throw new UnresolvedVariableException(name,"String_Node_Str" + name);
    }
  }
 else {
    substitued.add("String_Node_Str" + name,value,location);
    StringBuilder buf=new StringBuilder(input.length() - name.length() + value.length());
    buf.append(input.substring(0,location)).append(value);
    if (endIndex < input.length()) {
      buf.append(input.substring(endIndex));
    }
    input=buf.toString();
    ch=input.charAt(location);
  }
}
Program: 167682
Project: 167682
Buggy source:
public static SubstitutedLine parseLine(String str,ParsingStateCallbackHandler callbackHandler,ParsingState initialState,boolean strict,CommandContext ctx) throws CommandFormatException {
  try {
    return doParse(str,callbackHandler,initialState,strict,ctx);
  }
 catch (  CommandFormatException e) {
    throw e;
  }
catch (  Throwable t) {
    throw new CommandFormatException("String_Node_Str" + str + "String_Node_Str",t);
  }
}

Fixed version (ground truth):
public static SubstitutedLine parseLine(String str,ParsingStateCallbackHandler callbackHandler,ParsingState initialState,boolean strict,boolean disableResolutionException,CommandContext ctx) throws CommandFormatException {
  try {
    return doParse(str,callbackHandler,initialState,strict,disableResolutionException,ctx);
  }
 catch (  CommandFormatException e) {
    throw e;
  }
catch (  Throwable t) {
    throw new CommandFormatException("String_Node_Str" + str + "String_Node_Str",t);
  }
}
Program: 167683
Project: 167683
Buggy source:
@Test public void testForIf() throws Exception {
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  try {
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    checkEmpty();
  }
  finally {
    removeProperties();
  }
}

Fixed version (ground truth):
@Test public void testForIf() throws Exception {
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  addProperty("String_Node_Str","String_Node_Str");
  try {
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    cli.sendLine("String_Node_Str");
    checkEmpty();
  }
  finally {
    removeProperties();
  }
}
Program: 167687
Project: 167687
Buggy source:
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final String originalLine=ctx.getParsedCommandLine().getOriginalLine();
  boolean skipWS;
  int wordCount;
  if (Character.isWhitespace(originalLine.charAt(0))) {
    skipWS=true;
    wordCount=0;
  }
 else {
    skipWS=false;
    wordCount=1;
  }
  int cmdStart=1;
  while (cmdStart < originalLine.length()) {
    if (skipWS) {
      if (!Character.isWhitespace(originalLine.charAt(cmdStart))) {
        skipWS=false;
        ++wordCount;
        if (wordCount == 2) {
          break;
        }
      }
    }
 else     if (Character.isWhitespace(originalLine.charAt(cmdStart))) {
      skipWS=true;
    }
    ++cmdStart;
  }
  final String cmd;
  if (wordCount == 1) {
    cmd="String_Node_Str";
  }
 else   if (wordCount != 2) {
    return -1;
  }
 else {
    cmd=originalLine.substring(cmdStart);
  }
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=originalLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=originalLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}

Fixed version (ground truth):
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final String substituedLine=ctx.getParsedCommandLine().getSubstitutedLine();
  boolean skipWS;
  int wordCount;
  if (Character.isWhitespace(substituedLine.charAt(0))) {
    skipWS=true;
    wordCount=0;
  }
 else {
    skipWS=false;
    wordCount=1;
  }
  int cmdStart=1;
  while (cmdStart < substituedLine.length()) {
    if (skipWS) {
      if (!Character.isWhitespace(substituedLine.charAt(cmdStart))) {
        skipWS=false;
        ++wordCount;
        if (wordCount == 2) {
          break;
        }
      }
    }
 else     if (Character.isWhitespace(substituedLine.charAt(cmdStart))) {
      skipWS=true;
    }
    ++cmdStart;
  }
  final String cmd;
  if (wordCount == 1) {
    cmd="String_Node_Str";
  }
 else   if (wordCount != 2) {
    return -1;
  }
 else {
    cmd=substituedLine.substring(cmdStart);
  }
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=substituedLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=substituedLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}
Program: 167688
Project: 167688
Buggy source:
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final String lnStr=ln.getValue(ctx.getParsedCommandLine());
  if (lnStr == null) {
    return -1;
  }
  final String originalLine=ctx.getParsedCommandLine().getOriginalLine();
  boolean skipWS;
  int wordCount;
  if (Character.isWhitespace(originalLine.charAt(0))) {
    skipWS=true;
    wordCount=0;
  }
 else {
    skipWS=false;
    wordCount=1;
  }
  int cmdStart=1;
  while (cmdStart < originalLine.length()) {
    if (skipWS) {
      if (!Character.isWhitespace(originalLine.charAt(cmdStart))) {
        skipWS=false;
        ++wordCount;
        if (wordCount == 3) {
          break;
        }
      }
    }
 else     if (Character.isWhitespace(originalLine.charAt(cmdStart))) {
      skipWS=true;
    }
    ++cmdStart;
  }
  final String cmd;
  if (wordCount == 2) {
    cmd="String_Node_Str";
  }
 else   if (wordCount != 3) {
    return -1;
  }
 else {
    cmd=originalLine.substring(cmdStart);
  }
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=originalLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=originalLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}

Fixed version (ground truth):
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final String lnStr=ln.getValue(ctx.getParsedCommandLine());
  if (lnStr == null) {
    return -1;
  }
  final String substitutedLine=ctx.getParsedCommandLine().getSubstitutedLine();
  boolean skipWS;
  int wordCount;
  if (Character.isWhitespace(substitutedLine.charAt(0))) {
    skipWS=true;
    wordCount=0;
  }
 else {
    skipWS=false;
    wordCount=1;
  }
  int cmdStart=1;
  while (cmdStart < substitutedLine.length()) {
    if (skipWS) {
      if (!Character.isWhitespace(substitutedLine.charAt(cmdStart))) {
        skipWS=false;
        ++wordCount;
        if (wordCount == 3) {
          break;
        }
      }
    }
 else     if (Character.isWhitespace(substitutedLine.charAt(cmdStart))) {
      skipWS=true;
    }
    ++cmdStart;
  }
  final String cmd;
  if (wordCount == 2) {
    cmd="String_Node_Str";
  }
 else   if (wordCount != 3) {
    return -1;
  }
 else {
    cmd=substitutedLine.substring(cmdStart);
  }
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=substitutedLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=substitutedLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}
Program: 167691
Project: 167691
Buggy source:
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  final String lnStr=of.getValue(args);
  if (lnStr == null) {
    return -1;
  }
  final String originalLine=args.getOriginalLine();
  String conditionStr;
  try {
    conditionStr=condition.getValue(args,true);
  }
 catch (  CommandFormatException e) {
    return -1;
  }
  int i=originalLine.indexOf(conditionStr);
  if (i < 0) {
    return -1;
  }
  i=originalLine.indexOf("String_Node_Str",i + conditionStr.length());
  if (i < 0) {
    return -1;
  }
  final String cmd=originalLine.substring(i + 3);
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=originalLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=originalLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}

Fixed version (ground truth):
@Override public int complete(CommandContext ctx,String buffer,int cursor,List<String> candidates){
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  final String lnStr=of.getValue(args);
  if (lnStr == null) {
    return -1;
  }
  final String substitutedLine=args.getSubstitutedLine();
  String conditionStr;
  try {
    conditionStr=condition.getValue(args,true);
  }
 catch (  CommandFormatException e) {
    return -1;
  }
  int i=substitutedLine.indexOf(conditionStr);
  if (i < 0) {
    return -1;
  }
  i=substitutedLine.indexOf("String_Node_Str",i + conditionStr.length());
  if (i < 0) {
    return -1;
  }
  final String cmd=substitutedLine.substring(i + 3);
  int cmdResult=ctx.getDefaultCommandCompleter().complete(ctx,cmd,cmd.length(),candidates);
  if (cmdResult < 0) {
    return cmdResult;
  }
  int escapeCorrection=0;
  int start=substitutedLine.length() - 1 - buffer.length();
  while (start - escapeCorrection >= 0) {
    final char ch=substitutedLine.charAt(start - escapeCorrection);
    if (Character.isWhitespace(ch) || ch == '=') {
      break;
    }
    ++escapeCorrection;
  }
  return buffer.length() + escapeCorrection - (cmd.length() - cmdResult);
}