Program: 31743
Project: 31743
Buggy source:
/** 
 * Load model instance from stream like model0.gbt or model0.rf. User can specify to use raw score or score after sigmoid transfrom by isConvertToProb.
 * @param input the input stream
 * @param isConvertToProb if convert score to probability (if to transfrom raw score by sigmoid)
 * @return the tree model instance
 * @throws IOException any exception in load input stream
 */
public static IndependentTreeModel loadFromStream(InputStream input,boolean isConvertToProb) throws IOException {
  DataInputStream dis=null;
  try {
    byte[] header=new byte[2];
    BufferedInputStream bis=new BufferedInputStream(input);
    bis.mark(2);
    int result=bis.read(header);
    bis.reset();
    int ss=(header[0] & 0xff) | ((header[1] & 0xff) << 8);
    if (result != -1 && ss == GZIPInputStream.GZIP_MAGIC) {
      dis=new DataInputStream(new GZIPInputStream(bis));
    }
 else {
      dis=new DataInputStream(bis);
    }
  }
 catch (  java.io.IOException e) {
    dis=new DataInputStream(input);
  }
  int version=dis.readInt();
  String algorithm=dis.readUTF();
  String lossStr=dis.readUTF();
  boolean isClassification=dis.readBoolean();
  boolean isOneVsAll=dis.readBoolean();
  int inputNode=dis.readInt();
  Map<Integer,Double> numericalMeanMapping=new HashMap<Integer,Double>();
  Map<Integer,String> columnIndexNameMapping=new HashMap<Integer,String>();
  int size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    double mean=dis.readDouble();
    numericalMeanMapping.put(columnIndex,mean);
  }
  size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    String columnName=dis.readUTF();
    columnIndexNameMapping.put(columnIndex,columnName);
  }
  Map<Integer,List<String>> categoricalColumnNameNames=new HashMap<Integer,List<String>>();
  Map<Integer,Map<String,Integer>> columnCategoryIndexMapping=new HashMap<Integer,Map<String,Integer>>();
  size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    int categoryListSize=dis.readInt();
    Map<String,Integer> categoryIndexMapping=new HashMap<String,Integer>();
    List<String> categories=new ArrayList<String>();
    for (int j=0; j < categoryListSize; j++) {
      String category=dis.readUTF();
      categoryIndexMapping.put(category,j);
      categories.add(category);
    }
    categoricalColumnNameNames.put(columnIndex,categories);
    columnCategoryIndexMapping.put(columnIndex,categoryIndexMapping);
  }
  Map<Integer,Integer> columnMapping=new HashMap<Integer,Integer>();
  int columnMappingSize=dis.readInt();
  for (int i=0; i < columnMappingSize; i++) {
    columnMapping.put(dis.readInt(),dis.readInt());
  }
  int treeNum=dis.readInt();
  List<TreeNode> trees=new ArrayList<TreeNode>(treeNum);
  List<Double> weights=new ArrayList<Double>(treeNum);
  for (int i=0; i < treeNum; i++) {
    TreeNode treeNode=new TreeNode();
    treeNode.readFields(dis);
    trees.add(treeNode);
    weights.add(treeNode.getLearningRate());
  }
  return new IndependentTreeModel(numericalMeanMapping,columnIndexNameMapping,categoricalColumnNameNames,columnCategoryIndexMapping,columnMapping,trees,weights,CommonConstants.GBT_ALG_NAME.equalsIgnoreCase(algorithm),isClassification && !isOneVsAll,isConvertToProb,lossStr,algorithm,inputNode,version);
}

Fixed version (ground truth):
/** 
 * Load model instance from stream like model0.gbt or model0.rf. User can specify to use raw score or score after sigmoid transfrom by isConvertToProb.
 * @param input the input stream
 * @param isConvertToProb if convert score to probability (if to transfrom raw score by sigmoid)
 * @return the tree model instance
 * @throws IOException any exception in load input stream
 */
public static IndependentTreeModel loadFromStream(InputStream input,boolean isConvertToProb) throws IOException {
  DataInputStream dis=null;
  try {
    byte[] header=new byte[2];
    BufferedInputStream bis=new BufferedInputStream(input);
    bis.mark(2);
    int result=bis.read(header);
    bis.reset();
    int ss=(header[0] & 0xff) | ((header[1] & 0xff) << 8);
    if (result != -1 && ss == GZIPInputStream.GZIP_MAGIC) {
      dis=new DataInputStream(new GZIPInputStream(bis));
    }
 else {
      dis=new DataInputStream(bis);
    }
  }
 catch (  java.io.IOException e) {
    dis=new DataInputStream(input);
  }
  int version=dis.readInt();
  String algorithm=dis.readUTF();
  String lossStr=dis.readUTF();
  boolean isClassification=dis.readBoolean();
  boolean isOneVsAll=dis.readBoolean();
  int inputNode=dis.readInt();
  Map<Integer,Double> numericalMeanMapping=new HashMap<Integer,Double>();
  Map<Integer,String> columnIndexNameMapping=new HashMap<Integer,String>();
  int size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    double mean=dis.readDouble();
    numericalMeanMapping.put(columnIndex,mean);
  }
  size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    String columnName=dis.readUTF();
    columnIndexNameMapping.put(columnIndex,columnName);
  }
  Map<Integer,List<String>> categoricalColumnNameNames=new HashMap<Integer,List<String>>();
  Map<Integer,Map<String,Integer>> columnCategoryIndexMapping=new HashMap<Integer,Map<String,Integer>>();
  size=dis.readInt();
  for (int i=0; i < size; i++) {
    int columnIndex=dis.readInt();
    int categoryListSize=dis.readInt();
    Map<String,Integer> categoryIndexMapping=new HashMap<String,Integer>();
    List<String> categories=new ArrayList<String>();
    for (int j=0; j < categoryListSize; j++) {
      String category=dis.readUTF();
      categories.add(category);
      if (category.contains("String_Node_Str" + MERGE_CATEGORY_DELIMITER)) {
        String[] splits=split(category,MERGE_CATEGORY_DELIMITER);
        for (        String str : splits) {
          categoryIndexMapping.put(str,j);
        }
      }
 else {
        categoryIndexMapping.put(category,j);
      }
    }
    categoricalColumnNameNames.put(columnIndex,categories);
    columnCategoryIndexMapping.put(columnIndex,categoryIndexMapping);
  }
  Map<Integer,Integer> columnMapping=new HashMap<Integer,Integer>();
  int columnMappingSize=dis.readInt();
  for (int i=0; i < columnMappingSize; i++) {
    columnMapping.put(dis.readInt(),dis.readInt());
  }
  int treeNum=dis.readInt();
  List<TreeNode> trees=new ArrayList<TreeNode>(treeNum);
  List<Double> weights=new ArrayList<Double>(treeNum);
  for (int i=0; i < treeNum; i++) {
    TreeNode treeNode=new TreeNode();
    treeNode.readFields(dis);
    trees.add(treeNode);
    weights.add(treeNode.getLearningRate());
  }
  return new IndependentTreeModel(numericalMeanMapping,columnIndexNameMapping,categoricalColumnNameNames,columnCategoryIndexMapping,columnMapping,trees,weights,CommonConstants.GBT_ALG_NAME.equalsIgnoreCase(algorithm),isClassification && !isOneVsAll,isConvertToProb,lossStr,algorithm,inputNode,version);
}