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

VerifyError when private variable is used in synchronized block

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.2
    • 2.4.3
    • Static compilation
    • None

    Description

      In the following code, synchronizing on the private final field map inside a closure causes a VerifyError. Synchronizing on a protected or public field fixes the problem.

      class TaskManager {
          private final Map<Long, String> map = [1L:'a',2L:'b']
          void doh() {
              def list = [1L]
              list.each {
                  synchronized (map) {
                      map.remove(it)
                  }
              }
          }
      }
      new TaskManager().doh()
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: