Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-899

IoSession.getAttribute() doesn't store default value

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.0.8
    • Component/s: Core
    • Labels:
      None

      Description

      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?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              slaks Schabse Laks
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: