Program: 29662
Project: 29662
Buggy source:
public String processRefToExternalDefinition(String $ref,RefFormat refFormat){
  String renamedRef=cache.getRenamedRef($ref);
  if (renamedRef != null) {
    return renamedRef;
  }
  final Model model=cache.loadRef($ref,refFormat,Model.class);
  if (model == null) {
    LOGGER.warn("String_Node_Str" + $ref + "String_Node_Str"+ "String_Node_Str");
    return $ref;
  }
  String newRef;
  Map<String,Model> definitions=swagger.getDefinitions();
  if (definitions == null) {
    definitions=new LinkedHashMap<>();
  }
  final String possiblyConflictingDefinitionName=computeDefinitionName($ref,definitions.keySet());
  Model existingModel=definitions.get(possiblyConflictingDefinitionName);
  if (existingModel != null) {
    LOGGER.debug("String_Node_Str" + existingModel + "String_Node_Str");
    if (existingModel instanceof RefModel) {
      existingModel=null;
    }
  }
  newRef=possiblyConflictingDefinitionName;
  cache.putRenamedRef($ref,newRef);
  if (existingModel == null) {
    swagger.addDefinition(newRef,model);
    cache.addReferencedKey(newRef);
    String file=$ref.split("String_Node_Str")[0];
    if (model instanceof RefModel) {
      RefModel refModel=(RefModel)model;
      if (isAnExternalRefFormat(refModel.getRefFormat())) {
        refModel.set$ref(processRefToExternalDefinition(refModel.get$ref(),refModel.getRefFormat()));
      }
 else {
        processRefToExternalDefinition(file + refModel.get$ref(),RefFormat.RELATIVE);
      }
    }
 else     if (model instanceof ComposedModel) {
      ComposedModel composedModel=(ComposedModel)model;
      List<Model> listOfAllOF=composedModel.getAllOf();
      for (      Model allOfModel : listOfAllOF) {
        if (allOfModel instanceof RefModel) {
          RefModel refModel=(RefModel)allOfModel;
          if (isAnExternalRefFormat(refModel.getRefFormat())) {
            String joinedRef=join(file,refModel.get$ref());
            refModel.set$ref(processRefToExternalDefinition(joinedRef,refModel.getRefFormat()));
          }
 else {
            processRefToExternalDefinition(file + refModel.get$ref(),RefFormat.RELATIVE);
          }
        }
      }
    }
    Map<String,Property> subProps=model.getProperties();
    if (subProps != null) {
      for (      Map.Entry<String,Property> prop : subProps.entrySet()) {
        if (prop.getValue() instanceof RefProperty) {
          processRefProperty((RefProperty)prop.getValue(),file);
        }
 else         if (prop.getValue() instanceof ArrayProperty) {
          ArrayProperty arrayProp=(ArrayProperty)prop.getValue();
          if (arrayProp.getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)arrayProp.getItems(),file);
          }
        }
 else         if (prop.getValue() instanceof MapProperty) {
          MapProperty mapProp=(MapProperty)prop.getValue();
          if (mapProp.getAdditionalProperties() instanceof RefProperty) {
            processRefProperty((RefProperty)mapProp.getAdditionalProperties(),file);
          }
 else           if (mapProp.getAdditionalProperties() instanceof ArrayProperty && ((ArrayProperty)mapProp.getAdditionalProperties()).getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)((ArrayProperty)mapProp.getAdditionalProperties()).getItems(),file);
          }
        }
      }
    }
    if (model instanceof ModelImpl) {
      ModelImpl modelImpl=(ModelImpl)model;
      Property additionalProperties=modelImpl.getAdditionalProperties();
      if (additionalProperties != null) {
        if (additionalProperties instanceof RefProperty) {
          processRefProperty(((RefProperty)additionalProperties),file);
        }
 else         if (additionalProperties instanceof ArrayProperty) {
          ArrayProperty arrayProp=(ArrayProperty)additionalProperties;
          if (arrayProp.getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)arrayProp.getItems(),file);
          }
        }
 else         if (additionalProperties instanceof MapProperty) {
          MapProperty mapProp=(MapProperty)additionalProperties;
          if (mapProp.getAdditionalProperties() instanceof RefProperty) {
            processRefProperty((RefProperty)mapProp.getAdditionalProperties(),file);
          }
 else           if (mapProp.getAdditionalProperties() instanceof ArrayProperty && ((ArrayProperty)mapProp.getAdditionalProperties()).getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)((ArrayProperty)mapProp.getAdditionalProperties()).getItems(),file);
          }
        }
      }
    }
    if (model instanceof ArrayModel && ((ArrayModel)model).getItems() instanceof RefProperty) {
      processRefProperty((RefProperty)((ArrayModel)model).getItems(),file);
    }
  }
  return newRef;
}

Fixed version (ground truth):
public String processRefToExternalDefinition(String $ref,RefFormat refFormat){
  String renamedRef=cache.getRenamedRef($ref);
  if (renamedRef != null) {
    return renamedRef;
  }
  final Model model=cache.loadRef($ref,refFormat,Model.class);
  if (model == null) {
    LOGGER.warn("String_Node_Str" + $ref + "String_Node_Str"+ "String_Node_Str");
    return $ref;
  }
  String newRef;
  Map<String,Model> definitions=swagger.getDefinitions();
  if (definitions == null) {
    definitions=new LinkedHashMap<>();
  }
  final String possiblyConflictingDefinitionName=computeDefinitionName($ref,definitions.keySet());
  Model existingModel=definitions.get(possiblyConflictingDefinitionName);
  if (existingModel != null) {
    LOGGER.debug("String_Node_Str" + existingModel + "String_Node_Str");
    if (existingModel instanceof RefModel) {
      existingModel=null;
    }
  }
  newRef=possiblyConflictingDefinitionName;
  cache.putRenamedRef($ref,newRef);
  if (existingModel == null) {
    swagger.addDefinition(newRef,model);
    cache.addReferencedKey(newRef);
    String file=$ref.split("String_Node_Str")[0];
    if (model instanceof RefModel) {
      RefModel refModel=(RefModel)model;
      if (isAnExternalRefFormat(refModel.getRefFormat())) {
        refModel.set$ref(processRefToExternalDefinition(refModel.get$ref(),refModel.getRefFormat()));
      }
 else {
        processRefToExternalDefinition(file + refModel.get$ref(),RefFormat.RELATIVE);
      }
    }
 else     if (model instanceof ComposedModel) {
      ComposedModel composedModel=(ComposedModel)model;
      List<Model> listOfAllOF=composedModel.getAllOf();
      for (      Model allOfModel : listOfAllOF) {
        if (allOfModel instanceof RefModel) {
          RefModel refModel=(RefModel)allOfModel;
          if (isAnExternalRefFormat(refModel.getRefFormat())) {
            String joinedRef=join(file,refModel.get$ref());
            refModel.set$ref(processRefToExternalDefinition(joinedRef,refModel.getRefFormat()));
          }
 else {
            processRefToExternalDefinition(file + refModel.get$ref(),RefFormat.RELATIVE);
          }
        }
 else         if (allOfModel instanceof ModelImpl) {
          processProperties(allOfModel.getProperties(),file);
        }
      }
    }
    processProperties(model.getProperties(),file);
    if (model instanceof ModelImpl) {
      ModelImpl modelImpl=(ModelImpl)model;
      Property additionalProperties=modelImpl.getAdditionalProperties();
      if (additionalProperties != null) {
        if (additionalProperties instanceof RefProperty) {
          processRefProperty(((RefProperty)additionalProperties),file);
        }
 else         if (additionalProperties instanceof ArrayProperty) {
          ArrayProperty arrayProp=(ArrayProperty)additionalProperties;
          if (arrayProp.getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)arrayProp.getItems(),file);
          }
        }
 else         if (additionalProperties instanceof MapProperty) {
          MapProperty mapProp=(MapProperty)additionalProperties;
          if (mapProp.getAdditionalProperties() instanceof RefProperty) {
            processRefProperty((RefProperty)mapProp.getAdditionalProperties(),file);
          }
 else           if (mapProp.getAdditionalProperties() instanceof ArrayProperty && ((ArrayProperty)mapProp.getAdditionalProperties()).getItems() instanceof RefProperty) {
            processRefProperty((RefProperty)((ArrayProperty)mapProp.getAdditionalProperties()).getItems(),file);
          }
        }
      }
    }
    if (model instanceof ArrayModel && ((ArrayModel)model).getItems() instanceof RefProperty) {
      processRefProperty((RefProperty)((ArrayModel)model).getItems(),file);
    }
  }
  return newRef;
}