nus-yam/ex-repair huggingface dataset:
Program: 198688
Project: 198688
Buggy source:
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeAction(RoutingControlAction.class);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (!HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeActionExcept(RoutingControlAction.class,this);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}
Program: 198689
Project: 198689
Buggy source:
private static void checkTimeValue(int hour,int minute){
  if (hour < 0 || hour > 24) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 60) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}

Fixed version (ground truth):
private static void checkTimeValue(int hour,int minute){
  if (hour < 0 || hour > 23) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 59) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}
Program: 198690
Project: 198690
Buggy source:
private static void checkDurationValue(int hour,int minute){
  if (hour < 0 || hour > 99) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 60) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}

Fixed version (ground truth):
private static void checkDurationValue(int hour,int minute){
  if (hour < 0 || hour > 99) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 59) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}
Program: 198691
Project: 198691
Buggy source:
private static void checkTimeValue(int hour,int minute){
  if (hour < 0 || hour > 24) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 60) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}

Fixed version (ground truth):
private static void checkTimeValue(int hour,int minute){
  if (hour < 0 || hour > 23) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 59) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}
Program: 198692
Project: 198692
Buggy source:
private static void checkDurationValue(int hour,int minute){
  if (hour < 0 || hour > 99) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 60) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}

Fixed version (ground truth):
private static void checkDurationValue(int hour,int minute){
  if (hour < 0 || hour > 99) {
    throw new IllegalArgumentException("String_Node_Str" + hour);
  }
  if (minute < 0 || minute > 59) {
    throw new IllegalArgumentException("String_Node_Str" + minute);
  }
}
Program: 198693
Project: 198693
Buggy source:
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  ActiveSource current=tv.getActiveSource();
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    if (!current.equals(newActive)) {
      boolean notifyInputChange=(mCallback == null);
      tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    }
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    boolean notifyInputChange=(mCallback == null);
    tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    ActiveSource current=tv.getActiveSource();
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}
Program: 198694
Project: 198694
Buggy source:
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,getActivePortId(),false,null));
  }
}

Fixed version (ground truth):
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    setActivePath(newPath);
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,newPath,false,null));
  }
}
Program: 198695
Project: 198695
Buggy source:
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  setPrevPortId(portId);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  setPrevPortId(getActivePortId());
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}
Program: 198696
Project: 198696
Buggy source:
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeAction(RoutingControlAction.class);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (!HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeActionExcept(RoutingControlAction.class,this);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}
Program: 198697
Project: 198697
Buggy source:
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  ActiveSource current=tv.getActiveSource();
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    if (!current.equals(newActive)) {
      boolean notifyInputChange=(mCallback == null);
      tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    }
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    boolean notifyInputChange=(mCallback == null);
    tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    ActiveSource current=tv.getActiveSource();
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}
Program: 198698
Project: 198698
Buggy source:
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,getActivePortId(),false,null));
  }
}

Fixed version (ground truth):
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    setActivePath(newPath);
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,newPath,false,null));
  }
}
Program: 198699
Project: 198699
Buggy source:
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  setPrevPortId(portId);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  setPrevPortId(getActivePortId());
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}
Program: 198700
Project: 198700
Buggy source:
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeAction(RoutingControlAction.class);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (!HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeActionExcept(RoutingControlAction.class,this);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}
Program: 198701
Project: 198701
Buggy source:
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  ActiveSource current=tv.getActiveSource();
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    if (!current.equals(newActive)) {
      boolean notifyInputChange=(mCallback == null);
      tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    }
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles the incoming active source command.
 * @param newActive new active source information
 */
void process(ActiveSource newActive){
  HdmiCecLocalDeviceTv tv=mSource;
  ActiveSource activeSource=tv.getActiveSource();
  if (activeSource.equals(newActive)) {
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    return;
  }
  HdmiCecDeviceInfo device=mService.getDeviceInfo(newActive.logicalAddress);
  if (device == null) {
    tv.startNewDeviceAction(newActive);
  }
  if (!tv.isProhibitMode()) {
    tv.updateActiveSource(newActive);
    boolean notifyInputChange=(mCallback == null);
    tv.updateActiveInput(newActive.physicalAddress,notifyInputChange);
    invokeCallback(HdmiControlManager.RESULT_SUCCESS);
  }
 else {
    ActiveSource current=tv.getActiveSource();
    if (current.logicalAddress == getSourceAddress()) {
      HdmiCecMessage activeSourceCommand=HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress,current.physicalAddress);
      mService.sendCecCommand(activeSourceCommand);
      tv.updateActiveSource(current);
      invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    }
 else {
      HdmiCecMessage routingChange=HdmiCecMessageBuilder.buildRoutingChange(getSourceAddress(),newActive.physicalAddress,current.physicalAddress);
      mService.sendCecCommand(routingChange);
      tv.addAndStartAction(new RoutingControlAction(tv,current.physicalAddress,true,mCallback));
    }
  }
}
Program: 198702
Project: 198702
Buggy source:
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,getActivePortId(),false,null));
  }
}

Fixed version (ground truth):
private void handleNewDeviceAtTheTailOfActivePath(int path){
  if (isTailOfActivePath(path,getActivePath())) {
    removeAction(RoutingControlAction.class);
    int newPath=mService.portIdToPath(getActivePortId());
    setActivePath(newPath);
    mService.sendCecCommand(HdmiCecMessageBuilder.buildRoutingChange(mAddress,getActivePath(),newPath));
    addAndStartAction(new RoutingControlAction(this,newPath,false,null));
  }
}
Program: 198703
Project: 198703
Buggy source:
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  setPrevPortId(portId);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}

Fixed version (ground truth):
@ServiceThreadOnly void updateActiveInput(int path,boolean notifyInputChange){
  assertRunOnServiceThread();
  if (path == getActivePath()) {
    return;
  }
  setPrevPortId(getActivePortId());
  int portId=mService.pathToPortId(path);
  setActivePath(path);
  if (notifyInputChange) {
    ActiveSource activeSource=getActiveSource();
    HdmiCecDeviceInfo info=getDeviceInfo(activeSource.logicalAddress);
    if (info == null) {
      info=new HdmiCecDeviceInfo(Constants.ADDR_INVALID,path,portId,HdmiCecDeviceInfo.DEVICE_RESERVED,0,null);
    }
    mService.invokeInputChangeListener(info);
  }
}
Program: 198704
Project: 198704
Buggy source:
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeAction(RoutingControlAction.class);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean processCommand(HdmiCecMessage cmd){
  int opcode=cmd.getOpcode();
  byte[] params=cmd.getParams();
  if (mState == STATE_WAIT_FOR_ROUTING_INFORMATION && opcode == Constants.MESSAGE_ROUTING_INFORMATION) {
    int routingPath=HdmiUtils.twoBytesToInt(params);
    if (!HdmiUtils.isInActiveRoutingPath(mCurrentRoutingPath,routingPath)) {
      return true;
    }
    mCurrentRoutingPath=routingPath;
    removeActionExcept(RoutingControlAction.class,this);
    addTimer(mState,TIMEOUT_ROUTING_INFORMATION_MS);
    return true;
  }
 else   if (mState == STATE_WAIT_FOR_REPORT_POWER_STATUS && opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
    handleReportPowerStatus(cmd.getParams()[0]);
    return true;
  }
  return false;
}
Program: 198705
Project: 198705
Buggy source:
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}

Fixed version (ground truth):
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  removeRecentTasksForUser(userId);
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}
Program: 198706
Project: 198706
Buggy source:
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}

Fixed version (ground truth):
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  removeRecentTasksForUser(userId);
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}
Program: 198707
Project: 198707
Buggy source:
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}

Fixed version (ground truth):
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
    removeRecentTaskLocked(userId);
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}
Program: 198708
Project: 198708
Buggy source:
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  mStackSupervisor.removeUserLocked(userId);
}

Fixed version (ground truth):
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
    removeRecentTaskLocked(userId);
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  mStackSupervisor.removeUserLocked(userId);
}
Program: 198709
Project: 198709
Buggy source:
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}

Fixed version (ground truth):
void finishUserStop(UserStartedState uss){
  final int userId=uss.mHandle.getIdentifier();
  boolean stopped;
  ArrayList<IStopUserCallback> callbacks;
synchronized (this) {
    callbacks=new ArrayList<IStopUserCallback>(uss.mStopCallbacks);
    if (mStartedUsers.get(userId) != uss) {
      stopped=false;
    }
 else     if (uss.mState != UserStartedState.STATE_SHUTDOWN) {
      stopped=false;
    }
 else {
      stopped=true;
      mStartedUsers.remove(userId);
      mUserLru.remove(Integer.valueOf(userId));
      updateStartedUserArrayLocked();
      forceStopUserLocked(userId,"String_Node_Str");
    }
    removeRecentTaskLocked(userId);
  }
  for (int i=0; i < callbacks.size(); i++) {
    try {
      if (stopped)       callbacks.get(i).userStopped(userId);
 else       callbacks.get(i).userStopAborted(userId);
    }
 catch (    RemoteException e) {
    }
  }
  if (stopped) {
    mSystemServiceManager.cleanupUser(userId);
synchronized (this) {
      mStackSupervisor.removeUserLocked(userId);
    }
  }
}
Program: 198710
Project: 198710
Buggy source:
public synchronized void init(){
  mPtr=nativeOpen();
}

Fixed version (ground truth):
public void init(){
synchronized (mLock) {
    mPtr=nativeOpen();
  }
}
Program: 198711
Project: 198711
Buggy source:
public synchronized int removeStream(int deviceId,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int removeStream(int deviceId,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198712
Project: 198712
Buggy source:
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
      retrieveStreamConfigs(info.getDeviceId());
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + info);
      }
      mCallback.onDeviceAvailable(info,mStreamConfigs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  int deviceId=msg.arg1;
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + deviceId);
  }
  retrieveStreamConfigs(deviceId);
  mCallback.onStreamConfigurationChanged(deviceId,mStreamConfigs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}

Fixed version (ground truth):
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvStreamConfig[] configs;
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
        retrieveStreamConfigsLocked(info.getDeviceId());
        if (DEBUG) {
          Slog.d(TAG,"String_Node_Str" + info);
        }
        configs=mStreamConfigs.get(info.getDeviceId());
      }
      mCallback.onDeviceAvailable(info,configs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  TvStreamConfig[] configs;
  int deviceId=msg.arg1;
synchronized (mLock) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    retrieveStreamConfigsLocked(deviceId);
    configs=mStreamConfigs.get(deviceId);
  }
  mCallback.onStreamConfigurationChanged(deviceId,configs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}
Program: 198713
Project: 198713
Buggy source:
public synchronized int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198714
Project: 198714
Buggy source:
public synchronized void close(){
  if (mPtr != 0l) {
    nativeClose(mPtr);
  }
}

Fixed version (ground truth):
public void close(){
synchronized (mLock) {
    if (mPtr != 0l) {
      nativeClose(mPtr);
    }
  }
}
Program: 198715
Project: 198715
Buggy source:
public synchronized void init(){
  mPtr=nativeOpen();
}

Fixed version (ground truth):
public void init(){
synchronized (mLock) {
    mPtr=nativeOpen();
  }
}
Program: 198716
Project: 198716
Buggy source:
public synchronized int removeStream(int deviceId,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int removeStream(int deviceId,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198717
Project: 198717
Buggy source:
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
      retrieveStreamConfigs(info.getDeviceId());
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + info);
      }
      mCallback.onDeviceAvailable(info,mStreamConfigs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  int deviceId=msg.arg1;
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + deviceId);
  }
  retrieveStreamConfigs(deviceId);
  mCallback.onStreamConfigurationChanged(deviceId,mStreamConfigs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}

Fixed version (ground truth):
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvStreamConfig[] configs;
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
        retrieveStreamConfigsLocked(info.getDeviceId());
        if (DEBUG) {
          Slog.d(TAG,"String_Node_Str" + info);
        }
        configs=mStreamConfigs.get(info.getDeviceId());
      }
      mCallback.onDeviceAvailable(info,configs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  TvStreamConfig[] configs;
  int deviceId=msg.arg1;
synchronized (mLock) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    retrieveStreamConfigsLocked(deviceId);
    configs=mStreamConfigs.get(deviceId);
  }
  mCallback.onStreamConfigurationChanged(deviceId,configs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}
Program: 198718
Project: 198718
Buggy source:
public synchronized int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198719
Project: 198719
Buggy source:
public synchronized void close(){
  if (mPtr != 0l) {
    nativeClose(mPtr);
  }
}

Fixed version (ground truth):
public void close(){
synchronized (mLock) {
    if (mPtr != 0l) {
      nativeClose(mPtr);
    }
  }
}
Program: 198720
Project: 198720
Buggy source:
public synchronized void init(){
  mPtr=nativeOpen();
}

Fixed version (ground truth):
public void init(){
synchronized (mLock) {
    mPtr=nativeOpen();
  }
}
Program: 198721
Project: 198721
Buggy source:
public synchronized int removeStream(int deviceId,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int removeStream(int deviceId,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeRemoveStream(mPtr,deviceId,streamConfig.getStreamId()) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198722
Project: 198722
Buggy source:
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
      retrieveStreamConfigs(info.getDeviceId());
      if (DEBUG) {
        Slog.d(TAG,"String_Node_Str" + info);
      }
      mCallback.onDeviceAvailable(info,mStreamConfigs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  int deviceId=msg.arg1;
  if (DEBUG) {
    Slog.d(TAG,"String_Node_Str" + deviceId);
  }
  retrieveStreamConfigs(deviceId);
  mCallback.onStreamConfigurationChanged(deviceId,mStreamConfigs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}

Fixed version (ground truth):
@Override public boolean handleMessage(Message msg){
switch (msg.what) {
case EVENT_DEVICE_AVAILABLE:
{
      TvStreamConfig[] configs;
      TvInputHardwareInfo info=(TvInputHardwareInfo)msg.obj;
synchronized (mLock) {
        retrieveStreamConfigsLocked(info.getDeviceId());
        if (DEBUG) {
          Slog.d(TAG,"String_Node_Str" + info);
        }
        configs=mStreamConfigs.get(info.getDeviceId());
      }
      mCallback.onDeviceAvailable(info,configs);
      break;
    }
case EVENT_DEVICE_UNAVAILABLE:
{
    int deviceId=msg.arg1;
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    mCallback.onDeviceUnavailable(deviceId);
    break;
  }
case EVENT_STREAM_CONFIGURATION_CHANGED:
{
  TvStreamConfig[] configs;
  int deviceId=msg.arg1;
synchronized (mLock) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + deviceId);
    }
    retrieveStreamConfigsLocked(deviceId);
    configs=mStreamConfigs.get(deviceId);
  }
  mCallback.onStreamConfigurationChanged(deviceId,configs);
  break;
}
case EVENT_FIRST_FRAME_CAPTURED:
{
int deviceId=msg.arg1;
int streamId=msg.arg2;
mCallback.onFirstFrameCaptured(deviceId,streamId);
break;
}
default :
Slog.e(TAG,"String_Node_Str" + msg);
return false;
}
return true;
}
Program: 198723
Project: 198723
Buggy source:
public synchronized int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
  if (mPtr == 0) {
    return ERROR_NO_INIT;
  }
  if (mStreamConfigGeneration != streamConfig.getGeneration()) {
    return ERROR_STALE_CONFIG;
  }
  if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
    return SUCCESS;
  }
 else {
    return ERROR_UNKNOWN;
  }
}

Fixed version (ground truth):
public int addStream(int deviceId,Surface surface,TvStreamConfig streamConfig){
synchronized (mLock) {
    if (mPtr == 0) {
      return ERROR_NO_INIT;
    }
    int generation=mStreamConfigGenerations.get(deviceId,0);
    if (generation != streamConfig.getGeneration()) {
      return ERROR_STALE_CONFIG;
    }
    if (nativeAddStream(mPtr,deviceId,streamConfig.getStreamId(),surface) == 0) {
      return SUCCESS;
    }
 else {
      return ERROR_UNKNOWN;
    }
  }
}
Program: 198724
Project: 198724
Buggy source:
public synchronized void close(){
  if (mPtr != 0l) {
    nativeClose(mPtr);
  }
}

Fixed version (ground truth):
public void close(){
synchronized (mLock) {
    if (mPtr != 0l) {
      nativeClose(mPtr);
    }
  }
}
Program: 198725
Project: 198725
Buggy source:
@Override protected void handleSecondaryClick(){
  if (!mState.value) {
    mController.setBluetoothEnabled(true);
  }
  showDetail(true);
}

Fixed version (ground truth):
@Override protected void handleSecondaryClick(){
  showDetail(true);
}
Program: 198726
Project: 198726
Buggy source:
@Override protected void handleSecondaryClick(){
  if (!mState.value) {
    mController.setBluetoothEnabled(true);
  }
  showDetail(true);
}

Fixed version (ground truth):
@Override protected void handleSecondaryClick(){
  showDetail(true);
}