Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
Nightly Builds
-
None
-
None
-
Operating System: All
Platform: All
-
26853
Description
in: org.apache.commons.jxpath.MapDynamicPropertyHandler
If the following code:
public String[] getPropertyNames(Object object) {
Map map = (Map) object;
String names[] = new String[map.size()];
Iterator it = map.keySet().iterator();
for (int i = 0; i < names.length; i++)
return names;
}
could be replaced by:
public String[] getPropertyNames(Object object) {
Set keys = ((Map) object).keySet();
String names[] = new String[keys.size()];
Iterator it = keys.iterator();
for (int i = 0; i < names.length; i++)
return names;
}
This would permit to support very special cases where Map.keySet().size() !=
Map.size() [which, I know, does not conform to the Map API].
Anyway, in general, it is better to compute the size on the Set we are actually
using and not on another one related to it...
Thanks,
Yann Duponchel.