Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5079

remove an item of ListModelList causes nullponiterexception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 9.6.2
    • 9.6.0.1
    • ForEach
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      it's a simulated case, not a real one

          <nodom viewModel="@id('vm')@init('issue.ZK5079VM')">
              <forEach items="@init(vm.model)">
                  <apply template="nonExistedTemplate"/>
              </forEach>
              <button label="del" onClick="@command('del')"/>
          </nodom>
          <template name="noChildTemplate"></template>
      

      1. click "del" button

      another way

      use <apply template="noChildTemplate"/>

      Current Result

      error from the simulated case

      java.lang.NullPointerException
      at org.zkoss.zk.ui.HtmlShadowElement$ChildIter.<init>(HtmlShadowElement.java:1403)
      at org.zkoss.zk.ui.HtmlShadowElement$ChildIter.<init>(HtmlShadowElement.java:1382)
      at org.zkoss.zk.ui.HtmlShadowElement$4.listIterator(HtmlShadowElement.java:1364)
      at java.base/java.util.AbstractList.removeRange(AbstractList.java:595)
      at java.base/java.util.AbstractList.clear(AbstractList.java:243)
      at org.zkoss.zuti.zul.ForEachListDataListener.onListModelDataChange(ForEachListDataListener.java:99)
      at org.zkoss.zuti.zul.ForEachListDataListener.onChange(ForEachListDataListener.java:47)
      at org.zkoss.zul.AbstractListModel.fireEvent(AbstractListModel.java:73)
      at org.zkoss.zul.ListModelList.remove(ListModelList.java:348)
      at benchmark.NotifyListModelVM.del(NotifyListModelVM.java:30)
      at jdk.internal.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at org.zkoss.bind.impl.ParamCall.call(ParamCall.java:174)
      at org.zkoss.bind.impl.BinderImpl.handleNotifyChange(BinderImpl.java:1952)
      at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:2131)
      at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1847)
      at org.zkoss.bind.impl.BinderImpl.access$1300(BinderImpl.java:145)
      at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1688)
      at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1641)
      at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3190)
      at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3160)
      at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3102)

      error from the user

      Caused by: java.lang.Null Pointer Exception: null
              at org.zkoss.zk.ui.HtmlShadowElement$ChildIter.<init>(HtmlShadowElement.java:1403)
              at org.zkoss.zk.ui.HtmlShadowElement$ChildIter.<init>(HtmlShadowElement.java:1382)
              at org.zkoss.zk.ui.HtmlShadowElement$4.listIterator(HtmlShadowElement.java:1364)
              at java.base/java.util.AbstractList.removeRange(AbstractList.java:595)
              at java.base/java.util.AbstractList.clear(AbstractList.java:243)
              at org.zkoss.zuti.zul.ForEachListDataListener.onListModelDataChange(ForEachListDataListener.java:99)
              at org.zkoss.zuti.zul.ForEachListDataListener.onChange(ForEachListDataListener.java:47)
              at org.zkoss.zul.AbstractListModel.fireEvent(AbstractListModel.java:73)
              at com.yyy.zk.components.viewmode.ListModelListExt.fireEvent(ListModelListExt.java:334) -->Allows delaying event, not used here
              at org.zkoss.zul.ListModelList.remove(ListModelList.java:348)
              at com.yyy.zk.components.viewmode.ListModelListExt.removeInternal(ListModelListExt.java:223)  -->Simply super to remove
              at com.yyy.zk.components.viewmode.ListModelListExt.lambda$9(ListModelListExt.java:474)
              at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
              at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
              at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1675)
              at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
              at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
              at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
              at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
              at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
              at com.yyy.zk.components.viewmode.ListModelListExt.removeFromSubLists(ListModelListExt.java:471)
              at com.yyy.zk.components.viewmode.ListModelListExt.remove(ListModelListExt.java:204)
              at com.yyy.zk.ba.component.notification.NotifiedListModelListExt.remove(NotifiedListModelListExt.java:172)
              at com.yyy.zk.ba.component.notification.NotifiedListModelListExt.remove(NotifiedListModelListExt.java:1)
              at org.zkoss.zul.ListModelList.remove(ListModelList.java:355)
              at com.yyy.zk.ba.component.notification.NotifiedListModelListExt.lambda$7(NotifiedListModelListExt.java:383)
      

      Expected Result

      no error

      Debug Information

      • other places that call getShadowHostIfAny() check null, but ChildIter() doesn't check.

            DevChu DevChu
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: