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

Return from synchronized block throws IllegalMonitorStateException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0
    • None
    • None

    Description

      The following code throws a java.lang.IllegalMonitorStateException.

      class SomeClass {
      def lock = new Object()
      def doSomething() {
      synchronized (lock) {
      if (1==1)

      { return }

      }
      println("doSomething")
      }
      }
      new SomeClass().doSomething()

      bryan@rook /c/bryan
      $ groovy test.groovy
      Caught: java.lang.IllegalMonitorStateException
      at SomeClass.doSomething(test.groovy:8)
      at test.run(test.groovy:15)
      at test.main(test.groovy)

      bryan@rook /c/bryan
      $ java -version
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

      bryan@rook /c/bryan
      $ groovy -version
      Groovy Version: 1.0-jsr-05 JVM: 1.5.0_06-b05

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            castillo.bryan Bryan Castillo
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: