Program: 71750
Project: 71750
Buggy source:
/** 
 * @param session
 * @param queryDefn
 * @param queryResults
 */
public static void merge(DataEngineSession session,IBaseQueryDefinition queryDefn,IQueryResults queryResults){
  try {
    if (session == null || queryResults.getResultMetaData() == null || queryResults.getResultMetaData().getColumnCount() == 0)     return;
  }
 catch (  BirtException e) {
    return;
  }
  String elementId=queryDefn.getName();
  String bookmark=queryResults.getName();
  String rsId=queryResults.getID();
  NamingRelation relation=session.getNamingRelation();
  if (relation == null) {
    relation=new NamingRelation();
    session.setNamingRelation(relation);
  }
  Map bookmarkMap=relation.getBookmarkMap();
  Map elementIdMap=relation.getElementIdMap();
  if (bookmark != null) {
    if (bookmarkMap.get(bookmark) == null) {
      bookmarkMap.put(bookmark,rsId);
    }
 else {
      Object value=bookmarkMap.get(bookmark);
      if (value instanceof String) {
        Map subMap=new HashMap();
        subMap.put(getSubKey(subMap),value);
        bookmarkMap.put(bookmark,subMap);
      }
 else       if (value instanceof Map) {
        Map subMap=(Map)value;
        subMap.put(getSubKey(subMap),rsId);
      }
    }
  }
  if (elementId != null) {
    if (elementIdMap.get(elementId) == null) {
      elementIdMap.put(elementId,rsId);
    }
 else {
      Object value=elementIdMap.get(elementId);
      if (value instanceof String) {
        Map subMap=new HashMap();
        subMap.put(getSubKey(subMap),value);
        elementIdMap.put(elementId,subMap);
      }
 else       if (value instanceof Map) {
        Map subMap=(Map)value;
        subMap.put(getSubKey(subMap),rsId);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param session
 * @param queryDefn
 * @param queryResults
 */
public static void merge(DataEngineSession session,IBaseQueryDefinition queryDefn,IQueryResults queryResults){
  try {
    if (session == null || queryResults.getResultMetaData() == null || queryResults.getResultMetaData().getColumnCount() == 0 || queryDefn instanceof ISubqueryDefinition)     return;
  }
 catch (  BirtException e) {
    return;
  }
  String elementId=queryDefn.getName();
  String bookmark=queryResults.getName();
  String rsId=queryResults.getID();
  NamingRelation relation=session.getNamingRelation();
  if (relation == null) {
    relation=new NamingRelation();
    session.setNamingRelation(relation);
  }
  Map bookmarkMap=relation.getBookmarkMap();
  Map elementIdMap=relation.getElementIdMap();
  if (bookmark != null) {
    if (bookmarkMap.get(bookmark) == null) {
      bookmarkMap.put(bookmark,rsId);
    }
 else {
      Object value=bookmarkMap.get(bookmark);
      if (value instanceof String) {
        Map subMap=new HashMap();
        subMap.put(getSubKey(subMap),value);
        bookmarkMap.put(bookmark,subMap);
      }
 else       if (value instanceof Map) {
        Map subMap=(Map)value;
        subMap.put(getSubKey(subMap),rsId);
      }
    }
  }
  if (elementId != null) {
    if (elementIdMap.get(elementId) == null) {
      elementIdMap.put(elementId,rsId);
    }
 else {
      Object value=elementIdMap.get(elementId);
      if (value instanceof String) {
        Map subMap=new HashMap();
        subMap.put(getSubKey(subMap),value);
        elementIdMap.put(elementId,subMap);
      }
 else       if (value instanceof Map) {
        Map subMap=(Map)value;
        subMap.put(getSubKey(subMap),rsId);
      }
    }
  }
}