Program: 95931
Project: 95931
Buggy source:
static void compressTwoNode(ExecutableNodeBase node,ExecutableNodeBase parent){
  if (!(node instanceof QueryNodeBase) || !(parent instanceof QueryNodeBase)) {
    return;
  }
  QueryNodeBase parentQuery=(QueryNodeBase)parent;
  QueryNodeBase nodeQuery=(QueryNodeBase)node;
  BaseTable placeholderTableinParent=((QueryNodeWithPlaceHolders)parent).getPlaceholderTables().get(parent.getExecutableNodeBaseDependents().indexOf(node));
  ((QueryNodeWithPlaceHolders)parent).getPlaceholderTables().remove(placeholderTableinParent);
  boolean find=false;
  for (  AbstractRelation table : parentQuery.getSelectQuery().getFromList()) {
    if (table instanceof BaseTable && table.equals(placeholderTableinParent)) {
      int index=parentQuery.getSelectQuery().getFromList().indexOf(table);
      nodeQuery.getSelectQuery().setAliasName(parentQuery.getSelectQuery().getFromList().get(index).getAliasName().get());
      parentQuery.getSelectQuery().getFromList().set(index,nodeQuery.getSelectQuery());
      find=true;
      break;
    }
 else     if (table instanceof JoinTable) {
      for (      AbstractRelation joinTable : ((JoinTable)table).getJoinList()) {
        if (joinTable instanceof BaseTable && joinTable.equals(placeholderTableinParent)) {
          int index=((JoinTable)table).getJoinList().indexOf(joinTable);
          nodeQuery.getSelectQuery().setAliasName(joinTable.getAliasName().get());
          ((JoinTable)table).getJoinList().set(index,nodeQuery.getSelectQuery());
          find=true;
          break;
        }
      }
      if (find)       break;
    }
  }
  if (!find) {
    List<SubqueryColumn> placeholderTablesinFilter=((QueryNodeWithPlaceHolders)parent).getPlaceholderTablesinFilter();
    for (    SubqueryColumn filter : placeholderTablesinFilter) {
      if (filter.getSubquery().getFromList().size() == 1 && filter.getSubquery().getFromList().get(0).equals(placeholderTableinParent)) {
        filter.setSubquery(nodeQuery.getSelectQuery());
      }
    }
  }
  ((QueryNodeWithPlaceHolders)parent).getPlaceholderTables().addAll(((QueryNodeWithPlaceHolders)node).getPlaceholderTables());
  parentQuery.cancelSubscriptionTo(nodeQuery);
  for (  Pair<ExecutableNodeBase,Integer> s : nodeQuery.getSourcesAndChannels()) {
    parentQuery.subscribeTo(s.getLeft(),s.getRight());
  }
}

Fixed version (ground truth):
static void compressTwoNode(ExecutableNodeBase node,ExecutableNodeBase parent){
  if (!(node instanceof QueryNodeBase) || !(parent instanceof QueryNodeBase)) {
    return;
  }
  QueryNodeBase parentQuery=(QueryNodeBase)parent;
  QueryNodeBase nodeQuery=(QueryNodeBase)node;
  PlaceHolderRecord placeholderRecordinParent=((QueryNodeWithPlaceHolders)parent).getPlaceholderRecords().get(parent.getExecutableNodeBaseDependents().indexOf(node));
  ((QueryNodeWithPlaceHolders)parent).getPlaceholderRecords().remove(placeholderRecordinParent);
  BaseTable placeholderTableinParent=placeholderRecordinParent.getPlaceholderTable();
  boolean find=false;
  for (  AbstractRelation table : parentQuery.getSelectQuery().getFromList()) {
    if (table instanceof BaseTable && table.equals(placeholderTableinParent)) {
      int index=parentQuery.getSelectQuery().getFromList().indexOf(table);
      nodeQuery.getSelectQuery().setAliasName(parentQuery.getSelectQuery().getFromList().get(index).getAliasName().get());
      parentQuery.getSelectQuery().getFromList().set(index,nodeQuery.getSelectQuery());
      find=true;
      break;
    }
 else     if (table instanceof JoinTable) {
      for (      AbstractRelation joinTable : ((JoinTable)table).getJoinList()) {
        if (joinTable instanceof BaseTable && joinTable.equals(placeholderTableinParent)) {
          int index=((JoinTable)table).getJoinList().indexOf(joinTable);
          nodeQuery.getSelectQuery().setAliasName(joinTable.getAliasName().get());
          ((JoinTable)table).getJoinList().set(index,nodeQuery.getSelectQuery());
          find=true;
          break;
        }
      }
      if (find)       break;
    }
  }
  if (!find) {
    List<SubqueryColumn> placeholderTablesinFilter=((QueryNodeWithPlaceHolders)parent).getPlaceholderTablesinFilter();
    for (    SubqueryColumn filter : placeholderTablesinFilter) {
      if (filter.getSubquery().getFromList().size() == 1 && filter.getSubquery().getFromList().get(0).equals(placeholderTableinParent)) {
        filter.setSubquery(nodeQuery.getSelectQuery());
      }
    }
  }
  ((QueryNodeWithPlaceHolders)parent).getPlaceholderRecords().addAll(((QueryNodeWithPlaceHolders)node).getPlaceholderRecords());
  parentQuery.cancelSubscriptionTo(nodeQuery);
  for (  Pair<ExecutableNodeBase,Integer> s : nodeQuery.getSourcesAndChannels()) {
    parentQuery.subscribeTo(s.getLeft(),s.getRight());
  }
}