Program: 168727
Project: 168727
Buggy source:
private JoinNode getOrCreate(JoinNode baseNode,String joinRelationName,Type<?> joinRelationType,String treatType,String alias,JoinType type,String errorMessage,boolean implicit,boolean defaultJoin,Attribute<?,?> attribute){
  JoinTreeNode treeNode=baseNode.getOrCreateTreeNode(joinRelationName,attribute);
  JoinNode node=treeNode.getJoinNode(alias,defaultJoin);
  String qualificationExpression=null;
  if (attribute instanceof QualifiedAttribute) {
    qualificationExpression=((QualifiedAttribute)attribute).getQualificationExpression();
  }
  EntityType<?> treatJoinType;
  String currentJoinPath;
  if (treatType != null) {
    treatJoinType=metamodel.getEntity(treatType);
    currentJoinPath="String_Node_Str" + baseNode.getAliasInfo().getAbsolutePath() + "String_Node_Str"+ joinRelationName+ "String_Node_Str"+ treatJoinType.getName()+ "String_Node_Str";
  }
 else {
    treatJoinType=null;
    currentJoinPath=baseNode.getAliasInfo().getAbsolutePath() + "String_Node_Str" + joinRelationName;
  }
  if (node == null) {
    checkAliasIsAvailable(alias,currentJoinPath,errorMessage);
    if (implicit && aliasManager.getAliasInfo(alias) != null) {
      alias=aliasManager.generateJoinAlias(alias);
    }
    JoinAliasInfo newAliasInfo=new JoinAliasInfo(alias,currentJoinPath,implicit,false,aliasManager);
    aliasManager.registerAliasInfo(newAliasInfo);
    node=JoinNode.createAssociationJoinNode(baseNode,treeNode,type,joinRelationType,treatJoinType,qualificationExpression,newAliasInfo);
    newAliasInfo.setJoinNode(node);
    treeNode.addJoinNode(node,defaultJoin);
  }
 else {
    JoinAliasInfo nodeAliasInfo=node.getAliasInfo();
    if (!alias.equals(nodeAliasInfo.getAlias())) {
      if (nodeAliasInfo.isImplicit() && !implicit) {
        aliasManager.unregisterAliasInfoForBottomLevel(nodeAliasInfo);
        nodeAliasInfo.setAlias(alias);
        nodeAliasInfo.setImplicit(false);
        node.setJoinType(type);
        aliasManager.registerAliasInfo(nodeAliasInfo);
      }
 else       if (!nodeAliasInfo.isImplicit() && !implicit) {
        throw new IllegalArgumentException("String_Node_Str" + nodeAliasInfo.getAlias() + "String_Node_Str"+ nodeAliasInfo.getAbsolutePath()+ "String_Node_Str"+ alias+ "String_Node_Str"+ currentJoinPath+ "String_Node_Str");
      }
    }
    if (treatJoinType != null) {
      if (node.getTreatType() == null) {
        node=node.getTreatedJoinNode(treatJoinType);
      }
 else       if (!treatJoinType.equals(node.getTreatType())) {
        throw new IllegalArgumentException("String_Node_Str" + nodeAliasInfo.getAlias() + "String_Node_Str"+ nodeAliasInfo.getAbsolutePath()+ "String_Node_Str"+ "String_Node_Str"+ treatType+ "String_Node_Str"+ node.getTreatType()+ "String_Node_Str");
      }
    }
  }
  return node;
}

Fixed version (ground truth):
private JoinNode getOrCreate(JoinNode baseNode,String joinRelationName,Type<?> joinRelationType,String treatType,String alias,JoinType type,String errorMessage,boolean implicit,boolean defaultJoin,Attribute<?,?> attribute){
  JoinTreeNode treeNode=baseNode.getOrCreateTreeNode(joinRelationName,attribute);
  JoinNode node=treeNode.getJoinNode(alias,defaultJoin);
  String qualificationExpression=null;
  String qualifiedJoinPath;
  if (attribute instanceof QualifiedAttribute) {
    QualifiedAttribute qualifiedAttribute=(QualifiedAttribute)attribute;
    qualificationExpression=qualifiedAttribute.getQualificationExpression();
    qualifiedJoinPath=joinRelationName.substring(0,qualificationExpression.length() + 1) + baseNode.getAliasInfo().getAbsolutePath() + "String_Node_Str"+ joinRelationName.substring(qualificationExpression.length() + 1);
  }
 else {
    qualifiedJoinPath=baseNode.getAliasInfo().getAbsolutePath() + "String_Node_Str" + joinRelationName;
  }
  EntityType<?> treatJoinType;
  String currentJoinPath;
  if (treatType != null) {
    treatJoinType=metamodel.getEntity(treatType);
    currentJoinPath="String_Node_Str" + qualifiedJoinPath + "String_Node_Str"+ treatJoinType.getName()+ "String_Node_Str";
  }
 else {
    treatJoinType=null;
    currentJoinPath=qualifiedJoinPath;
  }
  if (node == null) {
    checkAliasIsAvailable(alias,currentJoinPath,errorMessage);
    if (implicit && aliasManager.getAliasInfo(alias) != null) {
      alias=aliasManager.generateJoinAlias(alias);
    }
    JoinAliasInfo newAliasInfo=new JoinAliasInfo(alias,currentJoinPath,implicit,false,aliasManager);
    aliasManager.registerAliasInfo(newAliasInfo);
    node=JoinNode.createAssociationJoinNode(baseNode,treeNode,type,joinRelationType,treatJoinType,qualificationExpression,newAliasInfo);
    newAliasInfo.setJoinNode(node);
    treeNode.addJoinNode(node,defaultJoin);
  }
 else {
    JoinAliasInfo nodeAliasInfo=node.getAliasInfo();
    if (!alias.equals(nodeAliasInfo.getAlias())) {
      if (nodeAliasInfo.isImplicit() && !implicit) {
        aliasManager.unregisterAliasInfoForBottomLevel(nodeAliasInfo);
        nodeAliasInfo.setAlias(alias);
        nodeAliasInfo.setImplicit(false);
        node.setJoinType(type);
        aliasManager.registerAliasInfo(nodeAliasInfo);
      }
 else       if (!nodeAliasInfo.isImplicit() && !implicit) {
        throw new IllegalArgumentException("String_Node_Str" + nodeAliasInfo.getAlias() + "String_Node_Str"+ nodeAliasInfo.getAbsolutePath()+ "String_Node_Str"+ alias+ "String_Node_Str"+ currentJoinPath+ "String_Node_Str");
      }
    }
    if (treatJoinType != null) {
      if (node.getTreatType() == null) {
        node=node.getTreatedJoinNode(treatJoinType);
      }
 else       if (!treatJoinType.equals(node.getTreatType())) {
        throw new IllegalArgumentException("String_Node_Str" + nodeAliasInfo.getAlias() + "String_Node_Str"+ nodeAliasInfo.getAbsolutePath()+ "String_Node_Str"+ "String_Node_Str"+ treatType+ "String_Node_Str"+ node.getTreatType()+ "String_Node_Str");
      }
    }
  }
  return node;
}