Program: 79127
Project: 79127
Buggy source:
/** 
 * Serialze result object array to file
 * @param bos output stream
 * @param resultObjects result objects needs to be deserialized
 * @param length how many objects to be deserialized
 * @throws IOException
 * @throws DataException
 * @throws Exception
 */
void writeData(BufferedOutputStream bos,IResultObject[] resultObjects,int length) throws IOException {
  byte[] rowsDataByte=new byte[0];
  ByteArrayOutputStream baos;
  ObjectOutputStream oos;
  for (int i=0; i < length; i++) {
    baos=new ByteArrayOutputStream();
    oos=new ObjectOutputStream(baos);
    for (int j=0; j < columnCount; j++) {
      Object fieldValue=null;
      try {
        fieldValue=resultObjects[i].getFieldValue(j + 1);
      }
 catch (      DataException e) {
      }
      Class fieldType=typeArray[j];
      if (fieldValue == null)       putNullObject(writeIndex,j);
 else       if (fieldType.equals(Integer.class))       oos.writeInt(((Integer)fieldValue).intValue());
 else       if (fieldType.equals(Double.class))       oos.writeDouble(((Double)fieldValue).doubleValue());
 else       if (fieldType.equals(BigDecimal.class))       oos.writeUTF(((BigDecimal)fieldValue).toString());
 else       if (fieldType.equals(Date.class))       oos.writeLong(((Date)fieldValue).getTime());
 else       if (fieldType.equals(Time.class))       oos.writeLong(((Time)fieldValue).getTime());
 else       if (fieldType.equals(Timestamp.class))       oos.writeLong(((Timestamp)fieldValue).getTime());
 else       if (fieldType.equals(Boolean.class))       oos.writeBoolean(((Boolean)fieldValue).booleanValue());
 else       if (fieldType.equals(String.class) || fieldType.equals(DataType.getClass(DataType.ANY_TYPE)))       oos.writeUTF(fieldValue.toString());
    }
    oos.flush();
    rowsDataByte=baos.toByteArray();
    bos.write(getBytesOfInt(rowsDataByte.length));
    bos.write(rowsDataByte);
    rowsDataByte=null;
    baos=null;
    oos=null;
    writeIndex++;
  }
}

Fixed version (ground truth):
/** 
 * Serialze result object array to file. The serialize procedure is conversed with de-serialize(read) procedure.
 * @param bos output stream
 * @param resultObjects result objects needs to be deserialized
 * @param length how many objects to be deserialized
 * @throws IOException
 */
void writeData(BufferedOutputStream bos,IResultObject[] resultObjects,int length) throws IOException {
  byte[] rowsDataByte=new byte[0];
  ByteArrayOutputStream baos;
  ObjectOutputStream oos;
  for (int i=0; i < length; i++) {
    baos=new ByteArrayOutputStream();
    oos=new ObjectOutputStream(baos);
    for (int j=0; j < columnCount; j++) {
      Object fieldValue=null;
      try {
        fieldValue=resultObjects[i].getFieldValue(j + 1);
      }
 catch (      DataException e) {
      }
      Class fieldType=typeArray[j];
      if (fieldValue == null)       putNullObject(writeIndex,j);
 else       if (fieldType.equals(Integer.class))       oos.writeInt(((Integer)fieldValue).intValue());
 else       if (fieldType.equals(Double.class))       oos.writeDouble(((Double)fieldValue).doubleValue());
 else       if (fieldType.equals(BigDecimal.class))       oos.writeUTF(((BigDecimal)fieldValue).toString());
 else       if (fieldType.equals(Date.class))       oos.writeLong(((Date)fieldValue).getTime());
 else       if (fieldType.equals(Time.class))       oos.writeLong(((Time)fieldValue).getTime());
 else       if (fieldType.equals(Timestamp.class))       oos.writeLong(((Timestamp)fieldValue).getTime());
 else       if (fieldType.equals(Boolean.class))       oos.writeBoolean(((Boolean)fieldValue).booleanValue());
 else       if (fieldType.equals(String.class) || fieldType.equals(DataType.getClass(DataType.ANY_TYPE)))       oos.writeUTF(fieldValue.toString());
    }
    oos.flush();
    rowsDataByte=baos.toByteArray();
    bos.write(getBytesOfInt(rowsDataByte.length));
    bos.write(rowsDataByte);
    rowsDataByte=null;
    baos=null;
    oos=null;
    writeIndex++;
  }
}