Program: 16150
Project: 16150
Buggy source:
/** 
 * It assumes exactly one of pagedef and richlet is not null. 
 */
private void execNewPage0(final Execution exec,final PageDefinition pagedef,final Richlet richlet,final Page page,final Writer out) throws IOException {
  final Desktop desktop=exec.getDesktop();
  final DesktopCtrl desktopCtrl=(DesktopCtrl)desktop;
  final LanguageDefinition langdef=pagedef != null ? pagedef.getLanguageDefinition() : richlet != null ? richlet.getLanguageDefinition() : null;
  if (langdef != null)   desktop.setDeviceType(langdef.getDeviceType());
  final WebApp wapp=desktop.getWebApp();
  final Configuration config=wapp.getConfiguration();
  PerformanceMeter pfmeter=config.getPerformanceMeter();
  final long startTime=pfmeter != null ? System.currentTimeMillis() : 0;
  final Execution oldexec=Executions.getCurrent();
  final ExecutionCtrl oldexecCtrl=(ExecutionCtrl)oldexec;
  final UiVisualizer olduv=oldexecCtrl != null ? (UiVisualizer)oldexecCtrl.getVisualizer() : null;
  final UiVisualizer uv;
  if (olduv != null) {
    uv=doReactivate(exec,olduv);
    pfmeter=null;
  }
 else {
    uv=doActivate(exec,false,false,null,-1);
  }
  final ExecutionCtrl execCtrl=(ExecutionCtrl)exec;
  final Page old=execCtrl.getCurrentPage();
  final PageDefinition olddef=execCtrl.getCurrentPageDefinition();
  execCtrl.setCurrentPage(page);
  execCtrl.setCurrentPageDefinition(pagedef);
  final String pfReqId=pfmeter != null ? meterLoadStart(pfmeter,exec,startTime) : null;
  AbortingReason abrn=null;
  try {
    config.invokeExecutionInits(exec,oldexec);
    desktopCtrl.invokeExecutionInits(exec,oldexec);
    if (olduv != null) {
      final Component owner=olduv.getOwner();
      if (owner != null) {
        ((PageCtrl)page).setOwner(owner);
      }
    }
    if (pagedef != null) {
      ((PageCtrl)page).preInit();
      pagedef.preInit(page);
      final Initiators inits=Initiators.doInit(pagedef,page,config.getInitiators());
      try {
        pagedef.init(page,!uv.isEverAsyncUpdate() && !uv.isAborting());
        final Component[] comps;
        final String uri=pagedef.getForwardURI(page);
        if (uri != null) {
          comps=new Component[0];
          exec.forward(uri);
        }
 else {
          comps=uv.isAborting() || exec.isVoided() ? new Component[0] : execCreate(new CreateInfo(((WebAppCtrl)wapp).getUiFactory(),exec,page,config.getComposer(page)),pagedef,null,null);
        }
        inits.doAfterCompose(page,comps);
        afterCreate(exec,comps);
      }
 catch (      Throwable ex) {
        if (!inits.doCatch(ex))         throw UiException.Aide.wrap(ex);
      }
 finally {
        inits.doFinally();
      }
    }
 else {
      ((PageCtrl)page).preInit();
      final Initiators inits=Initiators.doInit(null,page,config.getInitiators());
      try {
        ((PageCtrl)page).init(new PageConfig(){
          public String getId(){
            return null;
          }
          public String getUuid(){
            return null;
          }
          public String getTitle(){
            return null;
          }
          public String getStyle(){
            return null;
          }
          public String getViewport(){
            return "String_Node_Str";
          }
          public String getBeforeHeadTags(){
            return "String_Node_Str";
          }
          public String getAfterHeadTags(){
            return "String_Node_Str";
          }
          public Collection<Object[]> getResponseHeaders(){
            return Collections.emptyList();
          }
        }
);
        final Composer composer=config.getComposer(page);
        try {
          richlet.service(page);
          for (Component root=page.getFirstRoot(); root != null; root=root.getNextSibling()) {
            doAfterCompose(composer,root);
            afterCreate(exec,new Component[]{root});
          }
        }
 catch (        Throwable t) {
          if (composer instanceof ComposerExt)           if (((ComposerExt)composer).doCatch(t))           t=null;
          if (t != null)           throw t;
        }
 finally {
          if (composer instanceof ComposerExt)           ((ComposerExt)composer).doFinally();
        }
      }
 catch (      Throwable ex) {
        if (!inits.doCatch(ex))         throw UiException.Aide.wrap(ex);
      }
 finally {
        inits.doFinally();
      }
    }
    if (exec.isVoided())     return;
    final List<Throwable> errs=new LinkedList<Throwable>();
    Event event=nextEvent(uv);
    do {
      for (; event != null; event=nextEvent(uv)) {
        try {
          process(desktop,event);
        }
 catch (        Throwable ex) {
          handleError(ex,uv,errs);
        }
      }
      resumeAll(desktop,uv,null);
    }
 while ((event=nextEvent(uv)) != null);
    abrn=uv.getAbortingReason();
    if (abrn != null)     abrn.execute();
    List<AuResponse> responses=getResponses(exec,uv,errs,false);
    if (olduv != null && olduv.addToFirstAsyncUpdate(responses))     responses=null;
 else     execCtrl.setResponses(responses);
    ((PageCtrl)page).redraw(out);
    afterRenderNewPage(page);
    desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
    config.invokeExecutionCleanups(exec,oldexec,errs);
  }
 catch (  Throwable ex) {
    final List<Throwable> errs=new LinkedList<Throwable>();
    errs.add(ex);
    desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
    config.invokeExecutionCleanups(exec,oldexec,errs);
    if (!errs.isEmpty()) {
      ex=errs.get(0);
      if (ex instanceof IOException)       throw (IOException)ex;
      throw UiException.Aide.wrap(ex);
    }
  }
 finally {
    if (abrn != null) {
      try {
        abrn.finish();
      }
 catch (      Throwable t) {
        log.warning(t);
      }
    }
    execCtrl.setCurrentPage(old);
    execCtrl.setCurrentPageDefinition(olddef);
    if (olduv != null)     doDereactivate(exec,olduv);
 else     doDeactivate(exec);
    if (pfmeter != null)     meterLoadServerComplete(pfmeter,pfReqId,exec);
  }
}

Fixed version (ground truth):
/** 
 * It assumes exactly one of pagedef and richlet is not null. 
 */
private void execNewPage0(final Execution exec,final PageDefinition pagedef,final Richlet richlet,final Page page,final Writer out) throws IOException {
  final Desktop desktop=exec.getDesktop();
  final DesktopCtrl desktopCtrl=(DesktopCtrl)desktop;
  final LanguageDefinition langdef=pagedef != null ? pagedef.getLanguageDefinition() : richlet != null ? richlet.getLanguageDefinition() : null;
  if (langdef != null)   desktop.setDeviceType(langdef.getDeviceType());
  final WebApp wapp=desktop.getWebApp();
  final Configuration config=wapp.getConfiguration();
  PerformanceMeter pfmeter=config.getPerformanceMeter();
  final long startTime=pfmeter != null ? System.currentTimeMillis() : 0;
  final Execution oldexec=Executions.getCurrent();
  final ExecutionCtrl oldexecCtrl=(ExecutionCtrl)oldexec;
  final UiVisualizer olduv=oldexecCtrl != null ? (UiVisualizer)oldexecCtrl.getVisualizer() : null;
  final UiVisualizer uv;
  if (olduv != null) {
    uv=doReactivate(exec,olduv);
    pfmeter=null;
  }
 else {
    uv=doActivate(exec,false,false,null,-1);
  }
  final ExecutionCtrl execCtrl=(ExecutionCtrl)exec;
  final Page old=execCtrl.getCurrentPage();
  final PageDefinition olddef=execCtrl.getCurrentPageDefinition();
  execCtrl.setCurrentPage(page);
  execCtrl.setCurrentPageDefinition(pagedef);
  final String pfReqId=pfmeter != null ? meterLoadStart(pfmeter,exec,startTime) : null;
  AbortingReason abrn=null;
  try {
    config.invokeExecutionInits(exec,oldexec);
    desktopCtrl.invokeExecutionInits(exec,oldexec);
    if (olduv != null) {
      final Component owner=olduv.getOwner();
      if (owner != null) {
        ((PageCtrl)page).setOwner(owner);
      }
    }
    if (pagedef != null) {
      ((PageCtrl)page).preInit();
      pagedef.preInit(page);
      final Initiators inits=Initiators.doInit(pagedef,page,config.getInitiators());
      try {
        pagedef.init(page,!uv.isEverAsyncUpdate() && !uv.isAborting());
        final Component[] comps;
        final String uri=pagedef.getForwardURI(page);
        if (uri != null) {
          comps=new Component[0];
          try {
            exec.forward(uri);
          }
  finally {
            final List<Throwable> errs=new LinkedList<Throwable>();
            desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
            config.invokeExecutionCleanups(exec,oldexec,errs);
          }
        }
 else {
          comps=uv.isAborting() || exec.isVoided() ? new Component[0] : execCreate(new CreateInfo(((WebAppCtrl)wapp).getUiFactory(),exec,page,config.getComposer(page)),pagedef,null,null);
        }
        inits.doAfterCompose(page,comps);
        afterCreate(exec,comps);
      }
 catch (      Throwable ex) {
        if (!inits.doCatch(ex))         throw UiException.Aide.wrap(ex);
      }
 finally {
        inits.doFinally();
      }
    }
 else {
      ((PageCtrl)page).preInit();
      final Initiators inits=Initiators.doInit(null,page,config.getInitiators());
      try {
        ((PageCtrl)page).init(new PageConfig(){
          public String getId(){
            return null;
          }
          public String getUuid(){
            return null;
          }
          public String getTitle(){
            return null;
          }
          public String getStyle(){
            return null;
          }
          public String getViewport(){
            return "String_Node_Str";
          }
          public String getBeforeHeadTags(){
            return "String_Node_Str";
          }
          public String getAfterHeadTags(){
            return "String_Node_Str";
          }
          public Collection<Object[]> getResponseHeaders(){
            return Collections.emptyList();
          }
        }
);
        final Composer composer=config.getComposer(page);
        try {
          richlet.service(page);
          for (Component root=page.getFirstRoot(); root != null; root=root.getNextSibling()) {
            doAfterCompose(composer,root);
            afterCreate(exec,new Component[]{root});
          }
        }
 catch (        Throwable t) {
          if (composer instanceof ComposerExt)           if (((ComposerExt)composer).doCatch(t))           t=null;
          if (t != null)           throw t;
        }
 finally {
          if (composer instanceof ComposerExt)           ((ComposerExt)composer).doFinally();
        }
      }
 catch (      Throwable ex) {
        if (!inits.doCatch(ex))         throw UiException.Aide.wrap(ex);
      }
 finally {
        inits.doFinally();
      }
    }
    if (exec.isVoided())     return;
    final List<Throwable> errs=new LinkedList<Throwable>();
    Event event=nextEvent(uv);
    do {
      for (; event != null; event=nextEvent(uv)) {
        try {
          process(desktop,event);
        }
 catch (        Throwable ex) {
          handleError(ex,uv,errs);
        }
      }
      resumeAll(desktop,uv,null);
    }
 while ((event=nextEvent(uv)) != null);
    abrn=uv.getAbortingReason();
    if (abrn != null)     abrn.execute();
    List<AuResponse> responses=getResponses(exec,uv,errs,false);
    if (olduv != null && olduv.addToFirstAsyncUpdate(responses))     responses=null;
 else     execCtrl.setResponses(responses);
    ((PageCtrl)page).redraw(out);
    afterRenderNewPage(page);
    desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
    config.invokeExecutionCleanups(exec,oldexec,errs);
  }
 catch (  Throwable ex) {
    final List<Throwable> errs=new LinkedList<Throwable>();
    errs.add(ex);
    desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
    config.invokeExecutionCleanups(exec,oldexec,errs);
    if (!errs.isEmpty()) {
      ex=errs.get(0);
      if (ex instanceof IOException)       throw (IOException)ex;
      throw UiException.Aide.wrap(ex);
    }
  }
 finally {
    if (abrn != null) {
      try {
        abrn.finish();
      }
 catch (      Throwable t) {
        log.warning(t);
      }
    }
    execCtrl.setCurrentPage(old);
    execCtrl.setCurrentPageDefinition(olddef);
    if (olduv != null)     doDereactivate(exec,olduv);
 else     doDeactivate(exec);
    if (pfmeter != null)     meterLoadServerComplete(pfmeter,pfReqId,exec);
  }
}