Program: 62592
Project: 62592
Buggy source:
/** 
 * Updates our channel with the available buttons as option states
 */
private void updateChannel(){
  try {
    logger.debug("String_Node_Str",logName);
    if (bridge == null) {
      logger.debug("String_Node_Str",logName);
      return;
    }
    HarmonyConfig config=bridge.getCachedConfig();
    if (config == null) {
      logger.debug("String_Node_Str",logName);
      return;
    }
    List<StateOption> states=new LinkedList<StateOption>();
    List<Device> devices=config.getDevices();
    for (    Device device : devices) {
      if (device.getId() != id) {
        continue;
      }
      List<ControlGroup> controlGroups=device.getControlGroup();
      for (      ControlGroup controlGroup : controlGroups) {
        List<Function> functions=controlGroup.getFunction();
        for (        Function function : functions) {
          states.add(new StateOption(String.valueOf(function.getLabel()),function.getLabel()));
        }
      }
      break;
    }
    ThingBuilder thingBuilder=editThing();
    ChannelTypeUID channelTypeUID=new ChannelTypeUID(HarmonyHubBindingConstants.BINDING_ID + "String_Node_Str" + HarmonyHubBindingConstants.CHANNEL_BUTTON_PRESS);
    ChannelType channelType=new ChannelType(channelTypeUID,false,"String_Node_Str","String_Node_Str","String_Node_Str",null,null,new StateDescription(null,null,null,null,false,states),new URI(HarmonyHubBindingConstants.BINDING_ID,HarmonyHubBindingConstants.CHANNEL_BUTTON_PRESS,null));
    factory.addChannelType(channelType);
    Channel channel=ChannelBuilder.create(new ChannelUID(getThing().getUID(),HarmonyHubBindingConstants.CHANNEL_BUTTON_PRESS),"String_Node_Str").withType(channelTypeUID).build();
    thingBuilder.withChannels(channel);
    updateThing(thingBuilder.build());
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str" + logName,e);
  }
}

Fixed version (ground truth):
/** 
 * Updates our channel with the available buttons as option states
 */
private void updateChannel(){
  try {
    logger.debug("String_Node_Str",logName);
    if (bridge == null) {
      logger.debug("String_Node_Str",logName);
      return;
    }
    HarmonyConfig config=bridge.getCachedConfig();
    if (config == null) {
      logger.debug("String_Node_Str",logName);
      return;
    }
    List<StateOption> states=new LinkedList<StateOption>();
    List<Device> devices=config.getDevices();
    for (    Device device : devices) {
      if (device.getId() != id) {
        continue;
      }
      List<ControlGroup> controlGroups=device.getControlGroup();
      for (      ControlGroup controlGroup : controlGroups) {
        List<Function> functions=controlGroup.getFunction();
        for (        Function function : functions) {
          states.add(new StateOption(String.valueOf(function.getLabel()),function.getLabel()));
        }
      }
      break;
    }
    ThingBuilder thingBuilder=editThing();
    ChannelTypeUID channelTypeUID=new ChannelTypeUID(getThing().getUID().getAsString() + "String_Node_Str" + HarmonyHubBindingConstants.CHANNEL_BUTTON_PRESS);
    ChannelType channelType=new ChannelType(channelTypeUID,false,"String_Node_Str","String_Node_Str","String_Node_Str" + getThing().getLabel(),null,null,new StateDescription(null,null,null,null,false,states),null);
    factory.addChannelType(channelType);
    Channel channel=ChannelBuilder.create(new ChannelUID(getThing().getUID(),HarmonyHubBindingConstants.CHANNEL_BUTTON_PRESS),"String_Node_Str").withType(channelTypeUID).build();
    List<Channel> currentChannels=getThing().getChannels();
    List<Channel> newChannels=new ArrayList<Channel>();
    for (    Channel c : currentChannels) {
      if (!c.getUID().equals(channel.getUID())) {
        newChannels.add(c);
      }
    }
    newChannels.add(channel);
    thingBuilder.withChannels(newChannels);
    updateThing(thingBuilder.build());
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str" + logName,e);
  }
}