ICEfaces
  1. ICEfaces
  2. ICE-8301

NPE in org.icefaces.ace.renderkit.CoreRenderer.decodeBehaviors(FacesContext, UIComponent)

    Details

    • Assignee Priority:
      P1

      Description

      There is an NPE in CoreRenderer.decodeBehaviors.

      Following setup:
      A cell in the table has a <f:ajax execute="@all" render="@all">. When this field blurs a valueChange event is sent. The method is called for the enclosing ace:dataTable. The NPE occures at line 353 "for (ClientBehavior behavior: behaviorsForEvent) " because 'behaviorsForEvent' is NULL. See below for the entries in the RequestParameterMap.

      context.getExternalContext().getRequestParameterMap():
      {gF=gF, javax.faces.ViewState=-5315491828250340822:1175153470526214242, ice.window=82h3coi0aj, ice.view=v9ebgw5, gF:cityDialogPm_ts:0:editor_overviewTab_names_language=ENGLISH, gF:cityDialogPm_ts:0:editor_overviewTab_names:1:sel_rd=true, gF:cityDialogPm_ts:0:editor_overviewTab_names:1:cityName_in_in=fghfhgf, gF:cityDialogPm_ts:0:editor_overviewTab_names:1:eff_d_fd=12-Jun-2012, gF:cityDialogPm_ts:0:editor_overviewTab_names_selection=, gF:cityDialogPm_ts:0:editor_overviewTab_names_deselection=, gF:cityDialogPm_ts:0:editor_overviewTab_locations:0:sel_rd=true, gF:cityDialogPm_ts:0:editor_overviewTab_locations_selection=, gF:cityDialogPm_ts:0:editor_overviewTab_locations_deselection=, gF:cityDialogPm_ts:0:editor_overviewTab_postalCodeRanges_selection=, gF:cityDialogPm_ts:0:editor_overviewTab_postalCodeRanges_deselection=, icefacesCssUpdates=, gF:j_idcl=, javax.faces.source=gF:cityDialogPm_ts:0:editor_overviewTab_names:1:cityName_in_in, javax.faces.partial.event=change, javax.faces.partial.execute=@all, javax.faces.partial.render=@all, javax.faces.behavior.event=valueChange, javax.faces.partial.ajax=true}


      Unfortunately it's not that easy to build a small-scale example for this problem but I guess the following code is obviously wrong and no example is needed but only a detailed description of the problem:

      protected void decodeBehaviors(FacesContext context, UIComponent component) {

      [...]

      Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
      if (behaviors.isEmpty()) { <------------- (1)
      return;
      }

      [...]

      if (null != behaviorEvent) {
      List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);

      if(behaviors.size() > 0) { <--------- (2)
      [...]
      if (behaviorSource != null && behaviorSource.startsWith(clientId)) {
      for (ClientBehavior behavior : behaviorsForEvent) {
      behavior.decode(context, component);
      }
      }
      }
      }

      [...]
      }

      As one can see the marked if-statement (if (behaviors.size() > 0)) (2) is never false at this stage because of behaviors was already checked with .isEmpty() + return (1).

      However it can happen that behaviours.size() > 0 AND behaviorsForEvent is null or empty, thus it's possible that the for-loop tries to iterate through a list which is actually null - leading to an NPE.

      What you want is to change

      if (behaviors.size() > 0) (2)

      to something like

      if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty())

        Activity

          People

          • Assignee:
            Mark Collette
            Reporter:
            Evgheni Sadovoi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: