[ 
https://issues.apache.org/jira/browse/DIRMINA-899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13411740#comment-13411740
 ] 

Schabse Laks commented on DIRMINA-899:
--------------------------------------

setAttributeIfAbsent does behave as documented, but annoyingly returns the old 
value rather than the new value.
                
> IoSession.getAttribute() doesn't store default value
> ----------------------------------------------------
>
>                 Key: DIRMINA-899
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-899
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.4
>            Reporter: Schabse Laks
>
> The JavaDocs for IoSession.getAttribute(Object key, Object defaultValue) 
> state that if the key doesn't exist yet, the default value is stored in the 
> map.
> http://mina.apache.org/report/trunk/apidocs/org/apache/mina/core/session/IoSession.html#getAttribute(java.lang.Object,
>  java.lang.Object)
> The actual implementation (in DefaultIoSessionAttributeMap) reads
>         public Object getAttribute(IoSession session, Object key, Object 
> defaultValue) {
>             if (key == null) {
>                 throw new IllegalArgumentException("key");
>             }
>             Object answer = attributes.get(key);
>             if (answer == null) {
>                 return defaultValue;
>             }
>             
>             return answer;
>         }
> It never stores the default value.
> Can you (preferably) fix that, or (less preferably) correct the JavaDoc?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to