Program: 62594
Project: 62594
Buggy source:
private void buildChannel(){
  try {
    HarmonyConfig config=getCachedConfig();
    List<Activity> activities=config.getActivities();
    Collections.sort(activities,new Comparator<Activity>(){
      @Override public int compare(      Activity a1,      Activity a2){
        int o1=a1.getActivityOrder() == null ? -1 : a1.getActivityOrder().intValue();
        int o2=a2.getActivityOrder() == null ? -1 : a2.getActivityOrder().intValue();
        return (o1 < o2) ? -1 : (o1 == o2) ? 0 : 1;
      }
    }
);
    List<StateOption> states=new LinkedList<StateOption>();
    for (    Activity activity : activities) {
      states.add(new StateOption(String.valueOf(activity.getLabel()),activity.getLabel()));
    }
    ChannelTypeUID channelTypeUID=new ChannelTypeUID(HarmonyHubBindingConstants.BINDING_ID + "String_Node_Str" + HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY);
    ChannelType channelType=new ChannelType(channelTypeUID,true,"String_Node_Str","String_Node_Str","String_Node_Str",null,null,new StateDescription(null,null,null,"String_Node_Str",false,states),new URI(HarmonyHubBindingConstants.BINDING_ID,HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY,null));
    factory.addChannelType(channelType);
    BridgeBuilder thingBuilder=editThing();
    Channel channel=ChannelBuilder.create(new ChannelUID(getThing().getUID(),HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY),"String_Node_Str").withType(channelTypeUID).build();
    thingBuilder.withChannel(channel);
    updateThing(thingBuilder.build());
  }
 catch (  Exception e) {
    logger.debug("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void buildChannel(){
  try {
    HarmonyConfig config=getCachedConfig();
    List<Activity> activities=config.getActivities();
    Collections.sort(activities,new Comparator<Activity>(){
      @Override public int compare(      Activity a1,      Activity a2){
        int o1=a1.getActivityOrder() == null ? -1 : a1.getActivityOrder().intValue();
        int o2=a2.getActivityOrder() == null ? -1 : a2.getActivityOrder().intValue();
        return (o1 < o2) ? -1 : (o1 == o2) ? 0 : 1;
      }
    }
);
    List<StateOption> states=new LinkedList<StateOption>();
    for (    Activity activity : activities) {
      states.add(new StateOption(String.valueOf(activity.getLabel()),activity.getLabel()));
    }
    ChannelTypeUID channelTypeUID=new ChannelTypeUID(getThing().getUID() + "String_Node_Str" + HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY);
    ChannelType channelType=new ChannelType(channelTypeUID,false,"String_Node_Str","String_Node_Str","String_Node_Str" + getThing().getLabel(),null,null,new StateDescription(null,null,null,"String_Node_Str",false,states),null);
    factory.addChannelType(channelType);
    BridgeBuilder thingBuilder=editThing();
    Channel channel=ChannelBuilder.create(new ChannelUID(getThing().getUID(),HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY),"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",e);
  }
}