nus-yam/ex-repair huggingface dataset:
Program: 62559
Project: 62559
Buggy source:
@Override protected State getNAThingProperty(String channelId){
  NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_TEMPERATURE:
    return ChannelTypeUtils.toDecimalType(dashboardData.getTemperature());
case CHANNEL_HUMIDITY:
  return ChannelTypeUtils.toDecimalType(dashboardData.getHumidity());
case CHANNEL_TIMEUTC:
return ChannelTypeUtils.toDateTimeType(dashboardData.getTimeUtc());
case CHANNEL_HUMIDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHumidex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_HEATINDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHeatIndex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINT:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINTDEP:
Double dewpoint=WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity());
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPointDep(dashboardData.getTemperature(),dewpoint));
default :
return super.getNAThingProperty(channelId);
}
}

Fixed version (ground truth):
@Override protected State getNAThingProperty(String channelId){
  if (module != null) {
    NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_TEMPERATURE:
      return ChannelTypeUtils.toDecimalType(dashboardData.getTemperature());
case CHANNEL_HUMIDITY:
    return ChannelTypeUtils.toDecimalType(dashboardData.getHumidity());
case CHANNEL_TIMEUTC:
  return ChannelTypeUtils.toDateTimeType(dashboardData.getTimeUtc());
case CHANNEL_HUMIDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHumidex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_HEATINDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHeatIndex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINT:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINTDEP:
Double dewpoint=WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity());
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPointDep(dashboardData.getTemperature(),dewpoint));
}
}
return super.getNAThingProperty(channelId);
}
Program: 62560
Project: 62560
Buggy source:
@Override protected State getNAThingProperty(String channelId){
  NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_WIND_ANGLE:
    return ChannelTypeUtils.toDecimalType(dashboardData.getWindAngle());
case CHANNEL_WIND_STRENGTH:
  return ChannelTypeUtils.toDecimalType(dashboardData.getWindStrength());
case CHANNEL_GUST_ANGLE:
return ChannelTypeUtils.toDecimalType(dashboardData.getGustAngle());
case CHANNEL_GUST_STRENGTH:
return ChannelTypeUtils.toDecimalType(dashboardData.getGustStrength());
default :
return super.getNAThingProperty(channelId);
}
}

Fixed version (ground truth):
@Override protected State getNAThingProperty(String channelId){
  if (module != null) {
    NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_WIND_ANGLE:
      return ChannelTypeUtils.toDecimalType(dashboardData.getWindAngle());
case CHANNEL_WIND_STRENGTH:
    return ChannelTypeUtils.toDecimalType(dashboardData.getWindStrength());
case CHANNEL_GUST_ANGLE:
  return ChannelTypeUtils.toDecimalType(dashboardData.getGustAngle());
case CHANNEL_GUST_STRENGTH:
return ChannelTypeUtils.toDecimalType(dashboardData.getGustStrength());
}
}
return super.getNAThingProperty(channelId);
}
Program: 62561
Project: 62561
Buggy source:
@Override protected State getNAThingProperty(String channelId){
switch (channelId) {
case CHANNEL_RAIN:
    return ChannelTypeUtils.toDecimalType(module.getDashboardData().getRain());
default :
  return super.getNAThingProperty(channelId);
}
}

Fixed version (ground truth):
@Override protected State getNAThingProperty(String channelId){
  if (module != null) {
    NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_RAIN:
      return ChannelTypeUtils.toDecimalType(dashboardData.getRain());
  }
}
return super.getNAThingProperty(channelId);
}
Program: 62562
Project: 62562
Buggy source:
@Override protected State getNAThingProperty(String channelId){
  NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_CO2:
    return ChannelTypeUtils.toDecimalType(dashboardData.getCO2());
case CHANNEL_TEMPERATURE:
  return ChannelTypeUtils.toDecimalType(dashboardData.getTemperature());
case CHANNEL_TIMEUTC:
return ChannelTypeUtils.toDateTimeType(dashboardData.getTimeUtc());
case CHANNEL_HUMIDITY:
return ChannelTypeUtils.toDecimalType(dashboardData.getHumidity());
case CHANNEL_HUMIDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHumidex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_HEATINDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHeatIndex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINT:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINTDEP:
Double dewpoint=WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity());
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPointDep(dashboardData.getTemperature(),dewpoint));
default :
return super.getNAThingProperty(channelId);
}
}

Fixed version (ground truth):
@Override protected State getNAThingProperty(String channelId){
  if (module != null) {
    NADashboardData dashboardData=module.getDashboardData();
switch (channelId) {
case CHANNEL_CO2:
      return ChannelTypeUtils.toDecimalType(dashboardData.getCO2());
case CHANNEL_TEMPERATURE:
    return ChannelTypeUtils.toDecimalType(dashboardData.getTemperature());
case CHANNEL_TIMEUTC:
  return ChannelTypeUtils.toDateTimeType(dashboardData.getTimeUtc());
case CHANNEL_HUMIDITY:
return ChannelTypeUtils.toDecimalType(dashboardData.getHumidity());
case CHANNEL_HUMIDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHumidex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_HEATINDEX:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getHeatIndex(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINT:
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity()));
case CHANNEL_DEWPOINTDEP:
Double dewpoint=WeatherUtils.getDewPoint(dashboardData.getTemperature(),dashboardData.getHumidity());
return ChannelTypeUtils.toDecimalType(WeatherUtils.getDewPointDep(dashboardData.getTemperature(),dewpoint));
}
}
return super.getNAThingProperty(channelId);
}
Program: 62563
Project: 62563
Buggy source:
@Override public void initialize(){
  logger.debug("String_Node_Str");
  MaxCubeBridgeConfiguration configuration=getConfigAs(MaxCubeBridgeConfiguration.class);
  port=configuration.port;
  ipAddress=configuration.ipAddress;
  refreshInterval=configuration.refreshInterval;
  exclusive=configuration.exclusive;
  maxRequestsPerConnection=configuration.maxRequestsPerConnection;
  ntpServer1=configuration.ntpServer1;
  ntpServer2=configuration.ntpServer2;
  logger.debug("String_Node_Str",ipAddress);
  logger.debug("String_Node_Str",port);
  logger.debug("String_Node_Str",refreshInterval);
  logger.debug("String_Node_Str",exclusive);
  logger.debug("String_Node_Str",maxRequestsPerConnection);
  startAutomaticRefresh();
}

Fixed version (ground truth):
@Override public void initialize(){
  logger.debug("String_Node_Str");
  MaxCubeBridgeConfiguration configuration=getConfigAs(MaxCubeBridgeConfiguration.class);
  port=configuration.port;
  ipAddress=configuration.ipAddress;
  refreshInterval=configuration.refreshInterval;
  exclusive=configuration.exclusive;
  maxRequestsPerConnection=configuration.maxRequestsPerConnection;
  ntpServer1=configuration.ntpServer1;
  ntpServer2=configuration.ntpServer2;
  logger.debug("String_Node_Str",ipAddress);
  logger.debug("String_Node_Str",port);
  logger.debug("String_Node_Str",refreshInterval);
  logger.debug("String_Node_Str",exclusive);
  logger.debug("String_Node_Str",maxRequestsPerConnection);
  previousOnline=true;
  startAutomaticRefresh();
}
Program: 62564
Project: 62564
Buggy source:
/** 
 * Registers the DeviceDiscoveryService.
 */
private void registerDeviceDiscoveryService(){
  logger.trace("String_Node_Str",getThing().getUID().getId());
  discoveryService=new HomematicDeviceDiscoveryService(this);
  discoveryServiceRegistration=bundleContext.registerService(DiscoveryService.class.getName(),discoveryService,new Hashtable<String,Object>());
  discoveryService.activate();
}

Fixed version (ground truth):
/** 
 * Registers the DeviceDiscoveryService.
 */
private void registerDeviceDiscoveryService(){
  if (bundleContext != null) {
    logger.trace("String_Node_Str",getThing().getUID().getId());
    discoveryService=new HomematicDeviceDiscoveryService(this);
    discoveryServiceRegistration=bundleContext.registerService(DiscoveryService.class.getName(),discoveryService,new Hashtable<String,Object>());
    discoveryService.activate();
  }
}
Program: 62565
Project: 62565
Buggy source:
/** 
 * Unregisters the DeviceDisoveryService.
 */
private void unregisterDeviceDiscoveryService(){
  if (discoveryServiceRegistration != null) {
    HomematicDeviceDiscoveryService service=(HomematicDeviceDiscoveryService)bundleContext.getService(discoveryServiceRegistration.getReference());
    service.deactivate();
    discoveryServiceRegistration.unregister();
    discoveryServiceRegistration=null;
    discoveryService=null;
  }
}

Fixed version (ground truth):
/** 
 * Unregisters the DeviceDisoveryService.
 */
private void unregisterDeviceDiscoveryService(){
  if (discoveryServiceRegistration != null && bundleContext != null) {
    HomematicDeviceDiscoveryService service=(HomematicDeviceDiscoveryService)bundleContext.getService(discoveryServiceRegistration.getReference());
    service.deactivate();
    discoveryServiceRegistration.unregister();
    discoveryServiceRegistration=null;
    discoveryService=null;
  }
}
Program: 62567
Project: 62567
Buggy source:
@Override public void perform(AbstractDevice device,Item item,String value){
  if (value == null || value.length() != 8) {
    logger.error("String_Node_Str",value);
    return;
  }
  int r=Integer.parseInt(value.substring(2,4),16);
  int g=Integer.parseInt(value.substring(4,6),16);
  int b=Integer.parseInt(value.substring(6,8),16);
  HSBType hsbValue=HSBType.fromRGB(r,g,b);
  ItemCommandEvent event=ItemEventFactory.createCommandEvent(item.getName(),hsbValue,COMMAND_SOURCE);
  eventPublisher.post(event);
}

Fixed version (ground truth):
@Override public void perform(AbstractDevice device,Item item,String value){
  if (value == null || value.length() != 8) {
    logger.error("String_Node_Str",value);
    return;
  }
  int r=Integer.parseInt(value.substring(2,4),16);
  int g=Integer.parseInt(value.substring(4,6),16);
  int b=Integer.parseInt(value.substring(6,8),16);
  ItemCommandEvent event;
  if (r == 0 && g == 0 && b == 0) {
    event=ItemEventFactory.createCommandEvent(item.getName(),OnOffType.OFF,COMMAND_SOURCE);
  }
 else {
    HSBType hsbValue=HSBType.fromRGB(r,g,b);
    event=ItemEventFactory.createCommandEvent(item.getName(),hsbValue,COMMAND_SOURCE);
  }
  eventPublisher.post(event);
}
Program: 62568
Project: 62568
Buggy source:
@Override public StringType getProcessName(int pid) throws DeviceNotFoundException {
  OSProcess process=operatingSystem.getProcess(pid);
  String name=process.getName();
  return new StringType(name);
}

Fixed version (ground truth):
@Override public StringType getProcessName(int pid) throws DeviceNotFoundException {
  OSProcess process=getProcess(pid);
  String name=process.getName();
  return new StringType(name);
}
Program: 62569
Project: 62569
Buggy source:
@Override public StringType getProcessPath(int pid) throws DeviceNotFoundException {
  OSProcess process=operatingSystem.getProcess(pid);
  String path=process.getPath();
  return new StringType(path);
}

Fixed version (ground truth):
@Override public StringType getProcessPath(int pid) throws DeviceNotFoundException {
  OSProcess process=getProcess(pid);
  String path=process.getPath();
  return new StringType(path);
}
Program: 62570
Project: 62570
Buggy source:
@Override public DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException {
  OSProcess process=operatingSystem.getProcess(pid);
  long memortInBytes=process.getResidentSetSize();
  long memoryInMB=getSizeInMB(memortInBytes);
  return new DecimalType(memoryInMB);
}

Fixed version (ground truth):
@Override public DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException {
  OSProcess process=getProcess(pid);
  long memortInBytes=process.getResidentSetSize();
  long memoryInMB=getSizeInMB(memortInBytes);
  return new DecimalType(memoryInMB);
}
Program: 62571
Project: 62571
Buggy source:
@Override public DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException {
  OSProcess process=operatingSystem.getProcess(pid);
  double cpuUsageRaw=(process.getKernelTime() + process.getUserTime()) / process.getUpTime();
  BigDecimal cpuUsage=getPercentsValue(cpuUsageRaw);
  return new DecimalType(cpuUsage);
}

Fixed version (ground truth):
@Override public DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException {
  OSProcess process=getProcess(pid);
  double cpuUsageRaw=(process.getKernelTime() + process.getUserTime()) / process.getUpTime();
  BigDecimal cpuUsage=getPercentsValue(cpuUsageRaw);
  return new DecimalType(cpuUsage);
}
Program: 62572
Project: 62572
Buggy source:
@Override public DecimalType getProcessThreads(int pid) throws DeviceNotFoundException {
  OSProcess process=operatingSystem.getProcess(pid);
  int threadCount=process.getThreadCount();
  return new DecimalType(threadCount);
}

Fixed version (ground truth):
@Override public DecimalType getProcessThreads(int pid) throws DeviceNotFoundException {
  OSProcess process=getProcess(pid);
  int threadCount=process.getThreadCount();
  return new DecimalType(threadCount);
}
Program: 62573
Project: 62573
Buggy source:
@Override public void handleCommand(ChannelUID channelUID,Command command){
  logger.trace("String_Node_Str",command,channelUID);
  Channel channel=getThing().getChannel(channelUID.getId());
  if (channel == null) {
    logger.warn("String_Node_Str",channelUID,getThing());
    return;
  }
  if (!(command instanceof StringType)) {
    logger.warn("String_Node_Str",command,channelUID,getThing());
    return;
  }
  logger.debug("String_Node_Str",command,id > 0 ? 0 : name);
  if (id > 0) {
    bridge.getClient().pressButton(id,command.toString());
  }
 else {
    bridge.getClient().pressButton(name,command.toString());
  }
  updateState(channelUID,UnDefType.UNDEF);
}

Fixed version (ground truth):
@Override public void handleCommand(ChannelUID channelUID,Command command){
  logger.trace("String_Node_Str",command,channelUID);
  Channel channel=getThing().getChannel(channelUID.getId());
  if (channel == null) {
    logger.warn("String_Node_Str",channelUID,getThing());
    return;
  }
  if (command instanceof RefreshType) {
    return;
  }
  if (!(command instanceof StringType)) {
    logger.warn("String_Node_Str",command,channelUID,getThing());
    return;
  }
  logger.debug("String_Node_Str",command,id > 0 ? 0 : name);
  if (id > 0) {
    bridge.getClient().pressButton(id,command.toString());
  }
 else {
    bridge.getClient().pressButton(name,command.toString());
  }
  updateState(channelUID,UnDefType.UNDEF);
}
Program: 62574
Project: 62574
Buggy source:
@Override public void initialize(){
  id=getConfig().as(HarmonyDeviceConfig.class).id;
  name=getConfig().as(HarmonyDeviceConfig.class).name;
  if (!checkConfig()) {
    updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR,"String_Node_Str");
  }
 else {
    logName=id > 0 ? String.valueOf(id) : name;
    logger.debug("String_Node_Str",logName);
    updateDeviceStatus(getBridge().getStatus());
  }
}

Fixed version (ground truth):
@Override public void initialize(){
  id=getConfig().as(HarmonyDeviceConfig.class).id;
  name=getConfig().as(HarmonyDeviceConfig.class).name;
  if (!checkConfig()) {
    updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR,"String_Node_Str");
  }
 else {
    logName=id > 0 ? String.valueOf(id) : name;
    logger.debug("String_Node_Str",logName);
    if (getBridge() != null) {
      updateDeviceStatus(getBridge().getStatus());
    }
  }
}
Program: 62575
Project: 62575
Buggy source:
@Override public void hubDiscoveryFinished(){
  updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR,"String_Node_Str" + config.name);
  retryJob=scheduler.schedule(new Runnable(){
    @Override public void run(){
      initialize();
    }
  }
,RETRY_TIME,TimeUnit.SECONDS);
}

Fixed version (ground truth):
@Override public void hubDiscoveryFinished(){
  setOfflineAndReconnect("String_Node_Str");
}
Program: 62576
Project: 62576
Buggy source:
/** 
 * Connects to a Harmony Hub using credentials obtained through network discovery x
 */
private synchronized void connectToHub(){
  disconnectFromHub();
  final String host=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_HOST);
  final String accountId=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_ACCOUNTID);
  final String sessionId=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_SESSIONID);
  if (host == null || accountId == null || sessionId == null) {
    logger.error("String_Node_Str",host,accountId,sessionId);
    return;
  }
  client=HarmonyClient.getInstance();
  client.addListener(new HarmonyHubListener(){
    @Override public void removeFrom(    HarmonyClient hc){
    }
    @Override public void addTo(    HarmonyClient hc){
      hc.addListener(new ActivityChangeListener(){
        @Override public void activityStarted(        Activity activity){
          updateState(activity);
        }
      }
);
    }
  }
);
  try {
    logger.debug("String_Node_Str",host,sessionId,accountId);
    client.connect(host,new LoginToken(accountId,sessionId));
    heartBeatJob=scheduler.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        try {
          client.sendPing();
        }
 catch (        Exception e) {
          logger.error("String_Node_Str" + host,e);
          setOfflineAndReconnect();
        }
      }
    }
,heartBeatInterval,heartBeatInterval,TimeUnit.SECONDS);
    updateStatus(ThingStatus.ONLINE);
    buildChannel();
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + host,e);
    setOfflineAndReconnect();
  }
}

Fixed version (ground truth):
/** 
 * Connects to a Harmony Hub using credentials obtained through network discovery
 */
private synchronized void connectToHub(){
  disconnectFromHub();
  final String host=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_HOST);
  final String accountId=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_ACCOUNTID);
  final String sessionId=getThing().getProperties().get(HarmonyHubBindingConstants.HUB_PROPERTY_SESSIONID);
  if (host == null || accountId == null || sessionId == null) {
    logger.error("String_Node_Str",host,accountId,sessionId);
    setOfflineAndReconnect("String_Node_Str");
    return;
  }
  client=HarmonyClient.getInstance();
  client.addListener(this);
  try {
    logger.debug("String_Node_Str",host,sessionId,accountId);
    client.connect(host,new LoginToken(accountId,sessionId));
    heartBeatJob=scheduler.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        try {
          client.sendPing();
        }
 catch (        Exception e) {
          logger.error("String_Node_Str" + host,e);
          setOfflineAndReconnect("String_Node_Str");
        }
      }
    }
,heartBeatInterval,heartBeatInterval,TimeUnit.SECONDS);
    updateStatus(ThingStatus.ONLINE);
    buildChannel();
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + host,e);
    setOfflineAndReconnect("String_Node_Str" + e.getMessage());
  }
}
Program: 62577
Project: 62577
Buggy source:
@Override public void run(){
  initialize();
}

Fixed version (ground truth):
@Override public void run(){
  connect();
}
Program: 62578
Project: 62578
Buggy source:
@Override public void hubDiscovered(HarmonyHubDiscoveryResult result){
  logger.debug("String_Node_Str",result.getFriendlyName());
  if (result.getFriendlyName().equalsIgnoreCase(config.name)) {
    disco.removeListener(this);
    disco.stopDiscovery();
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ACCOUNTID,result.getAccountId());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_SESSIONID,result.getSessionID());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_HOST,result.getHost());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ID,result.getId());
    connectToHub();
  }
}

Fixed version (ground truth):
@Override public void hubDiscovered(HarmonyHubDiscoveryResult result){
  logger.debug("String_Node_Str",result.getFriendlyName());
  HarmonyHubConfig config=getConfig().as(HarmonyHubConfig.class);
  if (result.getFriendlyName().equalsIgnoreCase(config.name)) {
    discovery.removeListener(this);
    discovery.stopDiscovery();
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ACCOUNTID,result.getAccountId());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_SESSIONID,result.getSessionID());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_HOST,result.getHost());
    getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ID,result.getId());
    connectToHub();
  }
}
Program: 62579
Project: 62579
Buggy source:
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (command instanceof StringType) {
    try {
      try {
        int actId=Integer.parseInt(command.toString());
        client.startActivity(actId);
      }
 catch (      NumberFormatException ignored) {
        client.startActivityByName(command.toString());
      }
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else   if (command instanceof DecimalType) {
    try {
      client.startActivity(((DecimalType)command).intValue());
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else {
    logger.warn("String_Node_Str",command);
  }
}

Fixed version (ground truth):
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (command instanceof RefreshType) {
    updateState(client.getCurrentActivity());
  }
 else   if (command instanceof StringType) {
    try {
      try {
        int actId=Integer.parseInt(command.toString());
        client.startActivity(actId);
      }
 catch (      NumberFormatException ignored) {
        client.startActivityByName(command.toString());
      }
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else   if (command instanceof DecimalType) {
    try {
      client.startActivity(((DecimalType)command).intValue());
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else {
    logger.warn("String_Node_Str",command);
  }
}
Program: 62580
Project: 62580
Buggy source:
private void setOfflineAndReconnect(){
  disconnectFromHub();
  retryJob=scheduler.schedule(new Runnable(){
    @Override public void run(){
      initialize();
    }
  }
,RETRY_TIME,TimeUnit.SECONDS);
  updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.COMMUNICATION_ERROR);
}

Fixed version (ground truth):
private void setOfflineAndReconnect(String error){
  disconnectFromHub();
  retryJob=scheduler.schedule(new Runnable(){
    @Override public void run(){
      connect();
    }
  }
,RETRY_TIME,TimeUnit.SECONDS);
  updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.COMMUNICATION_ERROR,error);
}
Program: 62581
Project: 62581
Buggy source:
@Override public void addTo(HarmonyClient hc){
  hc.addListener(new ActivityChangeListener(){
    @Override public void activityStarted(    Activity activity){
      updateState(activity);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * HarmonyHubListener interface
 */
@Override public void addTo(HarmonyClient hc){
  hc.addListener(new ActivityChangeListener(){
    @Override public void activityStarted(    Activity activity){
      updateState(activity);
    }
  }
);
}
Program: 62582
Project: 62582
Buggy source:
@Override public void removeFrom(HarmonyClient hc){
}

Fixed version (ground truth):
/** 
 * HarmonyHubListener interface
 */
@Override public void removeFrom(HarmonyClient hc){
}
Program: 62583
Project: 62583
Buggy source:
@Override public void initialize(){
  updateStatus(ThingStatus.INITIALIZING);
  disconnectFromHub();
  final HarmonyHubConfig config=getConfig().as(HarmonyHubConfig.class);
  int discoTime=config.discoveryTimeout > 0 ? config.discoveryTimeout : DISCO_TIME;
  heartBeatInterval=config.heartBeatInterval > 0 ? config.heartBeatInterval : HEARTBEAT_INTERVAL;
  final HarmonyHubDiscovery disco=new HarmonyHubDiscovery(discoTime);
  disco.addListener(new HarmonyHubDiscoveryListener(){
    @Override public void hubDiscoveryFinished(){
      updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR,"String_Node_Str" + config.name);
      retryJob=scheduler.schedule(new Runnable(){
        @Override public void run(){
          initialize();
        }
      }
,RETRY_TIME,TimeUnit.SECONDS);
    }
    @Override public void hubDiscovered(    HarmonyHubDiscoveryResult result){
      logger.debug("String_Node_Str",result.getFriendlyName());
      if (result.getFriendlyName().equalsIgnoreCase(config.name)) {
        disco.removeListener(this);
        disco.stopDiscovery();
        getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ACCOUNTID,result.getAccountId());
        getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_SESSIONID,result.getSessionID());
        getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_HOST,result.getHost());
        getThing().setProperty(HarmonyHubBindingConstants.HUB_PROPERTY_ID,result.getId());
        connectToHub();
      }
    }
  }
);
  disco.startDiscovery();
}

Fixed version (ground truth):
@Override public void initialize(){
  connect();
}
Program: 62584
Project: 62584
Buggy source:
private void disconnectFromHub(){
  if (retryJob != null && !retryJob.isDone()) {
    retryJob.cancel(true);
  }
  if (heartBeatJob != null && !heartBeatJob.isDone()) {
    heartBeatJob.cancel(true);
  }
  if (getClient() != null) {
    getClient().disconnect();
  }
}

Fixed version (ground truth):
private void disconnectFromHub(){
  if (discovery != null) {
    discovery.removeListener(this);
    discovery.stopDiscovery();
    discovery=null;
  }
  if (retryJob != null && !retryJob.isDone()) {
    retryJob.cancel(true);
  }
  if (heartBeatJob != null && !heartBeatJob.isDone()) {
    heartBeatJob.cancel(true);
  }
  if (client != null) {
    client.removeListener(this);
    client.disconnect();
    client=null;
  }
}
Program: 62585
Project: 62585
Buggy source:
@Override public void handleCommand(ChannelUID channelUID,Command command){
  logger.debug("String_Node_Str",channelUID,command);
  if (bridgeHandler != null) {
    try {
      PacketType packetType=RFXComMessageFactory.convertPacketType(channelUID.getThingUID().getThingTypeId().toUpperCase());
      RFXComMessage msg=RFXComMessageFactory.createMessage(packetType);
      List<RFXComValueSelector> supportedValueSelectors=msg.getSupportedOutputValueSelectors();
      RFXComValueSelector valSelector=RFXComValueSelector.getValueSelector(channelUID.getId());
      if (supportedValueSelectors.contains(valSelector)) {
        msg.setSubType(msg.convertSubType(config.subType));
        msg.setDeviceId(config.deviceId);
        msg.convertFromState(valSelector,command);
        bridgeHandler.sendMessage(msg);
      }
 else {
        logger.warn("String_Node_Str",channelUID.getId());
      }
    }
 catch (    RFXComNotImpException e) {
      logger.error("String_Node_Str",e.getMessage());
    }
catch (    RFXComException e) {
      logger.error("String_Node_Str",e.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override public void handleCommand(ChannelUID channelUID,Command command){
  logger.debug("String_Node_Str",channelUID,command);
  if (bridgeHandler != null) {
    if (command instanceof RefreshType) {
    }
 else {
      try {
        PacketType packetType=RFXComMessageFactory.convertPacketType(channelUID.getThingUID().getThingTypeId().toUpperCase());
        RFXComMessage msg=RFXComMessageFactory.createMessage(packetType);
        List<RFXComValueSelector> supportedValueSelectors=msg.getSupportedOutputValueSelectors();
        RFXComValueSelector valSelector=RFXComValueSelector.getValueSelector(channelUID.getId());
        if (supportedValueSelectors.contains(valSelector)) {
          msg.setSubType(msg.convertSubType(config.subType));
          msg.setDeviceId(config.deviceId);
          msg.convertFromState(valSelector,command);
          bridgeHandler.sendMessage(msg);
        }
 else {
          logger.warn("String_Node_Str",channelUID.getId());
        }
      }
 catch (      RFXComNotImpException e) {
        logger.error("String_Node_Str",e.getMessage());
      }
catch (      RFXComException e) {
        logger.error("String_Node_Str",e.getMessage());
      }
    }
  }
}
Program: 62586
Project: 62586
Buggy source:
public static PacketType convertPacketType(String packetType) throws IllegalArgumentException {
  for (  PacketType p : PacketType.values()) {
    if (p.toString().equals(packetType)) {
      return p;
    }
  }
  throw new IllegalArgumentException("String_Node_Str" + packetType);
}

Fixed version (ground truth):
public static PacketType convertPacketType(String packetType) throws IllegalArgumentException {
  for (  PacketType p : PacketType.values()) {
    if (p.toString().replace("String_Node_Str","String_Node_Str").equals(packetType.replace("String_Node_Str","String_Node_Str"))) {
      return p;
    }
  }
  throw new IllegalArgumentException("String_Node_Str" + packetType);
}
Program: 62587
Project: 62587
Buggy source:
@Override public void channelLinked(ChannelUID channelUID){
  linkedChannelChange(channelUID,1);
}

Fixed version (ground truth):
@Override public void channelLinked(ChannelUID channelUID){
  linkedChannelChange(channelUID,1);
  publishChannelIfLinked(channelUID);
}
Program: 62588
Project: 62588
Buggy source:
/** 
 * Iterates all channels of the thing and updates their states.
 */
protected void publishPlanet(){
  logger.debug("String_Node_Str",getPlanet().getClass().getSimpleName(),getThing().getUID());
  for (  Channel channel : getThing().getChannels()) {
    publishChannelIfLinked(channel);
  }
}

Fixed version (ground truth):
/** 
 * Iterates all channels of the thing and updates their states.
 */
protected void publishPlanet(){
  logger.debug("String_Node_Str",getPlanet().getClass().getSimpleName(),getThing().getUID());
  for (  Channel channel : getThing().getChannels()) {
    publishChannelIfLinked(channel.getUID());
  }
}
Program: 62589
Project: 62589
Buggy source:
/** 
 * Publishes the channel with data if it's linked.
 */
private void publishChannelIfLinked(Channel channel){
  if (isLinked(channel.getUID().getId()) && getPlanet() != null) {
    try {
      updateState(channel.getUID(),PropertyUtils.getState(channel.getUID(),getPlanet()));
    }
 catch (    Exception ex) {
      logger.error("String_Node_Str" + channel.getUID() + "String_Node_Str"+ ex.getMessage(),ex);
    }
  }
}

Fixed version (ground truth):
/** 
 * Publishes the channel with data if it's linked.
 */
private void publishChannelIfLinked(ChannelUID channelUID){
  if (isLinked(channelUID.getId()) && getPlanet() != null) {
    try {
      updateState(channelUID,PropertyUtils.getState(channelUID,getPlanet()));
    }
 catch (    Exception ex) {
      logger.error("String_Node_Str" + channelUID + "String_Node_Str"+ ex.getMessage(),ex);
    }
  }
}
Program: 62590
Project: 62590
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (RefreshType.REFRESH == command) {
    logger.debug("String_Node_Str",channelUID);
    publishChannelIfLinked(getThing().getChannel(channelUID.getId()));
  }
 else {
    logger.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (RefreshType.REFRESH == command) {
    logger.debug("String_Node_Str",channelUID);
    publishChannelIfLinked(channelUID);
  }
 else {
    logger.warn("String_Node_Str");
  }
}
Program: 62591
Project: 62591
Buggy source:
public HomekitTaggedItem(Item item,ItemRegistry itemRegistry){
  this.item=item;
  for (  String tag : item.getTags()) {
    if (item instanceof DimmerItem) {
      tag="String_Node_Str" + tag;
    }
    if (!isMemberOfRootGroup(item,itemRegistry)) {
      homekitDeviceType=HomekitDeviceType.valueOfTag(tag);
    }
    if (homekitDeviceType == null) {
      homekitCharacteristicType=HomekitCharacteristicType.valueOfTag(tag);
    }
    if (homekitDeviceType != null || homekitCharacteristicType != null) {
      break;
    }
  }
  if (homekitDeviceType != null) {
    this.id=calculateId(item);
  }
 else {
    this.id=0;
  }
}

Fixed version (ground truth):
public HomekitTaggedItem(Item item,ItemRegistry itemRegistry){
  this.item=item;
  for (  String tag : item.getTags()) {
    if (item instanceof DimmerItem) {
      tag="String_Node_Str" + tag;
    }
    if (isMemberOfRootGroup(item,itemRegistry)) {
      homekitCharacteristicType=HomekitCharacteristicType.valueOfTag(tag);
    }
    if (homekitCharacteristicType == null) {
      homekitDeviceType=HomekitDeviceType.valueOfTag(tag);
    }
    if (homekitDeviceType != null || homekitCharacteristicType != null) {
      break;
    }
  }
  if (homekitDeviceType != null) {
    this.id=calculateId(item);
  }
 else {
    this.id=0;
  }
}
Program: 62595
Project: 62595
Buggy source:
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (command instanceof StringType) {
    try {
      client.startActivityByName(command.toString());
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else   if (command instanceof DecimalType) {
    try {
      client.startActivity(((DecimalType)command).intValue());
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else {
    logger.warn("String_Node_Str",command);
  }
}

Fixed version (ground truth):
@Override public void handleCommand(ChannelUID channelUID,Command command){
  if (command instanceof StringType) {
    try {
      try {
        int actId=Integer.parseInt(command.toString());
        client.startActivity(actId);
      }
 catch (      NumberFormatException ignored) {
        client.startActivityByName(command.toString());
      }
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else   if (command instanceof DecimalType) {
    try {
      client.startActivity(((DecimalType)command).intValue());
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
 else {
    logger.warn("String_Node_Str",command);
  }
}
Program: 62596
Project: 62596
Buggy source:
@Override public void dispose(){
  listeners.clear();
  disconnectFromHub();
}

Fixed version (ground truth):
@Override public void dispose(){
  listeners.clear();
  disconnectFromHub();
  factory.removeChannelTypesForThing(getThing().getUID());
}
Program: 62597
Project: 62597
Buggy source:
/** 
 * Converts an Item to a HueDevice
 * @param item
 * @return HueDevice
 */
private HueDevice itemToDevice(Item item){
  State itemState=item.getState();
  HueState hueState;
  if (itemState instanceof HSBType) {
    HSBType color=(HSBType)itemState;
    hueState=new HueState(color.getHue().intValue(),color.getSaturation().shortValue(),color.getBrightness().shortValue());
  }
 else   if (itemState instanceof DecimalType) {
    short bri=(short)((((DecimalType)itemState).intValue() * 255) / 100);
    hueState=new HueState(bri > 0,bri);
  }
 else   if (itemState instanceof OnOffType) {
    short bri=(short)(((OnOffType)itemState) == OnOffType.ON ? 255 : 0);
    hueState=new HueState(bri > 0,bri);
  }
 else {
    hueState=new HueState(false,(short)0);
  }
  HueDevice d=new HueDevice(hueState,item.getLabel(),item.getName());
  return d;
}

Fixed version (ground truth):
/** 
 * Converts an Item to a HueDevice
 * @param item
 * @return HueDevice
 */
private HueDevice itemToDevice(Item item){
  State itemState=item.getState();
  HueState hueState;
  if (itemState instanceof HSBType) {
    HSBType color=(HSBType)itemState;
    hueState=new HueState(color);
  }
 else   if (itemState instanceof DecimalType) {
    short bri=(short)((((DecimalType)itemState).intValue() * 255) / 100);
    hueState=new HueState(bri);
  }
 else   if (itemState instanceof OnOffType) {
    short bri=(short)(((OnOffType)itemState) == OnOffType.ON ? 255 : 0);
    hueState=new HueState(bri);
  }
 else {
    hueState=new HueState((short)0);
  }
  HueDevice d=new HueDevice(hueState,item.getLabel(),item.getName());
  return d;
}
Program: 62599
Project: 62599
Buggy source:
public HueState(int h,short s,short b){
  super();
  this.on=b > 0;
  this.hue=h;
  this.sat=s;
  this.bri=b;
}

Fixed version (ground truth):
public HueState(HSBType hsb){
  this.on=hsb.getBrightness().intValue() > 0;
  this.hue=hsb.getHue().intValue();
  this.sat=hsb.getSaturation().shortValue();
  this.bri=hsb.intValue() > 0 ? (short)((hsb.intValue() * 255) / 100) : -1;
}
Program: 62600
Project: 62600
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void start() throws IOException {
  logger.debug("String_Node_Str",config.getCallbackPort());
  xmlRpcHTTPD=new XmlRpcHTTPD(config.getCallbackPort());
  xmlRpcHTTPD.start(config.getTimeout() * 1000,true);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void start() throws IOException {
  logger.debug("String_Node_Str",config.getCallbackPort());
  xmlRpcHTTPD=new XmlRpcHTTPD(config.getCallbackPort());
  xmlRpcHTTPD.start(0,true);
}
Program: 62601
Project: 62601
Buggy source:
@Override public void initialize(){
  logger.debug("String_Node_Str");
  String apiBaseUrl=null;
  String apiVersion=null;
  String hardwareVersion=null;
  FreeboxServerConfiguration configuration=getConfigAs(FreeboxServerConfiguration.class);
  String result=HttpUtil.executeUrl("String_Node_Str","String_Node_Str" + configuration.fqdn + "String_Node_Str",5000);
  if (result != null) {
    apiBaseUrl=StringUtils.trim(StringUtils.replace(StringUtils.substringBetween(result,"String_Node_Str","String_Node_Str"),"String_Node_Str","String_Node_Str"));
    apiVersion=StringUtils.trim(StringUtils.substringBetween(result,"String_Node_Str","String_Node_Str"));
    hardwareVersion=StringUtils.trim(StringUtils.substringBetween(result,"String_Node_Str","String_Node_Str"));
  }
  if ((apiBaseUrl != null) && (apiVersion != null) && (hardwareVersion != null)) {
    updateStatus(ThingStatus.OFFLINE);
    logger.debug("String_Node_Str");
    if (authorizeJob == null || authorizeJob.isCancelled()) {
      authorizeJob=scheduler.schedule(authorizeRunnable,1,TimeUnit.SECONDS);
    }
  }
 else {
    updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR);
  }
  Map<String,String> properties=editProperties();
  boolean update=false;
  if ((apiBaseUrl != null) && !apiBaseUrl.isEmpty() && ((properties.get(FreeboxBindingConstants.API_BASE_URL) == null) || !properties.get(FreeboxBindingConstants.API_BASE_URL).equals(apiBaseUrl))) {
    update=true;
    properties.put(FreeboxBindingConstants.API_BASE_URL,apiBaseUrl);
  }
  if ((apiVersion != null) && !apiVersion.isEmpty() && ((properties.get(FreeboxBindingConstants.API_VERSION) == null) || !properties.get(FreeboxBindingConstants.API_VERSION).equals(apiVersion))) {
    update=true;
    properties.put(FreeboxBindingConstants.API_VERSION,apiVersion);
  }
  if ((hardwareVersion != null) && !hardwareVersion.isEmpty() && ((properties.get(Thing.PROPERTY_HARDWARE_VERSION) == null) || !properties.get(Thing.PROPERTY_HARDWARE_VERSION).equals(hardwareVersion))) {
    update=true;
    properties.put(Thing.PROPERTY_HARDWARE_VERSION,hardwareVersion);
  }
  if (update) {
    updateProperties(properties);
  }
}

Fixed version (ground truth):
@Override public void initialize(){
  logger.debug("String_Node_Str");
  FreeboxServerConfiguration configuration=getConfigAs(FreeboxServerConfiguration.class);
  if ((configuration != null) && (configuration.fqdn != null) && !configuration.fqdn.isEmpty()) {
    updateStatus(ThingStatus.OFFLINE);
    logger.debug("String_Node_Str");
    if (authorizeJob == null || authorizeJob.isCancelled()) {
      authorizeJob=scheduler.schedule(authorizeRunnable,1,TimeUnit.SECONDS);
    }
  }
 else {
    updateStatus(ThingStatus.OFFLINE,ThingStatusDetail.CONFIGURATION_ERROR);
  }
}
Program: 62605
Project: 62605
Buggy source:
/** 
 * Gets a SerialMessage with the NAME GET command
 * @return the serial message
 */
public SerialMessage getNameMessage(){
  logger.debug("String_Node_Str",this.getNode().getNodeId());
  SerialMessage result=new SerialMessage(this.getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.ApplicationCommandHandler,SerialMessagePriority.Get);
  byte[] newPayload={(byte)getNode().getNodeId(),2,(byte)getCommandClass().getKey(),(byte)NAME_GET};
  result.setMessagePayload(newPayload);
  return result;
}

Fixed version (ground truth):
/** 
 * Gets a SerialMessage with the NAME GET command
 * @return the serial message
 */
public SerialMessage getNameMessage(){
  logger.debug("String_Node_Str",getNode().getNodeId());
  SerialMessage result=new SerialMessage(getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.ApplicationCommandHandler,SerialMessagePriority.Get);
  byte[] newPayload={(byte)getNode().getNodeId(),2,(byte)getCommandClass().getKey(),(byte)NAME_GET};
  result.setMessagePayload(newPayload);
  return result;
}
Program: 62607
Project: 62607
Buggy source:
/** 
 * {@inheritDoc}
 * @throws ZWaveSerialMessageException
 */
@Override public void handleApplicationCommandRequest(SerialMessage serialMessage,int offset,int endpoint) throws ZWaveSerialMessageException {
  logger.debug("String_Node_Str",this.getNode().getNodeId());
  int command=serialMessage.getMessagePayloadByte(offset);
switch (command) {
case NAME_REPORT:
    logger.trace("String_Node_Str",this.getNode().getNodeId());
  processNameReport(serialMessage,offset,endpoint);
initialiseName=true;
break;
case LOCATION_REPORT:
logger.trace("String_Node_Str",this.getNode().getNodeId());
processLocationReport(serialMessage,offset,endpoint);
initialiseLocation=true;
break;
default :
logger.warn(String.format("String_Node_Str",command,this.getCommandClass().getLabel(),this.getCommandClass().getKey()));
}
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @throws ZWaveSerialMessageException
 */
@Override public void handleApplicationCommandRequest(SerialMessage serialMessage,int offset,int endpoint) throws ZWaveSerialMessageException {
  logger.debug("String_Node_Str",getNode().getNodeId(),getVersion());
  int command=serialMessage.getMessagePayloadByte(offset);
switch (command) {
case NAME_REPORT:
    logger.trace("String_Node_Str",getNode().getNodeId());
  processNameReport(serialMessage,offset,endpoint);
initialiseName=true;
break;
case LOCATION_REPORT:
logger.trace("String_Node_Str",getNode().getNodeId());
processLocationReport(serialMessage,offset,endpoint);
initialiseLocation=true;
break;
default :
logger.warn(String.format("String_Node_Str",command,getCommandClass().getLabel(),getCommandClass().getKey()));
}
}
Program: 62608
Project: 62608
Buggy source:
/** 
 * Gets a SerialMessage with the NAME GET command
 * @return the serial message
 */
public SerialMessage getLocationMessage(){
  logger.debug("String_Node_Str",this.getNode().getNodeId());
  SerialMessage result=new SerialMessage(this.getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.ApplicationCommandHandler,SerialMessagePriority.Get);
  byte[] newPayload={(byte)getNode().getNodeId(),2,(byte)getCommandClass().getKey(),(byte)LOCATION_GET};
  result.setMessagePayload(newPayload);
  return result;
}

Fixed version (ground truth):
/** 
 * Gets a SerialMessage with the NAME GET command
 * @return the serial message
 */
public SerialMessage getLocationMessage(){
  logger.debug("String_Node_Str",getNode().getNodeId());
  SerialMessage result=new SerialMessage(getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.ApplicationCommandHandler,SerialMessagePriority.Get);
  byte[] newPayload={(byte)getNode().getNodeId(),2,(byte)getCommandClass().getKey(),(byte)LOCATION_GET};
  result.setMessagePayload(newPayload);
  return result;
}
Program: 62609
Project: 62609
Buggy source:
/** 
 * Gets a SerialMessage with the Name or Location SET command
 * @param the level to set.
 * @return the serial message
 */
private SerialMessage setValueMessage(String str,int command){
  logger.debug("String_Node_Str",this.getNode().getNodeId(),str);
  byte[] nameBuffer=null;
  byte encoding=ENCODING_ASCII;
  CharsetEncoder asciiEncoder=StandardCharsets.US_ASCII.newEncoder();
  if (asciiEncoder.canEncode(str) == true) {
    nameBuffer=str.getBytes(StandardCharsets.US_ASCII);
  }
 else {
    nameBuffer=str.getBytes(StandardCharsets.UTF_16);
    encoding=ENCODING_UTF16;
  }
  int len=nameBuffer.length;
  if (len > 16) {
    len=16;
  }
  SerialMessage result=new SerialMessage(this.getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.SendData,SerialMessagePriority.Set);
  byte[] newPayload={(byte)this.getNode().getNodeId(),(byte)((byte)len + 3),(byte)getCommandClass().getKey(),(byte)command,encoding};
  byte[] msg=new byte[newPayload.length + len];
  System.arraycopy(newPayload,0,msg,0,newPayload.length);
  System.arraycopy(nameBuffer,0,msg,newPayload.length,len);
  result.setMessagePayload(msg);
  return result;
}

Fixed version (ground truth):
/** 
 * Gets a SerialMessage with the Name or Location SET command
 * @param the level to set.
 * @return the serial message
 */
private SerialMessage setValueMessage(String str,int command){
  logger.debug("String_Node_Str",getNode().getNodeId(),str);
  byte[] nameBuffer=null;
  byte encoding=ENCODING_ASCII;
  CharsetEncoder asciiEncoder=StandardCharsets.US_ASCII.newEncoder();
  if (asciiEncoder.canEncode(str) == true) {
    nameBuffer=str.getBytes(StandardCharsets.US_ASCII);
  }
 else {
    nameBuffer=str.getBytes(StandardCharsets.UTF_16);
    encoding=ENCODING_UTF16;
  }
  int len=nameBuffer.length;
  if (len > 16) {
    len=16;
  }
  SerialMessage result=new SerialMessage(getNode().getNodeId(),SerialMessageClass.SendData,SerialMessageType.Request,SerialMessageClass.SendData,SerialMessagePriority.Set);
  byte[] newPayload={(byte)getNode().getNodeId(),(byte)((byte)len + 3),(byte)getCommandClass().getKey(),(byte)command,encoding};
  byte[] msg=new byte[newPayload.length + len];
  System.arraycopy(newPayload,0,msg,0,newPayload.length);
  System.arraycopy(nameBuffer,0,msg,newPayload.length,len);
  result.setMessagePayload(msg);
  return result;
}
Program: 62610
Project: 62610
Buggy source:
@Override public Collection<SerialMessage> getDynamicValues(boolean refresh){
  ArrayList<SerialMessage> result=new ArrayList<SerialMessage>();
  if (refresh == true) {
    initialiseName=false;
    initialiseLocation=false;
  }
  if (initialiseName == false) {
    result.add(this.getNameMessage());
  }
  if (initialiseLocation == false) {
    result.add(this.getLocationMessage());
  }
  return result;
}

Fixed version (ground truth):
@Override public Collection<SerialMessage> getDynamicValues(boolean refresh){
  ArrayList<SerialMessage> result=new ArrayList<SerialMessage>();
  if (refresh == true) {
    initialiseName=false;
    initialiseLocation=false;
  }
  if (initialiseName == false) {
    result.add(getNameMessage());
  }
  if (initialiseLocation == false) {
    result.add(getLocationMessage());
  }
  return result;
}