[ http://issues.apache.org/struts/browse/WW-456?page=all ]
Don Brown updated WW-456:
-------------------------
Fix Version/s: (was: 2.0.1)
> SingleValueMap.entrySet() is broken
> -----------------------------------
>
> Key: WW-456
> URL: http://issues.apache.org/struts/browse/WW-456
> Project: Struts 2
> Issue Type: Bug
> Components: Actions
> Affects Versions: WW 1.4, WW 1.3
> Reporter: Attila Szegedi
> Fix For: WW 1.4.1
>
>
> SingleValueMap.entrySet() returns multivalue entries instead of single value
> ones. There's a "//TODO: NYI" comment in there...
> Here's a patch that makes it right, coded to be similar to how values() is
> implemented:
> public Set entrySet()
> {
> Set entries = m.entrySet();
> Set realEntries = new HashSet(entries.size() * 4/3, .75f);
> for (Iterator iterator = entries.iterator(); iterator.hasNext();)
> {
> realEntries.add(new SingleValueEntry((Map.Entry)iterator.next()));
> }
> return realEntries;
> }
>
> private static class SingleValueEntry implements Map.Entry
> {
> private final Map.Entry entry;
>
> SingleValueEntry(Map.Entry entry)
> {
> this.entry = entry;
> }
> public Object getKey()
> {
> return entry.getKey();
> }
>
> public Object getValue()
> {
> Object o = entry.getValue();
> return o == null ? null : ((Object[])o)[0];
> }
>
> public void setValue(Object value)
> {
> Object o = entry.getValue();
> if(o instanceof Object[])
> {
> Object[] ao = (Object[])o;
> if(ao.length > 0)
> {
> ao[0] = value;
> return;
> }
> }
> entry.setValue(new Object[] { value });
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira