Program: 67884
Project: 67884
Buggy source:
/** 
 * Convert the given object to the appropriate type by invoking the appropriate ConversionManager method.
 * @param sourceObject - will always be a string if read from XML
 * @param javaClass - the class that the object must be converted to
 * @param schemaTypeQName - the XML schema that the object is being converted from
 * @return - the newly converted object
 */
public Object convertObject(Object sourceObject,Class javaClass,QName schemaTypeQName) throws ConversionException {
  if (schemaTypeQName == null) {
    return convertObject(sourceObject,javaClass);
  }
  if (sourceObject == null) {
    return super.convertObject(sourceObject,javaClass);
  }
 else   if ((javaClass == ClassConstants.CALENDAR) || (javaClass == ClassConstants.GREGORIAN_CALENDAR)) {
    return convertObjectToCalendar(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.ABYTE) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.HEX_BINARY)) {
      return super.convertObjectToByteObjectArray(sourceObject);
    }
 else     if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return convertSchemaBase64ToByteObjectArray(sourceObject);
    }
  }
 else   if (javaClass == ClassConstants.APBYTE) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.HEX_BINARY)) {
      return super.convertObjectToByteArray(sourceObject);
    }
 else     if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return convertSchemaBase64ToByteArray(sourceObject);
    }
  }
 else   if ((javaClass == ClassConstants.List_Class) && (sourceObject instanceof String)) {
    return convertStringToList(sourceObject);
  }
 else   if ((javaClass == ClassConstants.STRING) && (sourceObject instanceof List)) {
    return convertListToString(sourceObject);
  }
 else   if (sourceObject instanceof byte[]) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return buildBase64StringFromBytes((byte[])sourceObject);
    }
    return Helper.buildHexStringFromBytes((byte[])sourceObject);
  }
 else   if (sourceObject instanceof Byte[]) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return buildBase64StringFromObjectBytes((Byte[])sourceObject);
    }
    return buildHexStringFromObjectBytes((Byte[])sourceObject);
  }
 else   if ((javaClass == ClassConstants.UTILDATE)) {
    return convertObjectToUtilDate(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.SQLDATE) {
    return convertObjectToSQLDate(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.TIME) {
    return convertObjectToSQLTime(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.TIMESTAMP) {
    return convertObjectToTimestamp(sourceObject,schemaTypeQName);
  }
 else   if ((javaClass == XMLConstants.QNAME_CLASS) && (sourceObject != null)) {
    return convertObjectToQName(sourceObject);
  }
 else   if (javaClass == ClassConstants.STRING) {
    return convertObjectToString(sourceObject,schemaTypeQName);
  }
 else   if ((javaClass == java.net.URI.class)) {
    return convertObjectToURI(sourceObject);
  }
 else   if ((javaClass == ClassConstants.XML_GREGORIAN_CALENDAR)) {
    return convertObjectToXMLGregorianCalendar(sourceObject);
  }
 else   if ((javaClass == ClassConstants.DURATION)) {
    return convertObjectToDuration(sourceObject);
  }
 else {
    try {
      return super.convertObject(sourceObject,javaClass);
    }
 catch (    ConversionException ex) {
      if (sourceObject.getClass() == ClassConstants.STRING) {
        return super.convertObject(((String)sourceObject).trim(),javaClass);
      }
      throw ex;
    }
  }
  throw ConversionException.couldNotBeConverted(sourceObject,javaClass);
}

Fixed version (ground truth):
/** 
 * Convert the given object to the appropriate type by invoking the appropriate ConversionManager method.
 * @param sourceObject - will always be a string if read from XML
 * @param javaClass - the class that the object must be converted to
 * @param schemaTypeQName - the XML schema that the object is being converted from
 * @return - the newly converted object
 */
public Object convertObject(Object sourceObject,Class javaClass,QName schemaTypeQName) throws ConversionException {
  if (schemaTypeQName == null) {
    return convertObject(sourceObject,javaClass);
  }
  if (sourceObject == null) {
    return super.convertObject(sourceObject,javaClass);
  }
 else   if ((javaClass == ClassConstants.CALENDAR) || (javaClass == ClassConstants.GREGORIAN_CALENDAR)) {
    return convertObjectToCalendar(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.ABYTE) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.HEX_BINARY)) {
      return super.convertObjectToByteObjectArray(sourceObject);
    }
 else     if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return convertSchemaBase64ToByteObjectArray(sourceObject);
    }
  }
 else   if (javaClass == ClassConstants.APBYTE) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.HEX_BINARY)) {
      return super.convertObjectToByteArray(sourceObject);
    }
 else     if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return convertSchemaBase64ToByteArray(sourceObject);
    }
  }
 else   if ((javaClass == ClassConstants.List_Class) && (sourceObject instanceof String)) {
    return convertStringToList(sourceObject);
  }
 else   if ((javaClass == ClassConstants.STRING) && (sourceObject instanceof List)) {
    return convertListToString(sourceObject);
  }
 else   if (sourceObject instanceof byte[]) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return buildBase64StringFromBytes((byte[])sourceObject);
    }
    return Helper.buildHexStringFromBytes((byte[])sourceObject);
  }
 else   if (sourceObject instanceof Byte[]) {
    if (schemaTypeQName.getLocalPart().equalsIgnoreCase(XMLConstants.BASE_64_BINARY)) {
      return buildBase64StringFromObjectBytes((Byte[])sourceObject);
    }
    return buildHexStringFromObjectBytes((Byte[])sourceObject);
  }
 else   if ((javaClass == ClassConstants.UTILDATE)) {
    return convertObjectToUtilDate(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.SQLDATE) {
    return convertObjectToSQLDate(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.TIME) {
    return convertObjectToSQLTime(sourceObject,schemaTypeQName);
  }
 else   if (javaClass == ClassConstants.TIMESTAMP) {
    return convertObjectToTimestamp(sourceObject,schemaTypeQName);
  }
 else   if ((javaClass == XMLConstants.QNAME_CLASS) && (sourceObject != null)) {
    return convertObjectToQName(sourceObject);
  }
 else   if (javaClass == ClassConstants.STRING) {
    return convertObjectToString(sourceObject,schemaTypeQName);
  }
 else   if ((javaClass == java.net.URI.class)) {
    return convertObjectToURI(sourceObject);
  }
 else   if ((javaClass == ClassConstants.XML_GREGORIAN_CALENDAR)) {
    return convertObjectToXMLGregorianCalendar(sourceObject,schemaTypeQName);
  }
 else   if ((javaClass == ClassConstants.DURATION)) {
    return convertObjectToDuration(sourceObject);
  }
 else {
    try {
      return super.convertObject(sourceObject,javaClass);
    }
 catch (    ConversionException ex) {
      if (sourceObject.getClass() == ClassConstants.STRING) {
        return super.convertObject(((String)sourceObject).trim(),javaClass);
      }
      throw ex;
    }
  }
  throw ConversionException.couldNotBeConverted(sourceObject,javaClass);
}