[ http://issues.apache.org/struts/browse/WW-456?page=comments#action_38760 
] 
            
Attila Szegedi commented on WW-456:
-----------------------------------

Don Brown says "Resolution: Not a problem". Wow. Let me try to understand this:

- having SingleValueMap.entrySet() return different values than 
SingleValueMap.values(), thus breaking the contract of the java.util.Map 
interface - not a problem.

- it returning *multiple* values when the class is named *Single*ValueMap - not 
a problem.

What can I say? I stopped using WebWork long ago due to this and other problems 
I had with it, so incidentally to me it really is - not a problem (anymore).

Anyway, there's a working code solution for the problem. All you'd need to do 
is drop it into your local copy and commit it. Why you wouldn't do that is 
beyond me, but as I said, three years later after filing this, I don't care 
about WW anymore.

Best of luck to anyone else who steps into this, though.

> 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

        

Reply via email to