Program: 16266
Project: 16266
Buggy source:
/** 
 * Retrieves the media from   {@link DynamicMedia#getMedia}.
 */
public void service(HttpServletRequest request,HttpServletResponse response,String pi) throws ServletException, IOException {
  final Session sess=Sessions.getCurrent(false);
  if (sess == null) {
    response.sendError(response.SC_GONE,Messages.get(MZk.PAGE_NOT_FOUND,pi));
    return;
  }
  int j=pi.indexOf('/',1) + 1;
  int k=pi.indexOf('/',j);
  if (j <= 0 || k <= 0)   throw new ServletException("String_Node_Str" + pi);
  final String dtid=pi.substring(j,k);
  final int l=pi.indexOf('/',++k);
  final String uuid=l >= 0 ? pi.substring(k,l) : pi.substring(k);
  Media media;
  boolean download=false;
  try {
    final WebApp wapp=sess.getWebApp();
    final WebAppCtrl wappc=(WebAppCtrl)wapp;
    final UiEngine uieng=wappc.getUiEngine();
    final Desktop desktop=wappc.getDesktopCache(sess).getDesktop(dtid);
    final DesktopCtrl desktopCtrl=(DesktopCtrl)desktop;
    final Execution oldexec=Executions.getCurrent();
    final Execution exec=new ExecutionImpl(_ctx,request,response,desktop,null);
    uieng.activate(exec);
    final Configuration config=wapp.getConfiguration();
    boolean err=false;
    try {
      config.invokeExecutionInits(exec,oldexec);
      desktopCtrl.invokeExecutionInits(exec,oldexec);
      media=desktopCtrl.getDownloadMedia(uuid,false);
      if (media != null) {
        download=true;
      }
 else {
        final Component comp=desktop.getComponentByUuid(uuid);
        final Object cc=((ComponentCtrl)comp).getExtraCtrl();
        if (!(cc instanceof DynamicMedia))         throw new ServletException(DynamicMedia.class + "String_Node_Str" + comp);
        int m=l >= 0 ? pi.indexOf('/',l + 1) : -1;
        if (m < 0)         m=l;
        media=((DynamicMedia)cc).getMedia(m >= 0 ? pi.substring(m) : "String_Node_Str");
        if (media == null) {
          response.sendError(response.SC_GONE,Messages.get(MZk.PAGE_NOT_FOUND,pi + "String_Node_Str" + comp));
          return;
        }
      }
    }
 catch (    Throwable ex) {
      err=true;
      final List<Throwable> errs=new LinkedList<Throwable>();
      errs.add(ex);
      desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
      config.invokeExecutionCleanups(exec,oldexec,errs);
      final StringBuffer errmsg=new StringBuffer(100);
      if (!errs.isEmpty()) {
        for (Iterator it=errs.iterator(); it.hasNext(); ) {
          final Throwable t=(Throwable)it.next();
          log.realCauseBriefly("String_Node_Str" + pi,t);
          errmsg.append('\n').append(Exceptions.getMessage(t));
        }
      }
      response.sendError(response.SC_GONE,Messages.get(MZk.PAGE_FAILED,new Object[]{pi,errmsg,"String_Node_Str"}));
      return;
    }
 finally {
      if (!err) {
        desktopCtrl.invokeExecutionCleanups(exec,oldexec,null);
        config.invokeExecutionCleanups(exec,oldexec,null);
      }
      uieng.deactivate(exec);
    }
  }
 catch (  ComponentNotFoundException ex) {
    response.sendError(response.SC_GONE,Messages.get(MZk.UPDATE_OBSOLETE_PAGE,uuid));
    return;
  }
  Https.write(request,response,media,download,false);
}

Fixed version (ground truth):
/** 
 * Retrieves the media from   {@link DynamicMedia#getMedia}.
 */
public void service(HttpServletRequest request,HttpServletResponse response,String pi) throws ServletException, IOException {
  final Session sess=Sessions.getCurrent(false);
  if (sess == null) {
    response.sendError(HttpServletResponse.SC_GONE,Messages.get(MZk.PAGE_NOT_FOUND,pi));
    return;
  }
  int j=pi.indexOf('/',1) + 1;
  int k=pi.indexOf('/',j);
  if (j <= 0 || k <= 0)   throw new ServletException("String_Node_Str" + pi);
  final String dtid=pi.substring(j,k);
  final int l=pi.indexOf('/',++k);
  final String uuid=l >= 0 ? pi.substring(k,l) : pi.substring(k);
  Media media;
  boolean download=false;
  try {
    final WebApp wapp=sess.getWebApp();
    final WebAppCtrl wappc=(WebAppCtrl)wapp;
    final UiEngine uieng=wappc.getUiEngine();
    final Desktop desktop=wappc.getDesktopCache(sess).getDesktop(dtid);
    final DesktopCtrl desktopCtrl=(DesktopCtrl)desktop;
    final Execution oldexec=Executions.getCurrent();
    final Execution exec=new ExecutionImpl(_ctx,request,response,desktop,null);
    uieng.activate(exec);
    final Configuration config=wapp.getConfiguration();
    boolean err=false;
    try {
      config.invokeExecutionInits(exec,oldexec);
      desktopCtrl.invokeExecutionInits(exec,oldexec);
      media=desktopCtrl.getDownloadMedia(uuid,false);
      if (media != null) {
        download=true;
      }
 else {
        final Component comp=desktop.getComponentByUuid(uuid);
        final Object cc=((ComponentCtrl)comp).getExtraCtrl();
        if (!(cc instanceof DynamicMedia))         throw new ServletException(DynamicMedia.class + "String_Node_Str" + comp);
        int m=l >= 0 ? pi.indexOf('/',l + 1) : -1;
        if (m < 0)         m=l;
        media=((DynamicMedia)cc).getMedia(m >= 0 ? pi.substring(m) : "String_Node_Str");
        if (media == null) {
          response.sendError(HttpServletResponse.SC_GONE,Messages.get(MZk.PAGE_NOT_FOUND,pi + "String_Node_Str" + comp));
          return;
        }
      }
    }
 catch (    Throwable ex) {
      err=true;
      final List<Throwable> errs=new LinkedList<Throwable>();
      errs.add(ex);
      desktopCtrl.invokeExecutionCleanups(exec,oldexec,errs);
      config.invokeExecutionCleanups(exec,oldexec,errs);
      final StringBuffer errmsg=new StringBuffer(100);
      if (!errs.isEmpty()) {
        for (Iterator it=errs.iterator(); it.hasNext(); ) {
          final Throwable t=(Throwable)it.next();
          log.realCauseBriefly("String_Node_Str" + pi,t);
          errmsg.append('\n').append(Exceptions.getMessage(t));
        }
      }
      response.sendError(HttpServletResponse.SC_GONE,Messages.get(MZk.PAGE_FAILED,new Object[]{pi,errmsg,"String_Node_Str"}));
      return;
    }
 finally {
      if (!err) {
        desktopCtrl.invokeExecutionCleanups(exec,oldexec,null);
        config.invokeExecutionCleanups(exec,oldexec,null);
      }
      uieng.deactivate(exec);
    }
  }
 catch (  ComponentNotFoundException ex) {
    response.sendError(HttpServletResponse.SC_GONE,Messages.get(MZk.UPDATE_OBSOLETE_PAGE,uuid));
    return;
  }
  Https.write(request,response,media,download,false);
}