ICEfaces
  1. ICEfaces
  2. ICE-2332

NPE in GroupAsyncRender.remove()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7DR#2
    • Fix Version/s: 1.7DR#3, 1.7
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      win xp

      Description

      If a user tries to call renderer.remove() after the Renderable has already been removed the remove method will generate an NPE:

      ava.lang.NullPointerException
              at
      com.icesoft.faces.async.render.GroupAsyncRenderer.remove(GroupAsyncRenderer.java:127)
              at
      com.efunds.oe.fm.pb.AbstractRenderableBean.removePolling(AbstractRenderableBean.java:117)
              at
      com.efunds.oe.fm.pb.AbstractRenderableBean.viewDisposed(AbstractRenderableBean.java:210)
              at com.icesoft.faces.context.View.notifyViewDisposal(View.java:221)
              at com.icesoft.faces.context.View.dispose(View.java:191)
      ...

      suggested fix:

      public void remove(Renderable renderable) {
         if( group != null ){
      synchronized (group) {
                  Iterator iter = group.iterator();
                  while (iter.hasNext()) {
                      WeakReference ref = (WeakReference) iter.next();
                      if (renderable == (Renderable) ref.get()) {
                          group.remove(ref);
                          if (log.isTraceEnabled()) {
                              log.trace(name + " removing " + renderable);
                          }
                          return;
                      }
                  }
                  if (log.isWarnEnabled()) {
                      log.warn(name + " does not contain " + renderable);
                  }
              }
            }
          }

        Activity

        Hide
        Deryk Sinotte added a comment -

        Rather than add a whole bunch of if(group !=null) logic to the various methods, I've removed the group = null statement from the dispose method. We already clear out all the Renderables and the group is only visible to the GroupAsyncRenderer and sub classes. There is really no need to null it out. The rest of the logic in the class should work fine with an empty rather than null collection.

        Show
        Deryk Sinotte added a comment - Rather than add a whole bunch of if(group !=null) logic to the various methods, I've removed the group = null statement from the dispose method. We already clear out all the Renderables and the group is only visible to the GroupAsyncRenderer and sub classes. There is really no need to null it out. The rest of the logic in the class should work fine with an empty rather than null collection.

          People

          • Assignee:
            Unassigned
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: