Program: 62566
Project: 62566
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void generate(HmDevice device){
  ThingTypeUID thingTypeUID=UidUtils.generateThingTypeUID(device);
  ThingType tt=thingTypeProvider.getThingType(thingTypeUID,Locale.getDefault());
  if (tt == null || device.isGatewayExtras()) {
    logger.debug("String_Node_Str",device.getType(),device.getDatapointCount());
    List<ChannelGroupType> groupTypes=new ArrayList<ChannelGroupType>();
    for (    HmChannel channel : device.getChannels()) {
      List<ChannelDefinition> channelDefinitions=new ArrayList<ChannelDefinition>();
      for (      HmDatapoint dp : channel.getDatapoints().values()) {
        if (!isStatusDatapoint(dp) && !isIgnoredDatapoint(dp)) {
          if (dp.getParamsetType() == HmParamsetType.VALUES) {
            ChannelTypeUID channelTypeUID=UidUtils.generateChannelTypeUID(dp);
            ChannelType channelType=channelTypeProvider.getChannelType(channelTypeUID,Locale.getDefault());
            if (channelType == null) {
              channelType=createChannelType(dp,channelTypeUID);
              channelTypeProvider.addChannelType(channelType);
            }
            ChannelDefinition channelDef=new ChannelDefinition(dp.getName(),channelType.getUID());
            channelDefinitions.add(channelDef);
          }
        }
      }
      ChannelGroupTypeUID groupTypeUID=UidUtils.generateChannelGroupTypeUID(channel);
      ChannelGroupType groupType=channelTypeProvider.getChannelGroupType(groupTypeUID,Locale.getDefault());
      if (groupType == null || device.isGatewayExtras()) {
        String groupLabel=String.format("String_Node_Str",WordUtils.capitalizeFully(StringUtils.replace(channel.getType(),"String_Node_Str","String_Node_Str")));
        groupType=new ChannelGroupType(groupTypeUID,false,groupLabel,null,channelDefinitions);
        channelTypeProvider.addChannelGroupType(groupType);
        groupTypes.add(groupType);
      }
    }
    tt=createThingType(device,groupTypes);
    thingTypeProvider.addThingType(tt);
  }
  addFirmware(device);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void generate(HmDevice device){
  if (thingTypeProvider != null) {
    ThingTypeUID thingTypeUID=UidUtils.generateThingTypeUID(device);
    ThingType tt=thingTypeProvider.getThingType(thingTypeUID,Locale.getDefault());
    if (tt == null || device.isGatewayExtras()) {
      logger.debug("String_Node_Str",device.getType(),device.getDatapointCount());
      List<ChannelGroupType> groupTypes=new ArrayList<ChannelGroupType>();
      for (      HmChannel channel : device.getChannels()) {
        List<ChannelDefinition> channelDefinitions=new ArrayList<ChannelDefinition>();
        for (        HmDatapoint dp : channel.getDatapoints().values()) {
          if (!isStatusDatapoint(dp) && !isIgnoredDatapoint(dp)) {
            if (dp.getParamsetType() == HmParamsetType.VALUES) {
              ChannelTypeUID channelTypeUID=UidUtils.generateChannelTypeUID(dp);
              ChannelType channelType=channelTypeProvider.getChannelType(channelTypeUID,Locale.getDefault());
              if (channelType == null) {
                channelType=createChannelType(dp,channelTypeUID);
                channelTypeProvider.addChannelType(channelType);
              }
              ChannelDefinition channelDef=new ChannelDefinition(dp.getName(),channelType.getUID());
              channelDefinitions.add(channelDef);
            }
          }
        }
        ChannelGroupTypeUID groupTypeUID=UidUtils.generateChannelGroupTypeUID(channel);
        ChannelGroupType groupType=channelTypeProvider.getChannelGroupType(groupTypeUID,Locale.getDefault());
        if (groupType == null || device.isGatewayExtras()) {
          String groupLabel=String.format("String_Node_Str",WordUtils.capitalizeFully(StringUtils.replace(channel.getType(),"String_Node_Str","String_Node_Str")));
          groupType=new ChannelGroupType(groupTypeUID,false,groupLabel,null,channelDefinitions);
          channelTypeProvider.addChannelGroupType(groupType);
          groupTypes.add(groupType);
        }
      }
      tt=createThingType(device,groupTypes);
      thingTypeProvider.addThingType(tt);
    }
    addFirmware(device);
  }
}