Hi, I found another bug in Pluto 1.1 branch that breaks the portlet spec.
The portlet spec (xci, SPEC 91, PLT 14.1) states that:
The getMap method returns an immutable Map of String keys and String[]
values containing all current preference values. Preferences values
must not be modified if the values in the Map are altered.
I added a checkPreferencesValuesNotModified() method in the
testsuite class SimplePreferenceTest, to check PLT 14.1. That test
failed: In fact, if I changed the values of the string array in the map
returned (NOT to put an entry into the map, since that operation is not
allowed), the preferences values are changed accordingly.
The bug resides in the class PortletPreferencesImpl. I updated the
method getMap() as the following, and then the spec was respected:
public Map getMap() {
Map map = new java.util.HashMap();
Iterator it = preferences.keySet().iterator();
while (it.hasNext()) {
PortletPreference
pref = (PortletPreference)preferences.get(it.next());
map.put(pref.getName(), pref.getValues().clone()); // <== Here we clone the string array.
}
return Collections.unmodifiableMap(map);
}
I submitted a patch (SVN diff file) for PortletPreferencesImpl, as well as a SVN diff file for the updated test class
SimplePreferenceTest, on JIRA:
http://issues.apache.org/jira/browse/PLUTO-167
Hope that will be applied to SVN.
Regards.
--
ZHENG Zhong
1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90
heavyzheng {AT} gmail {D0T} com
http://heavyz.sourceforge.net
http://heavyz.blogspot.com
http://spaces.msn.com/members/zhengzhong
- In Pluto 1.1 branch, PortletPreferencesImpl.getMap() break... Zhong ZHENG
