groovy
  1. groovy
  2. GROOVY-3590

Map.get(key, defaultvalue) doesn't work properly if current value is null.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6.4, 1.7-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      windows xp
      Groovy Version: 1.6.0 JVM: 1.6.0_05
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      I have a Map, args, which contains a key/value pair 'abcd':null .
      I create an default object and then do the get:

      def default_abcd = new abcd(blah, blah)
      args.get('freq',default_freq)

      Now the value of args.abcd is the new object. However, since the key 'abcd' previously existed and had a value (null), the get() call should have left the value alone (as null).

        Activity

        Hide
        Paul Czyzewski added a comment -

        oops. code lines should read:

        def default_abcd = new abcd(blah, blah)
        args.get('freq',default_abcd)

        Also, I meant to check "no" for 'testcase included'.

        Show
        Paul Czyzewski added a comment - oops. code lines should read: def default_abcd = new abcd(blah, blah) args.get('freq',default_abcd) Also, I meant to check "no" for 'testcase included'.
        Hide
        Roshan Dawrani added a comment -

        Fixed

        Show
        Roshan Dawrani added a comment - Fixed

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Paul Czyzewski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: