You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2014/09/10 01:50:28 UTC

[jira] [Resolved] (DIRMINA-899) IoSession.getAttribute() doesn't store default value

     [ https://issues.apache.org/jira/browse/DIRMINA-899?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRMINA-899.
---------------------------------------
    Resolution: Fixed

Fixed a long time ago. We now store the value, even if the key does not exist :


{code}
        public Object getAttribute(IoSession session, Object key, Object defaultValue) {
            if (key == null) {
                throw new IllegalArgumentException("key");
            }

            if (defaultValue == null) {
                return attributes.get(key);
            }

            Object object = attributes.putIfAbsent(key, defaultValue);
...
{code}

> 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
>             Fix For: 2.0.8
>
>
> 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
> {code}
>         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;
>         }
> {code}
> It never stores the default value.
> Can you (preferably) fix that, or (less preferably) correct the JavaDoc?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)