Program: 31587
Project: 31587
Buggy source:
public static void save(ModelConfig modelConfig,List<ColumnConfig> columnConfigList,List<List<TreeNode>> baggingTrees,String loss,int inputCount,OutputStream output) throws IOException {
  DataOutputStream fos=null;
  try {
    fos=new DataOutputStream(new GZIPOutputStream(output));
    fos.writeInt(CommonConstants.TREE_FORMAT_VERSION);
    fos.writeUTF(modelConfig.getAlgorithm());
    fos.writeUTF(loss);
    fos.writeBoolean(modelConfig.isClassification());
    fos.writeBoolean(modelConfig.getTrain().isOneVsAll());
    fos.writeInt(inputCount);
    Map<Integer,String> columnIndexNameMapping=new HashMap<Integer,String>();
    Map<Integer,List<String>> columnIndexCategoricalListMapping=new HashMap<Integer,List<String>>();
    Map<Integer,Double> numericalMeanMapping=new HashMap<Integer,Double>();
    for (    ColumnConfig columnConfig : columnConfigList) {
      if (columnConfig.isFinalSelect()) {
        columnIndexNameMapping.put(columnConfig.getColumnNum(),columnConfig.getColumnName());
      }
      if (columnConfig.isCategorical() && CollectionUtils.isNotEmpty(columnConfig.getBinCategory())) {
        columnIndexCategoricalListMapping.put(columnConfig.getColumnNum(),columnConfig.getBinCategory());
      }
      if (columnConfig.isNumerical() && columnConfig.getMean() != null) {
        numericalMeanMapping.put(columnConfig.getColumnNum(),columnConfig.getMean());
      }
    }
    if (columnIndexNameMapping.size() == 0) {
      boolean hasCandidates=CommonUtils.hasCandidateColumns(columnConfigList);
      for (      ColumnConfig columnConfig : columnConfigList) {
        if (CommonUtils.isGoodCandidate(columnConfig,hasCandidates)) {
          columnIndexNameMapping.put(columnConfig.getColumnNum(),columnConfig.getColumnName());
        }
      }
    }
    fos.writeInt(numericalMeanMapping.size());
    for (    Entry<Integer,Double> entry : numericalMeanMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeDouble(entry.getValue() == null ? 0d : entry.getValue());
    }
    fos.writeInt(columnIndexNameMapping.size());
    for (    Entry<Integer,String> entry : columnIndexNameMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeUTF(entry.getValue());
    }
    fos.writeInt(columnIndexCategoricalListMapping.size());
    for (    Entry<Integer,List<String>> entry : columnIndexCategoricalListMapping.entrySet()) {
      List<String> categories=entry.getValue();
      if (categories != null) {
        fos.writeInt(entry.getKey());
        fos.writeInt(categories.size());
        for (        String category : categories) {
          if (category.length() > Constants.MAX_CATEGORICAL_VAL_LEN) {
            int pos=category.lastIndexOf(Constants.CATEGORICAL_GROUP_VAL_DELIMITER,Constants.MAX_CATEGORICAL_VAL_LEN);
            if (pos >= 0) {
              category=category.substring(0,pos);
            }
 else {
              category=category.substring(0,Constants.MAX_CATEGORICAL_VAL_LEN);
            }
            fos.writeUTF(category);
          }
 else {
            fos.writeShort(UTF_BYTES_MARKER);
            byte[] bytes=category.getBytes("String_Node_Str");
            fos.writeInt(bytes.length);
            for (int i=0; i < bytes.length; i++) {
              fos.writeByte(bytes[i]);
            }
          }
        }
      }
    }
    Map<Integer,Integer> columnMapping=getColumnMapping(columnConfigList);
    fos.writeInt(columnMapping.size());
    for (    Entry<Integer,Integer> entry : columnMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeInt(entry.getValue());
    }
    fos.writeInt(baggingTrees.size());
    for (int i=0; i < baggingTrees.size(); i++) {
      List<TreeNode> trees=baggingTrees.get(i);
      int treeLength=trees.size();
      fos.writeInt(treeLength);
      for (      TreeNode treeNode : trees) {
        treeNode.write(fos);
      }
    }
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
 finally {
    IOUtils.closeStream(fos);
  }
}

Fixed version (ground truth):
public static void save(ModelConfig modelConfig,List<ColumnConfig> columnConfigList,List<List<TreeNode>> baggingTrees,String loss,int inputCount,OutputStream output) throws IOException {
  DataOutputStream fos=null;
  try {
    fos=new DataOutputStream(new GZIPOutputStream(output));
    fos.writeInt(CommonConstants.TREE_FORMAT_VERSION);
    fos.writeUTF(modelConfig.getAlgorithm());
    fos.writeUTF(loss);
    fos.writeBoolean(modelConfig.isClassification());
    fos.writeBoolean(modelConfig.getTrain().isOneVsAll());
    fos.writeInt(inputCount);
    Map<Integer,String> columnIndexNameMapping=new HashMap<Integer,String>();
    Map<Integer,List<String>> columnIndexCategoricalListMapping=new HashMap<Integer,List<String>>();
    Map<Integer,Double> numericalMeanMapping=new HashMap<Integer,Double>();
    for (    ColumnConfig columnConfig : columnConfigList) {
      if (columnConfig.isFinalSelect()) {
        columnIndexNameMapping.put(columnConfig.getColumnNum(),columnConfig.getColumnName());
      }
      if (columnConfig.isCategorical() && CollectionUtils.isNotEmpty(columnConfig.getBinCategory())) {
        columnIndexCategoricalListMapping.put(columnConfig.getColumnNum(),columnConfig.getBinCategory());
      }
      if (columnConfig.isNumerical() && columnConfig.getMean() != null) {
        numericalMeanMapping.put(columnConfig.getColumnNum(),columnConfig.getMean());
      }
    }
    if (columnIndexNameMapping.size() == 0) {
      boolean hasCandidates=CommonUtils.hasCandidateColumns(columnConfigList);
      for (      ColumnConfig columnConfig : columnConfigList) {
        if (CommonUtils.isGoodCandidate(columnConfig,hasCandidates)) {
          columnIndexNameMapping.put(columnConfig.getColumnNum(),columnConfig.getColumnName());
        }
      }
    }
    fos.writeInt(numericalMeanMapping.size());
    for (    Entry<Integer,Double> entry : numericalMeanMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeDouble(entry.getValue() == null ? 0d : entry.getValue());
    }
    fos.writeInt(columnIndexNameMapping.size());
    for (    Entry<Integer,String> entry : columnIndexNameMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeUTF(entry.getValue());
    }
    fos.writeInt(columnIndexCategoricalListMapping.size());
    for (    Entry<Integer,List<String>> entry : columnIndexCategoricalListMapping.entrySet()) {
      List<String> categories=entry.getValue();
      if (categories != null) {
        fos.writeInt(entry.getKey());
        fos.writeInt(categories.size());
        for (        String category : categories) {
          if (category.length() < Constants.MAX_CATEGORICAL_VAL_LEN) {
            fos.writeUTF(category);
          }
 else {
            fos.writeShort(UTF_BYTES_MARKER);
            byte[] bytes=category.getBytes("String_Node_Str");
            fos.writeInt(bytes.length);
            for (int i=0; i < bytes.length; i++) {
              fos.writeByte(bytes[i]);
            }
          }
        }
      }
    }
    Map<Integer,Integer> columnMapping=getColumnMapping(columnConfigList);
    fos.writeInt(columnMapping.size());
    for (    Entry<Integer,Integer> entry : columnMapping.entrySet()) {
      fos.writeInt(entry.getKey());
      fos.writeInt(entry.getValue());
    }
    fos.writeInt(baggingTrees.size());
    for (int i=0; i < baggingTrees.size(); i++) {
      List<TreeNode> trees=baggingTrees.get(i);
      int treeLength=trees.size();
      fos.writeInt(treeLength);
      for (      TreeNode treeNode : trees) {
        treeNode.write(fos);
      }
    }
  }
 catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
 finally {
    IOUtils.closeStream(fos);
  }
}