Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.5
-
Fix Version/s: 1.8.6, 2.0-beta-3
-
Component/s: None
-
Labels:None
-
Environment:Mac OSX Lion
-
Number of attachments :
Description
import groovy.json.* aMap = [a:1, b:2, c:3] new JsonBuilder(aMap) // works as expected aMap = [a:1, b:2, c:3].sort() new JsonBuilder(aMap) // fails with a NullPointerException in 1.8.5. Works as expected in 1.8.4
I believe this issue may be related to commit c5456c808f0af5a. The sort() call returns a TreeMap and that is the root issue here, same error occurs for Hashtable (and Properties). A call to containsKey with a null key will throw a NPE for those Map implementations (unless used with a comparator that handles null keys).