Program: 102463
Project: 102463
Buggy source:
@Ajax @POST @Resource public Response saveSetting(String params){
  JSON data=new JSON();
  try {
    Map<String,String> datas=parserParams(params);
    Set<String> paramsName=datas.keySet();
    Set<String> channels=new HashSet<String>();
    UserSetting setting=userSettingService.get(getRemoteUser());
    for (    String channel : paramsName) {
      if (channel.startsWith(CHANNEL_PREFIX) && "String_Node_Str".equals((String)datas.get(channel))) {
        String channelId=channel.replaceFirst(CHANNEL_PREFIX,"String_Node_Str");
        channels.add(channelId);
        setting.setChannelActive(channelId);
      }
    }
    for (    String pluginId : paramsName) {
      if (pluginId.indexOf(SELECT_BOX_PREFIX) > 0) {
        String value=datas.get(pluginId);
        pluginId=pluginId.replaceFirst(SELECT_BOX_PREFIX,"String_Node_Str");
        if (WEEKLY.equals(value)) {
          setting.addPlugin(pluginId,FREQUENCY.WEEKLY);
        }
        if (DAILY.equals(value)) {
          setting.addPlugin(pluginId,FREQUENCY.DAILY);
        }
      }
 else       if (!pluginId.startsWith(CHANNEL_PREFIX)) {
        for (        String channelId : channels) {
          if (pluginId.startsWith(channelId)) {
            if (UserSetting.EMAIL_CHANNEL.equals(channelId)) {
              setting.addPlugin(pluginId.replaceFirst(UserSetting.EMAIL_CHANNEL,"String_Node_Str"),FREQUENCY.INSTANTLY);
            }
 else {
              setting.addChannelPlugin(channelId,pluginId.replaceFirst(channelId,"String_Node_Str"));
            }
          }
        }
      }
    }
    userSettingService.save(setting);
    data.set("String_Node_Str","String_Node_Str");
    data.set("String_Node_Str","String_Node_Str");
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    data.set("String_Node_Str","String_Node_Str");
    data.set("String_Node_Str",e.toString());
  }
  return Response.ok(data.toString()).withMimeType("String_Node_Str");
}

Fixed version (ground truth):
@Ajax @POST @Resource public Response saveSetting(String params){
  JSON data=new JSON();
  try {
    Map<String,String> datas=parserParams(params);
    Set<String> paramsName=datas.keySet();
    Set<String> channels=new HashSet<String>();
    UserSetting setting=userSettingService.get(getRemoteUser());
    for (    String channel : paramsName) {
      if (channel.startsWith(CHANNEL_PREFIX) && "String_Node_Str".equals((String)datas.get(channel))) {
        String channelId=channel.replaceFirst(CHANNEL_PREFIX,"String_Node_Str");
        channels.add(channelId);
        setting.setChannelActive(channelId);
      }
    }
    for (    String pluginId : paramsName) {
      if (pluginId.indexOf(SELECT_BOX_PREFIX) > 0) {
        String value=datas.get(pluginId);
        pluginId=pluginId.replaceFirst(SELECT_BOX_PREFIX,"String_Node_Str");
        if (WEEKLY.equals(value)) {
          setting.addPlugin(pluginId.replaceFirst(UserSetting.EMAIL_CHANNEL,"String_Node_Str"),FREQUENCY.WEEKLY);
        }
        if (DAILY.equals(value)) {
          setting.addPlugin(pluginId.replaceFirst(UserSetting.EMAIL_CHANNEL,"String_Node_Str"),FREQUENCY.DAILY);
        }
      }
 else       if (!pluginId.startsWith(CHANNEL_PREFIX)) {
        for (        String channelId : channels) {
          if (pluginId.startsWith(channelId)) {
            if (UserSetting.EMAIL_CHANNEL.equals(channelId)) {
              setting.addPlugin(pluginId.replaceFirst(UserSetting.EMAIL_CHANNEL,"String_Node_Str"),FREQUENCY.INSTANTLY);
            }
 else {
              setting.addChannelPlugin(channelId,pluginId.replaceFirst(channelId,"String_Node_Str"));
            }
          }
        }
      }
    }
    userSettingService.save(setting);
    data.set("String_Node_Str","String_Node_Str");
    data.set("String_Node_Str","String_Node_Str");
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    data.set("String_Node_Str","String_Node_Str");
    data.set("String_Node_Str",e.toString());
  }
  return Response.ok(data.toString()).withMimeType("String_Node_Str");
}