Program: 102154
Project: 102154
Buggy source:
/** 
 * Get the FunctionLibrary
 * @return the FunctionLibrary
 */
public synchronized IFunctionLibrary<IFunctionForm,IFunctionDescriptor> getFunctionLibrary(){
  if (!changed && this.cachedFunctionLibrary != null) {
    return this.cachedFunctionLibrary;
  }
  List<FunctionMethodDescriptor> functionMethodDescriptors=new ArrayList<FunctionMethodDescriptor>();
  for (  ModelResource functionModelResource : functionModels) {
    ScalarFunction[] functions=getScalarFunctions(functionModelResource);
    if (functions.length == 0)     continue;
    IMarker[] markers=getMarkers(functionModelResource);
    String schema=FileUtils.getFilenameWithoutExtension(functionModelResource.getItemName());
    for (    ScalarFunction function : functions) {
      if (!isFunctionObjectErrorFree(function.getReturnParameter(),markers,functionModelResource) || function.getReturnParameter() == null || !isFunctionObjectErrorFree(function.getReturnParameter(),markers,functionModelResource)) {
        continue;
      }
      String description=null;
      try {
        description=ModelerCore.getModelEditor().getDescription(function);
      }
 catch (      ModelerCoreException ex) {
        UdfPlugin.UTIL.log(ex);
      }
      boolean functionPamameterHasError=false;
      Collection<FunctionParameterDescriptor> fParams=new ArrayList<FunctionParameterDescriptor>();
      for (      Object inputParam : function.getInputParameters()) {
        if (inputParam instanceof org.teiid.designer.metamodels.function.FunctionParameter) {
          org.teiid.designer.metamodels.function.FunctionParameter param=(org.teiid.designer.metamodels.function.FunctionParameter)inputParam;
          fParams.add(new FunctionParameterDescriptor(param.getName(),param.getType()));
          if (!functionPamameterHasError && !isFunctionObjectErrorFree(param,markers,functionModelResource)) {
            functionPamameterHasError=true;
          }
        }
      }
      if (functionPamameterHasError) {
        continue;
      }
      String returnParamName=ModelerCore.getModelEditor().getName(function.getReturnParameter());
      FunctionParameterDescriptor outputParam=new FunctionParameterDescriptor(returnParamName,function.getReturnParameter().getType());
      FunctionMethodDescriptor fMethodDescriptor=new FunctionMethodDescriptor(function,function.getName(),description,function.getCategory(),function.getInvocationClass(),function.getInvocationMethod(),fParams.toArray(new FunctionParameterDescriptor[0]),outputParam,schema);
      fMethodDescriptor.setPushDown(function.getPushDown().getLiteral());
      fMethodDescriptor.setDeterministic(function.isDeterministic());
      boolean varArgs=false;
      String propValue=FunctionPlugin.getExtensionProperty(function,"String_Node_Str");
      if (propValue != null && propValue.length() > 0) {
        varArgs=Boolean.parseBoolean(propValue);
      }
      fMethodDescriptor.setVariableArgs(varArgs);
      functionMethodDescriptors.add(fMethodDescriptor);
    }
  }
  for (  ModelResource sourceModel : getRelationalModels()) {
    IMarker[] markers=getMarkers(sourceModel);
    String schema=FileUtils.getFilenameWithoutExtension(sourceModel.getItemName());
    for (    Procedure procedure : getFunctions(sourceModel)) {
      boolean isPhysical=ModelUtil.isPhysical(procedure);
      ProcedureWrapper wrappedProcedure=new ProcedureWrapper(procedure);
      if (!isFunctionObjectErrorFree(wrappedProcedure.getReturnParameter(),markers,sourceModel) || wrappedProcedure.getReturnParameter() == null || !isFunctionObjectErrorFree(wrappedProcedure.getReturnParameter(),markers,sourceModel)) {
        continue;
      }
      String description=null;
      try {
        description=ModelerCore.getModelEditor().getDescription(procedure);
      }
 catch (      ModelerCoreException ex) {
        UdfPlugin.UTIL.log(ex);
      }
      boolean functionPamameterHasError=false;
      Collection<FunctionParameterDescriptor> fParams=new ArrayList<FunctionParameterDescriptor>();
      for (      ProcedureParameter inputParam : wrappedProcedure.getInputParameters()) {
        String dTypeName=ModelerCore.getModelEditor().getName(inputParam.getType());
        fParams.add(new FunctionParameterDescriptor(inputParam.getName(),dTypeName));
        if (!functionPamameterHasError && !isFunctionObjectErrorFree(inputParam,markers,sourceModel)) {
          functionPamameterHasError=true;
        }
      }
      if (functionPamameterHasError) {
        continue;
      }
      String dTypeName=ModelerCore.getModelEditor().getName(wrappedProcedure.getReturnParameter().getType());
      String returnParamName=ModelerCore.getModelEditor().getName(wrappedProcedure.getReturnParameter());
      FunctionParameterDescriptor outputParam=new FunctionParameterDescriptor(returnParamName,dTypeName);
      String category=wrappedProcedure.getCategory();
      String javaClass=wrappedProcedure.getJavaClass();
      String javaMethod=wrappedProcedure.getJavaMethod();
      boolean javaClassAndMethodEmpty=(javaClass == null && javaMethod == null) ? true : false;
      if (isPhysical && javaClassAndMethodEmpty) {
        category=sourceModel.getItemName();
        if (category.endsWith("String_Node_Str")) {
          category=category.replaceAll("String_Node_Str",StringUtilities.EMPTY_STRING);
        }
      }
      FunctionMethodDescriptor fMethodDescriptor=new FunctionMethodDescriptor(procedure,wrappedProcedure.getName(),description,category,javaClass,javaMethod,fParams.toArray(new FunctionParameterDescriptor[0]),outputParam,schema);
      fMethodDescriptor.setPushDown(Boolean.toString(true));
      fMethodDescriptor.setDeterministic(wrappedProcedure.isDeterministic());
      boolean varArgs=false;
      String propValue=RelationalPlugin.getExtensionProperty(procedure,"String_Node_Str");
      if (propValue != null && propValue.length() > 0) {
        varArgs=Boolean.parseBoolean(propValue);
      }
      fMethodDescriptor.setVariableArgs(varArgs);
      functionMethodDescriptors.add(fMethodDescriptor);
    }
  }
  IQueryService queryService=ModelerCore.getTeiidQueryService();
  this.cachedFunctionLibrary=queryService.createFunctionLibrary(functionMethodDescriptors);
  this.changed=false;
  return this.cachedFunctionLibrary;
}

Fixed version (ground truth):
/** 
 * Get the FunctionLibrary
 * @return the FunctionLibrary
 */
public synchronized IFunctionLibrary<IFunctionForm,IFunctionDescriptor> getFunctionLibrary(){
  if (!changed && this.cachedFunctionLibrary != null) {
    return this.cachedFunctionLibrary;
  }
  List<FunctionMethodDescriptor> functionMethodDescriptors=new ArrayList<FunctionMethodDescriptor>();
  for (  ModelResource functionModelResource : functionModels) {
    ScalarFunction[] functions=getScalarFunctions(functionModelResource);
    if (functions.length == 0)     continue;
    IMarker[] markers=getMarkers(functionModelResource);
    String schema=FileUtils.getFilenameWithoutExtension(functionModelResource.getItemName());
    for (    ScalarFunction function : functions) {
      if (!isFunctionObjectErrorFree(function.getReturnParameter(),markers,functionModelResource) || function.getReturnParameter() == null || !isFunctionObjectErrorFree(function.getReturnParameter(),markers,functionModelResource)) {
        continue;
      }
      String description=null;
      try {
        description=ModelerCore.getModelEditor().getDescription(function);
      }
 catch (      ModelerCoreException ex) {
        UdfPlugin.UTIL.log(ex);
      }
      boolean functionPamameterHasError=false;
      Collection<FunctionParameterDescriptor> fParams=new ArrayList<FunctionParameterDescriptor>();
      for (      Object inputParam : function.getInputParameters()) {
        if (inputParam instanceof org.teiid.designer.metamodels.function.FunctionParameter) {
          org.teiid.designer.metamodels.function.FunctionParameter param=(org.teiid.designer.metamodels.function.FunctionParameter)inputParam;
          fParams.add(new FunctionParameterDescriptor(param.getName(),param.getType()));
          if (!functionPamameterHasError && !isFunctionObjectErrorFree(param,markers,functionModelResource)) {
            functionPamameterHasError=true;
          }
        }
      }
      if (functionPamameterHasError) {
        continue;
      }
      String returnParamName=ModelerCore.getModelEditor().getName(function.getReturnParameter());
      FunctionParameterDescriptor outputParam=new FunctionParameterDescriptor(returnParamName,function.getReturnParameter().getType());
      FunctionMethodDescriptor fMethodDescriptor=new FunctionMethodDescriptor(function,function.getName(),description,function.getCategory(),function.getInvocationClass(),function.getInvocationMethod(),fParams.toArray(new FunctionParameterDescriptor[0]),outputParam,schema);
      fMethodDescriptor.setPushDown(function.getPushDown().getLiteral());
      fMethodDescriptor.setDeterministic(function.isDeterministic());
      boolean varArgs=false;
      String propValue=FunctionPlugin.getExtensionProperty(function,"String_Node_Str");
      if (propValue != null && propValue.length() > 0) {
        varArgs=Boolean.parseBoolean(propValue);
      }
      fMethodDescriptor.setVariableArgs(varArgs);
      functionMethodDescriptors.add(fMethodDescriptor);
    }
  }
  for (  ModelResource sourceModel : getRelationalModels()) {
    IMarker[] markers=getMarkers(sourceModel);
    String schema=FileUtils.getFilenameWithoutExtension(sourceModel.getItemName());
    for (    Procedure procedure : getFunctions(sourceModel)) {
      boolean isPhysical=ModelUtil.isPhysical(procedure);
      ProcedureWrapper wrappedProcedure=new ProcedureWrapper(procedure);
      if (!isFunctionObjectErrorFree(wrappedProcedure.getReturnParameter(),markers,sourceModel) || wrappedProcedure.getReturnParameter() == null || !isFunctionObjectErrorFree(wrappedProcedure.getReturnParameter(),markers,sourceModel)) {
        continue;
      }
      String description=null;
      try {
        description=ModelerCore.getModelEditor().getDescription(procedure);
      }
 catch (      ModelerCoreException ex) {
        UdfPlugin.UTIL.log(ex);
      }
      boolean functionPamameterHasError=false;
      Collection<FunctionParameterDescriptor> fParams=new ArrayList<FunctionParameterDescriptor>();
      for (      ProcedureParameter inputParam : wrappedProcedure.getInputParameters()) {
        String dTypeName=ModelerCore.getModelEditor().getName(inputParam.getType());
        fParams.add(new FunctionParameterDescriptor(inputParam.getName(),dTypeName));
        if (!functionPamameterHasError && !isFunctionObjectErrorFree(inputParam,markers,sourceModel)) {
          functionPamameterHasError=true;
        }
      }
      if (functionPamameterHasError) {
        continue;
      }
      String dTypeName=ModelerCore.getModelEditor().getName(wrappedProcedure.getReturnParameter().getType());
      String returnParamName=ModelerCore.getModelEditor().getName(wrappedProcedure.getReturnParameter());
      FunctionParameterDescriptor outputParam=new FunctionParameterDescriptor(returnParamName,dTypeName);
      String category=wrappedProcedure.getCategory();
      String javaClass=wrappedProcedure.getJavaClass();
      String javaMethod=wrappedProcedure.getJavaMethod();
      boolean javaClassAndMethodEmpty=(javaClass == null && javaMethod == null) ? true : false;
      boolean isPushdown=false;
      if (isPhysical && javaClassAndMethodEmpty) {
        isPushdown=true;
        category=sourceModel.getItemName();
        if (category.endsWith("String_Node_Str")) {
          category=category.replaceAll("String_Node_Str",StringUtilities.EMPTY_STRING);
        }
      }
      FunctionMethodDescriptor fMethodDescriptor=new FunctionMethodDescriptor(procedure,wrappedProcedure.getName(),description,category,javaClass,javaMethod,fParams.toArray(new FunctionParameterDescriptor[0]),outputParam,schema);
      if (isPushdown) {
        fMethodDescriptor.setPushDown(Boolean.toString(true));
      }
      fMethodDescriptor.setDeterministic(wrappedProcedure.isDeterministic());
      boolean varArgs=false;
      String propValue=RelationalPlugin.getExtensionProperty(procedure,"String_Node_Str");
      if (propValue != null && propValue.length() > 0) {
        varArgs=Boolean.parseBoolean(propValue);
      }
      fMethodDescriptor.setVariableArgs(varArgs);
      functionMethodDescriptors.add(fMethodDescriptor);
    }
  }
  IQueryService queryService=ModelerCore.getTeiidQueryService();
  this.cachedFunctionLibrary=queryService.createFunctionLibrary(functionMethodDescriptors);
  this.changed=false;
  return this.cachedFunctionLibrary;
}