groovy
  1. groovy
  2. GROOVY-5162

JsonOutput fails with uninformative NPE when map has null key

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.4
    • Fix Version/s: 1.8.5, 2.0-beta-2
    • Component/s: groovy-jdk
    • Labels:
    • Environment:
      Mac Java 6
    • Number of attachments :
      0

      Description

      import groovy.json.JsonOutput
      
      def group = [1, 2, null].countBy{it}
      def result = use (JsonOutput) {
          group.toJson()
      }
      

      throws NullPointerException due to the presence of a null a as key to map entry.
      The stacktrace is rather unhelpful, so it would be nice if the JsonOutput would translate this to indicate a problem with the map content.
      http://groovyconsole.appspot.com/script/601001

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved: