Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6934

JsonSlurper in 2.3 returns LazyMap which is not thread safe for multiple reads

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 2.3.4
    • None
    • JSON
    • None
    • Linux


      We recently upgraded one of our systems from Groovy 2.1 to Groovy 2.3. This went mostly without any issues which was great. We did have one issue which caused us a bit of grief. It seems that groovy 2.3 changed the type of map that the JsonSlurper returns from the default HashMap to a LazyMap. Looking at the implementation of LazyMap, it's not thread safe for multiple reads. We are seeing multiple null pointer exceptions in our logs, which result from the fact that the map is lazily constructed by multiple threads, and the first thread to finish nulls the keys and values. (There are also other concurrency bugs there).

      I am attaching a test case that demonstrates this. It works fine in groovy 2.2 and 2.1, but gets a null pointer in 2.3.

      I'd consider this a very serious breaking change. Only reference of this change I can find is here:


      While we can about concurrency semantics, I would expect data that was read of the wire to be readable by multiple threads, and groovy up to version 2.2 did offer this behaviour.

      Thank you,

      Stefanos Zachariadis



        Issue Links


          This comment will be Viewable by All Users Viewable by All Users


            Unassigned Unassigned
            rohirrim Stefanos Zachariadis




                Issue deployment