Program: 66622
Project: 66622
Buggy source:
/** 
 * Return an object retrieved from resultSet with the getObject() method. Optimize the get for certain type to avoid double conversion. <b>NOTE</b>: This method handles a virtual machine error thrown when retrieving times & dates from Oracle or Sybase.
 */
public Object getObject(ResultSet resultSet,DatabaseField field,ResultSetMetaData metaData,int columnNumber,DatabasePlatform platform,boolean optimizeData,AbstractSession session) throws DatabaseException {
  Object value=null;
  try {
    int type=field.sqlType;
    if (type == NULL_SQL_TYPE) {
      type=metaData.getColumnType(columnNumber);
      field.setSqlType(type);
    }
    if (optimizeData) {
      try {
        value=getObjectThroughOptimizedDataConversion(resultSet,field,type,columnNumber,platform,session);
        if (value == null) {
          return null;
        }
        if (value == this) {
          value=null;
        }
      }
 catch (      SQLException exception) {
        if (session.shouldLog(SessionLog.WARNING,SessionLog.SQL)) {
          session.logThrowable(SessionLog.WARNING,SessionLog.SQL,exception);
        }
      }
    }
    if (value == null) {
      if ((type == Types.LONGVARBINARY) && platform.usesStreamsForBinding()) {
        InputStream tempInputStream;
        tempInputStream=resultSet.getBinaryStream(columnNumber);
        if (tempInputStream != null) {
          try {
            ByteArrayOutputStream tempOutputStream=new ByteArrayOutputStream();
            int tempInt=tempInputStream.read();
            while (tempInt != -1) {
              tempOutputStream.write(tempInt);
              tempInt=tempInputStream.read();
            }
            value=tempOutputStream.toByteArray();
          }
 catch (          IOException exception) {
            throw DatabaseException.errorReadingBlobData();
          }
        }
 else {
          value=null;
        }
      }
 else {
        value=platform.getObjectFromResultSet(resultSet,columnNumber,type,session);
        if (isBlob(type)) {
          value=platform.convertObject(value,ClassConstants.APBYTE);
        }
        if (isClob(type)) {
          value=platform.convertObject(value,ClassConstants.STRING);
        }
        if (isArray(type)) {
          value=ObjectRelationalDataTypeDescriptor.buildArrayObjectFromArray(value);
        }
        if (isStruct(type,value)) {
          value=ObjectRelationalDataTypeDescriptor.buildArrayObjectFromStruct(value);
        }
      }
    }
    if ((!optimizeData) && resultSet.wasNull()) {
      value=null;
    }
  }
 catch (  SQLException exception) {
    DatabaseException commException=processExceptionForCommError(session,exception,null);
    if (commException != null)     throw commException;
    throw DatabaseException.sqlException(exception,this,session,false);
  }
  return value;
}

Fixed version (ground truth):
/** 
 * Return an object retrieved from resultSet with the getObject() method. Optimize the get for certain type to avoid double conversion. <b>NOTE</b>: This method handles a virtual machine error thrown when retrieving times & dates from Oracle or Sybase.
 */
public Object getObject(ResultSet resultSet,DatabaseField field,ResultSetMetaData metaData,int columnNumber,DatabasePlatform platform,boolean optimizeData,AbstractSession session) throws DatabaseException {
  Object value=null;
  try {
    int type=field.sqlType;
    if (type == NULL_SQL_TYPE) {
      type=metaData.getColumnType(columnNumber);
      field.setSqlType(type);
    }
    if (optimizeData) {
      try {
        value=getObjectThroughOptimizedDataConversion(resultSet,field,type,columnNumber,platform,session);
        if (value == null) {
          return null;
        }
        if (value == this) {
          value=null;
        }
      }
 catch (      SQLException exception) {
        if (session.shouldLog(SessionLog.WARNING,SessionLog.SQL)) {
          session.logThrowable(SessionLog.WARNING,SessionLog.SQL,exception);
        }
      }
    }
    if (value == null) {
      if ((type == Types.LONGVARBINARY) && platform.usesStreamsForBinding()) {
        InputStream tempInputStream;
        tempInputStream=resultSet.getBinaryStream(columnNumber);
        if (tempInputStream != null) {
          try {
            ByteArrayOutputStream tempOutputStream=new ByteArrayOutputStream();
            int tempInt=tempInputStream.read();
            while (tempInt != -1) {
              tempOutputStream.write(tempInt);
              tempInt=tempInputStream.read();
            }
            value=tempOutputStream.toByteArray();
          }
 catch (          IOException exception) {
            throw DatabaseException.errorReadingBlobData();
          }
        }
 else {
          value=null;
        }
      }
 else {
        value=platform.getObjectFromResultSet(resultSet,columnNumber,type,session);
        if (isBlob(type)) {
          Object originalValue=value;
          value=platform.convertObject(value,ClassConstants.APBYTE);
          platform.freeTemporaryObject(originalValue);
        }
        if (isClob(type)) {
          Object originalValue=value;
          value=platform.convertObject(value,ClassConstants.STRING);
          platform.freeTemporaryObject(originalValue);
        }
        if (isArray(type)) {
          value=ObjectRelationalDataTypeDescriptor.buildArrayObjectFromArray(value);
        }
        if (isStruct(type,value)) {
          value=ObjectRelationalDataTypeDescriptor.buildArrayObjectFromStruct(value);
        }
      }
    }
    if ((!optimizeData) && resultSet.wasNull()) {
      value=null;
    }
  }
 catch (  SQLException exception) {
    DatabaseException commException=processExceptionForCommError(session,exception,null);
    if (commException != null)     throw commException;
    throw DatabaseException.sqlException(exception,this,session,false);
  }
  return value;
}