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

IoSession.getAttribute() doesn't store default value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.4
    • 2.0.8
    • Core
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: