Program: 69890
Project: 69890
Buggy source:
/** 
 * Launch a controller in a tab or site in the given window from a user request url
 * @param ureq
 * @param wControl
 */
public boolean launch(UserRequest ureq,WindowControl wControl){
  BusinessControl bc=wControl.getBusinessControl();
  ContextEntry mainCe=bc.popLauncherContextEntry();
  OLATResourceable ores=mainCe.getOLATResourceable();
  boolean ceConsumed=false;
  RepositoryEntry re=null;
  if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(RepositoryEntry.class))) {
    RepositoryManager repom=RepositoryManager.getInstance();
    re=repom.lookupRepositoryEntry(ores.getResourceableId());
    if (re != null) {
      ores=re.getOlatResource();
      ceConsumed=true;
    }
  }
  UserSession usess=ureq.getUserSession();
  Window window=Windows.getWindows(usess).getWindow(ureq);
  if (window == null) {
    logDebug("String_Node_Str",null);
    window=wControl.getWindowBackOffice().getWindow();
  }
  DTabs dts=(DTabs)window.getAttribute("String_Node_Str");
  DTab dt=dts.getDTab(ores);
  if (dt != null) {
    dts.removeDTab(ureq,dt);
  }
  String firstType=mainCe.getOLATResourceable().getResourceableTypeName();
  ContextEntryControllerCreator typeHandler=contextEntryControllerCreators.get(firstType);
  if (typeHandler == null) {
    logWarn("String_Node_Str" + mainCe,null);
    return false;
  }
  if (!typeHandler.validateContextEntryAndShowError(mainCe,ureq,wControl)) {
    return false;
  }
  String siteClassName=typeHandler.getSiteClassName(mainCe,ureq);
  if (siteClassName != null) {
    List<ContextEntry> entries=new ArrayList<ContextEntry>();
    if (bc.hasContextEntry()) {
      ContextEntry subContext=bc.popLauncherContextEntry();
      if (subContext != null) {
        entries.add(subContext);
        while (bc.hasContextEntry()) {
          entries.add(bc.popLauncherContextEntry());
        }
      }
    }
 else     if (!ceConsumed) {
      if (ores != null) {
        entries.add(BusinessControlFactory.getInstance().createContextEntry(ores));
      }
    }
    TabContext context=typeHandler.getTabContext(ureq,ores,mainCe,entries);
    dts.activateStatic(ureq,siteClassName,context.getContext());
    return true;
  }
 else {
    List<ContextEntry> entries=new ArrayList<ContextEntry>();
    while (bc.hasContextEntry()) {
      entries.add(bc.popLauncherContextEntry());
    }
    TabContext context=typeHandler.getTabContext(ureq,ores,mainCe,entries);
    dt=dts.createDTab(context.getTabResource(),re,context.getName());
    if (dt == null) {
      return false;
    }
 else {
      WindowControl bwControl=BusinessControlFactory.getInstance().createBusinessWindowControl(bc,dt.getWindowControl());
      usess.addToHistory(ureq,bc);
      Controller launchC=typeHandler.createController(mainCe,ureq,bwControl);
      if (launchC == null) {
        throw new AssertException("String_Node_Str" + bc.getAsString() + "String_Node_Str"+ typeHandler.getClass().getName()+ "String_Node_Str");
      }
      dt.setController(launchC);
      dts.addDTab(ureq,dt);
      dts.activate(ureq,dt,context.getContext());
      return true;
    }
  }
}

Fixed version (ground truth):
/** 
 * Launch a controller in a tab or site in the given window from a user request url
 * @param ureq
 * @param wControl
 */
public boolean launch(UserRequest ureq,WindowControl wControl){
  BusinessControl bc=wControl.getBusinessControl();
  ContextEntry mainCe=bc.popLauncherContextEntry();
  OLATResourceable ores=mainCe.getOLATResourceable();
  boolean ceConsumed=false;
  RepositoryEntry re=null;
  if (ores.getResourceableTypeName().equals(OresHelper.calculateTypeName(RepositoryEntry.class))) {
    RepositoryManager repom=RepositoryManager.getInstance();
    re=repom.lookupRepositoryEntry(ores.getResourceableId());
    if (re != null) {
      ores=re.getOlatResource();
      ceConsumed=true;
    }
  }
  UserSession usess=ureq.getUserSession();
  Window window=Windows.getWindows(usess).getWindow(ureq);
  if (window == null) {
    logDebug("String_Node_Str",null);
    window=wControl.getWindowBackOffice().getWindow();
  }
  DTabs dts=(DTabs)window.getAttribute("String_Node_Str");
  DTab dt=dts.getDTab(ores);
  if (dt != null) {
    dts.removeDTab(ureq,dt);
  }
  String firstType=mainCe.getOLATResourceable().getResourceableTypeName();
  ContextEntryControllerCreator typeHandler=contextEntryControllerCreators.get(firstType);
  if (typeHandler == null) {
    logWarn("String_Node_Str" + mainCe,null);
    return false;
  }
  if (!typeHandler.validateContextEntryAndShowError(mainCe,ureq,wControl)) {
    return false;
  }
  String siteClassName=typeHandler.getSiteClassName(mainCe,ureq);
  if (siteClassName != null) {
    List<ContextEntry> entries=new ArrayList<ContextEntry>();
    if (bc.hasContextEntry()) {
      ContextEntry subContext=bc.popLauncherContextEntry();
      if (subContext != null) {
        entries.add(subContext);
        while (bc.hasContextEntry()) {
          entries.add(bc.popLauncherContextEntry());
        }
      }
    }
 else     if (!ceConsumed) {
      if (ores != null) {
        entries.add(BusinessControlFactory.getInstance().createContextEntry(ores));
      }
    }
    TabContext context=typeHandler.getTabContext(ureq,ores,mainCe,entries);
    dts.activateStatic(ureq,siteClassName,context.getContext());
    return true;
  }
 else {
    List<ContextEntry> entries=new ArrayList<ContextEntry>();
    while (bc.hasContextEntry()) {
      entries.add(bc.popLauncherContextEntry());
    }
    TabContext context=typeHandler.getTabContext(ureq,ores,mainCe,entries);
    dt=dts.createDTab(context.getTabResource(),re,context.getName());
    if (dt == null) {
      return false;
    }
 else {
      WindowControl bwControl=BusinessControlFactory.getInstance().createBusinessWindowControl(bc,dt.getWindowControl());
      usess.addToHistory(ureq,bc);
      Controller launchC=typeHandler.createController(mainCe,ureq,bwControl);
      if (launchC == null) {
        throw new AssertException("String_Node_Str" + bc.getAsString() + "String_Node_Str"+ typeHandler.getClass().getName()+ "String_Node_Str");
      }
      dt.setController(launchC);
      if (dts.addDTab(ureq,dt)) {
        dts.activate(ureq,dt,context.getContext());
        return true;
      }
 else {
        return false;
      }
    }
  }
}