Program: 176489
Project: 176489
Buggy source:
/** 
 * @param node
 * @return
 */
protected List<RelationHolder> getRelationHolders(Node node){
  List<RelationHolder> relationsHolder=new ArrayList<RelationHolder>();
  Map<NodeLink,Node> parents=node.getParents();
  Map<NodeLink,Node> children=node.getChildren();
  if (parents != null && !parents.isEmpty()) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      String linkName=(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
      Object linkValue=parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE);
      boolean isSharedByPrimaryKey=(Boolean)parentNodeLink.getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
      Relation.ForeignKey multiplicity=parentNodeLink.getMultiplicity();
      if (linkName != null && linkValue != null && !isSharedByPrimaryKey && multiplicity.equals(ForeignKey.ONE_TO_MANY)) {
        RelationHolder relationHolder=new RelationHolder(linkName,linkValue);
        relationsHolder.add(relationHolder);
      }
    }
  }
  if (children != null && !children.isEmpty()) {
    for (    NodeLink childNodeLink : children.keySet()) {
      String linkName=(String)childNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
      Object linkValue=childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE);
      boolean isSharedByPrimaryKey=(Boolean)childNodeLink.getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
      Relation.ForeignKey multiplicity=childNodeLink.getMultiplicity();
      if (linkName != null && linkValue != null && !isSharedByPrimaryKey) {
        if (multiplicity.equals(ForeignKey.ONE_TO_ONE) || multiplicity.equals(ForeignKey.MANY_TO_ONE)) {
          RelationHolder relationHolder=new RelationHolder(linkName,linkValue);
          relationsHolder.add(relationHolder);
        }
 else         if (multiplicity.equals(ForeignKey.MANY_TO_MANY) && ((Field)childNodeLink.getLinkProperty(LinkProperty.PROPERTY)).getType().isAssignableFrom(Map.class)) {
          Object relationTo=((Node)children.get(childNodeLink)).getData();
          RelationHolder relationHolder=new RelationHolder(linkName,relationTo,linkValue);
          relationsHolder.add(relationHolder);
        }
      }
    }
  }
  return relationsHolder;
}

Fixed version (ground truth):
/** 
 * @param node
 * @return
 */
protected List<RelationHolder> getRelationHolders(Node node){
  List<RelationHolder> relationsHolder=new ArrayList<RelationHolder>();
  Map<NodeLink,Node> parents=node.getParents();
  Map<NodeLink,Node> children=node.getChildren();
  if (parents != null && !parents.isEmpty()) {
    for (    NodeLink parentNodeLink : parents.keySet()) {
      String linkName=(String)parentNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
      Object linkValue=parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) != null ? parentNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) : parents.get(parentNodeLink).getEntityId();
      boolean isSharedByPrimaryKey=(Boolean)parentNodeLink.getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
      Relation.ForeignKey multiplicity=parentNodeLink.getMultiplicity();
      if (linkName != null && linkValue != null && !isSharedByPrimaryKey && multiplicity.equals(ForeignKey.ONE_TO_MANY)) {
        RelationHolder relationHolder=new RelationHolder(linkName,linkValue);
        relationsHolder.add(relationHolder);
      }
    }
  }
  if (children != null && !children.isEmpty()) {
    for (    NodeLink childNodeLink : children.keySet()) {
      String linkName=(String)childNodeLink.getLinkProperty(LinkProperty.LINK_NAME);
      Object linkValue=childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) != null ? childNodeLink.getLinkProperty(LinkProperty.LINK_VALUE) : children.get(childNodeLink).getEntityId();
      boolean isSharedByPrimaryKey=(Boolean)childNodeLink.getLinkProperty(LinkProperty.IS_SHARED_BY_PRIMARY_KEY);
      Relation.ForeignKey multiplicity=childNodeLink.getMultiplicity();
      if (linkName != null && linkValue != null && !isSharedByPrimaryKey) {
        if (multiplicity.equals(ForeignKey.ONE_TO_ONE) || multiplicity.equals(ForeignKey.MANY_TO_ONE)) {
          RelationHolder relationHolder=new RelationHolder(linkName,linkValue);
          relationsHolder.add(relationHolder);
        }
 else         if (multiplicity.equals(ForeignKey.MANY_TO_MANY) && ((Field)childNodeLink.getLinkProperty(LinkProperty.PROPERTY)).getType().isAssignableFrom(Map.class)) {
          Object relationTo=((Node)children.get(childNodeLink)).getData();
          RelationHolder relationHolder=new RelationHolder(linkName,relationTo,linkValue);
          relationsHolder.add(relationHolder);
        }
      }
    }
  }
  return relationsHolder;
}