Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: EE-3.0.0.GA
-
Fix Version/s: 3.1.0.RC1, 3.1, EE-3.0.0.GA_P01
-
Component/s: ACE-Components
-
Labels:None
-
Environment:N/A
-
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())
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
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #29700 | Wed Jun 27 09:04:19 MDT 2012 | mark.collette | |
Files Changed | ||||
MODIFY
/icefaces3/branches/icefaces-3.0.x-maintenance/icefaces/ace/component/src/org/icefaces/ace/renderkit/CoreRenderer.java
|
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #29699 | Wed Jun 27 09:03:43 MDT 2012 | mark.collette | |
Files Changed | ||||
MODIFY
/icefaces3/trunk/icefaces/ace/component/src/org/icefaces/ace/renderkit/CoreRenderer.java
|