Program: 16402
Project: 16402
Buggy source:
/** 
 * Processes an AU request. <p> Default: in addition to what are handled by   {@link XulElement#service}, it also handles onSelect.
 * @since 5.0.0
 */
public void service(org.zkoss.zk.au.AuRequest request,boolean everError){
  final String cmd=request.getCommand();
  if (cmd.equals("String_Node_Str")) {
    if (_rod) {
      Executions.getCurrent().setAttribute("String_Node_Str" + this.getUuid(),Boolean.TRUE);
    }
    Events.postEvent(DataLoadingEvent.getDataLoadingEvent(request,preloadSize()));
  }
 else   if (inPagingMold() && cmd.equals(ZulEvents.ON_PAGE_SIZE)) {
    final Map data=request.getData();
    final int oldsize=getPageSize();
    int size=AuRequests.getInt(data,"String_Node_Str",oldsize);
    if (size != oldsize) {
      int begin=getActivePage() * oldsize;
      int end=begin + oldsize;
      end=Math.min(getPaginal().getTotalSize(),end);
      int sel=getSelectedIndex();
      if (sel < 0 || sel < begin || sel >= end) {
        sel=size > oldsize ? (end - 1) : begin;
      }
      int newpg=sel / size;
      setPageSize(size);
      setActivePage(newpg);
      Events.postEvent(new PageSizeEvent(cmd,this,pgi(),size));
    }
  }
 else   if (cmd.equals("String_Node_Str")) {
    final Map data=request.getData();
    _currentTop=AuRequests.getInt(data,"String_Node_Str",0);
    _currentLeft=AuRequests.getInt(data,"String_Node_Str",0);
  }
 else   if (cmd.equals("String_Node_Str")) {
    _topPad=AuRequests.getInt(request.getData(),"String_Node_Str",0);
  }
 else   if (cmd.equals(Events.ON_SELECT)) {
    if (_rod && Executions.getCurrent().getAttribute("String_Node_Str" + this.getUuid()) != null)     return;
    SelectEvent evt=SelectEvent.getSelectEvent(request);
    Set selItems=evt.getSelectedItems();
    if (_rod) {
      Map m=(Map)request.getData().get("String_Node_Str");
      if (m != null) {
        int start=AuRequests.getInt(m,"String_Node_Str",-1);
        int end=AuRequests.getInt(m,"String_Node_Str",-1);
        int ignoreStart=-1;
        int ignoreEnd=-1;
        for (Iterator it=_items.iterator(); it.hasNext(); ) {
          Listitem item=(Listitem)it.next();
          int index=item.getIndex();
          if (index >= start && index <= end) {
            if (ignoreStart == -1)             ignoreStart=index;
            ignoreEnd=index;
            if (!item.isDisabled())             selItems.add(item);
          }
        }
        if (_model instanceof Selectable) {
          for (int i=start; i < end; i++) {
            if (i < ignoreStart || i > ignoreEnd)             ((Selectable)_model).addSelection(_model.getElementAt(i));
          }
        }
      }
    }
    disableClientUpdate(true);
    try {
      if (AuRequests.getBoolean(request.getData(),"String_Node_Str"))       clearSelection();
      final boolean paging=inPagingMold();
      if (!_multiple || (!_rod && !paging && (selItems == null || selItems.size() <= 1))) {
        final Listitem item=selItems != null && selItems.size() > 0 ? (Listitem)selItems.iterator().next() : null;
        selectItem(item);
      }
 else {
        int from, to;
        if (paging) {
          final Paginal pgi=getPaginal();
          int pgsz=pgi.getPageSize();
          from=pgi.getActivePage() * pgsz;
          to=from + pgsz;
        }
 else {
          from=to=0;
        }
        Set oldSelItems=new LinkedHashSet(_selItems);
        for (Iterator it=selItems.iterator(); it.hasNext(); ) {
          final Listitem item=(Listitem)it.next();
          if (!_selItems.contains(item))           addItemToSelection(item);
        }
        for (Iterator it=oldSelItems.iterator(); it.hasNext(); ) {
          final Listitem item=(Listitem)it.next();
          if (!selItems.contains(item)) {
            final int index=item.getIndex();
            if (!paging || (index >= from && index < to))             removeItemFromSelection(item);
          }
        }
      }
    }
  finally {
      disableClientUpdate(false);
    }
    Events.postEvent(evt);
  }
 else   if (cmd.equals("String_Node_Str")) {
    final String width=AuRequests.getInnerWidth(request);
    _innerWidth=width == null ? "String_Node_Str" : width;
  }
 else   if (cmd.equals(Events.ON_RENDER)) {
    final Set items=AuRequests.convertToItems(request.getDesktop(),(List)request.getData().get("String_Node_Str"));
    int cnt=items.size();
    if (cnt == 0)     return;
    cnt=20 - cnt;
    if (cnt > 0 && _preloadsz > 0) {
      if (cnt > _preloadsz)       cnt=_preloadsz;
      final List toload=new LinkedList();
      Iterator it=_items.iterator();
      while (it.hasNext()) {
        final Listitem li=(Listitem)it.next();
        if (items.contains(li))         break;
        if (!li.isLoaded())         toload.add(0,li);
      }
      if (!toload.isEmpty()) {
        int bfcnt=cnt / 3;
        for (Iterator e=toload.iterator(); bfcnt > 0 && e.hasNext(); --bfcnt, --cnt) {
          items.add(e.next());
        }
      }
      while (cnt > 0 && it.hasNext()) {
        final Listitem li=(Listitem)it.next();
        if (!li.isLoaded() && items.add(li))         --cnt;
      }
    }
    Listbox.this.renderItems(items);
  }
 else   super.service(request,everError);
}

Fixed version (ground truth):
/** 
 * Processes an AU request. <p> Default: in addition to what are handled by   {@link XulElement#service}, it also handles onSelect.
 * @since 5.0.0
 */
public void service(org.zkoss.zk.au.AuRequest request,boolean everError){
  final String cmd=request.getCommand();
  if (cmd.equals("String_Node_Str")) {
    if (_rod) {
      Executions.getCurrent().setAttribute("String_Node_Str" + this.getUuid(),Boolean.TRUE);
    }
    Events.postEvent(DataLoadingEvent.getDataLoadingEvent(request,preloadSize()));
  }
 else   if (inPagingMold() && cmd.equals(ZulEvents.ON_PAGE_SIZE)) {
    final Map data=request.getData();
    final int oldsize=getPageSize();
    int size=AuRequests.getInt(data,"String_Node_Str",oldsize);
    if (size != oldsize) {
      int begin=getActivePage() * oldsize;
      int end=begin + oldsize;
      end=Math.min(getPaginal().getTotalSize(),end);
      int sel=getSelectedIndex();
      if (sel < 0 || sel < begin || sel >= end) {
        sel=size > oldsize ? (end - 1) : begin;
      }
      int newpg=sel / size;
      setPageSize(size);
      setActivePage(newpg);
      Events.postEvent(new PageSizeEvent(cmd,this,pgi(),size));
    }
  }
 else   if (cmd.equals("String_Node_Str")) {
    final Map data=request.getData();
    _currentTop=AuRequests.getInt(data,"String_Node_Str",0);
    _currentLeft=AuRequests.getInt(data,"String_Node_Str",0);
  }
 else   if (cmd.equals("String_Node_Str")) {
    _topPad=AuRequests.getInt(request.getData(),"String_Node_Str",0);
  }
 else   if (cmd.equals(Events.ON_SELECT)) {
    if (_rod && Executions.getCurrent().getAttribute("String_Node_Str" + this.getUuid()) != null)     return;
    SelectEvent evt=SelectEvent.getSelectEvent(request);
    Set selItems=evt.getSelectedItems();
    if (_rod) {
      Map m=(Map)request.getData().get("String_Node_Str");
      if (m != null) {
        selItems.addAll(_selItems);
        int start=AuRequests.getInt(m,"String_Node_Str",-1);
        int end=AuRequests.getInt(m,"String_Node_Str",-1);
        int ignoreStart=-1;
        int ignoreEnd=-1;
        for (Iterator it=_items.iterator(); it.hasNext(); ) {
          Listitem item=(Listitem)it.next();
          int index=item.getIndex();
          if (index >= start && index <= end) {
            if (ignoreStart == -1)             ignoreStart=index;
            ignoreEnd=index;
            if (!item.isDisabled())             selItems.add(item);
          }
        }
        if (_model instanceof Selectable) {
          for (int i=start; i < end; i++) {
            if (i < ignoreStart || i > ignoreEnd)             ((Selectable)_model).addSelection(_model.getElementAt(i));
          }
        }
      }
    }
    disableClientUpdate(true);
    try {
      if (AuRequests.getBoolean(request.getData(),"String_Node_Str"))       clearSelection();
      final boolean paging=inPagingMold();
      if (!_multiple || (!_rod && !paging && (selItems == null || selItems.size() <= 1))) {
        final Listitem item=selItems != null && selItems.size() > 0 ? (Listitem)selItems.iterator().next() : null;
        selectItem(item);
      }
 else {
        int from, to;
        if (paging) {
          final Paginal pgi=getPaginal();
          int pgsz=pgi.getPageSize();
          from=pgi.getActivePage() * pgsz;
          to=from + pgsz;
        }
 else {
          from=to=0;
        }
        Set oldSelItems=new LinkedHashSet(_selItems);
        for (Iterator it=selItems.iterator(); it.hasNext(); ) {
          final Listitem item=(Listitem)it.next();
          if (!_selItems.contains(item))           addItemToSelection(item);
        }
        for (Iterator it=oldSelItems.iterator(); it.hasNext(); ) {
          final Listitem item=(Listitem)it.next();
          if (!selItems.contains(item)) {
            final int index=item.getIndex();
            if (!paging || (index >= from && index < to))             removeItemFromSelection(item);
          }
        }
      }
    }
  finally {
      disableClientUpdate(false);
    }
    Events.postEvent(evt);
  }
 else   if (cmd.equals("String_Node_Str")) {
    final String width=AuRequests.getInnerWidth(request);
    _innerWidth=width == null ? "String_Node_Str" : width;
  }
 else   if (cmd.equals(Events.ON_RENDER)) {
    final Set items=AuRequests.convertToItems(request.getDesktop(),(List)request.getData().get("String_Node_Str"));
    int cnt=items.size();
    if (cnt == 0)     return;
    cnt=20 - cnt;
    if (cnt > 0 && _preloadsz > 0) {
      if (cnt > _preloadsz)       cnt=_preloadsz;
      final List toload=new LinkedList();
      Iterator it=_items.iterator();
      while (it.hasNext()) {
        final Listitem li=(Listitem)it.next();
        if (items.contains(li))         break;
        if (!li.isLoaded())         toload.add(0,li);
      }
      if (!toload.isEmpty()) {
        int bfcnt=cnt / 3;
        for (Iterator e=toload.iterator(); bfcnt > 0 && e.hasNext(); --bfcnt, --cnt) {
          items.add(e.next());
        }
      }
      while (cnt > 0 && it.hasNext()) {
        final Listitem li=(Listitem)it.next();
        if (!li.isLoaded() && items.add(li))         --cnt;
      }
    }
    Listbox.this.renderItems(items);
  }
 else   super.service(request,everError);
}