Program: 63904
Project: 63904
Buggy source:
/** 
 * Build and return a Result instance based on a given ProcedureType and return type name.
 */
protected Result buildResultForStoredFunction(ArgumentType returnArgument,String returnType){
  Result result=null;
  DatabaseType rargDataType=returnArgument.getEnclosedType();
  if (rargDataType.isPLSQLCursorType() || returnArgument.getTypeName().contains(CURSOR_STR)) {
    result=new CollectionResult();
    result.setType(SXF_QNAME_CURSOR);
  }
 else {
    result=new Result();
    int rargJdbcType=OTHER;
    if (rargDataType.isComposite()) {
      if (rargDataType.isObjectType()) {
        rargJdbcType=STRUCT;
      }
 else       if (rargDataType.isVArrayType() || rargDataType.isObjectTableType()) {
        rargJdbcType=ARRAY;
      }
    }
 else {
      rargJdbcType=Util.getJDBCTypeFromTypeName(returnArgument.getTypeName());
    }
switch (rargJdbcType) {
case OTHER:
      String returnTypeName;
    if (returnType != null && returnType.length() > 0) {
      returnTypeName=returnType;
    }
 else {
      returnType=rargDataType.getTypeName();
      String packageName=null;
      if (rargDataType.isPLSQLType()) {
        packageName=((PLSQLType)rargDataType).getParentType().getPackageName();
      }
      returnTypeName=(packageName != null && packageName.length() > 0) ? packageName + UNDERSCORE + returnType : returnType;
      returnTypeName=returnTypeName.contains(PERCENT) ? returnTypeName.replace(PERCENT,UNDERSCORE) : returnTypeName;
      returnTypeName=nct.generateSchemaAlias(returnTypeName);
    }
  result.setType(buildCustomQName(returnTypeName,dbwsBuilder));
break;
case STRUCT:
case ARRAY:
if (returnType == null || returnType.length() == 0) {
returnType=rargDataType.getTypeName().toLowerCase().concat(TYPE_STR);
}
result.setType(buildCustomQName(returnType,dbwsBuilder));
break;
default :
result.setType(getXMLTypeFromJDBCType(rargJdbcType));
break;
}
}
if (rargDataType == ScalarDatabaseTypeEnum.XMLTYPE_TYPE) {
result.setJdbcType(getJDBCTypeForTypeName(ScalarDatabaseTypeEnum.XMLTYPE_TYPE.toString()));
}
return result;
}

Fixed version (ground truth):
/** 
 * Build and return a Result instance based on a given ProcedureType and return type name.
 */
protected Result buildResultForStoredFunction(ArgumentType returnArgument,String returnType){
  Result result=null;
  DatabaseType rargDataType=returnArgument.getEnclosedType();
  if (rargDataType.isPLSQLCursorType() || returnArgument.getTypeName().contains(CURSOR_STR)) {
    result=new CollectionResult();
    result.setType(SXF_QNAME_CURSOR);
  }
 else {
    result=new Result();
    int rargJdbcType=OTHER;
    if (rargDataType.isComposite()) {
      if (rargDataType.isObjectType()) {
        rargJdbcType=STRUCT;
      }
 else       if (rargDataType.isVArrayType() || rargDataType.isObjectTableType()) {
        rargJdbcType=ARRAY;
      }
    }
 else {
      rargJdbcType=Util.getJDBCTypeFromTypeName(returnArgument.getTypeName());
    }
switch (rargJdbcType) {
case OTHER:
      String returnTypeName;
    if (returnType != null && returnType.length() > 0) {
      returnTypeName=returnType;
    }
 else {
      returnType=rargDataType.getTypeName();
      String packageName=null;
      if (rargDataType.isPLSQLType()) {
        packageName=((PLSQLType)rargDataType).getParentType().getPackageName();
      }
      returnTypeName=(packageName != null && packageName.length() > 0) ? packageName + UNDERSCORE + returnType : returnType;
      returnTypeName=returnTypeName.contains(PERCENT) ? returnTypeName.replace(PERCENT,UNDERSCORE) : returnTypeName;
      returnTypeName=nct.generateSchemaAlias(returnTypeName);
    }
  result.setType(buildCustomQName(returnTypeName,dbwsBuilder));
break;
case STRUCT:
case ARRAY:
if (returnType == null || returnType.length() == 0) {
returnType=rargDataType.getTypeName().toLowerCase().concat(TYPE_STR);
}
result.setType(buildCustomQName(returnType,dbwsBuilder));
break;
default :
result.setType(getXMLTypeFromJDBCType(rargJdbcType));
break;
}
}
if (rargDataType == ScalarDatabaseTypeEnum.XMLTYPE_TYPE) {
result.setJdbcType(getJDBCTypeForTypeName(XMLTYPE_STR));
}
return result;
}