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

TimeoutException immediately thrown when using both TimedInterrupt and with {} closure on a Map

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.6
    • 1.8.8, 2.0.2, 2.1.0-beta-1
    • None
    • None

    Description

      The attached script.groovy has a very strange behaviour:

      Bar.java
      class GroovyTimedInterruptAndWithTest {
      
        @groovy.transform.TimedInterrupt( 60L )
        def test() {
          
          def map = [:]
          
          map.with {
            key1 = 'foo'
            key2 = 42
          }
          
          map
        }
      }
      
      new GroovyTimedInterruptAndWithTest().test()
      

      At runtime, the script immediately throws the TimeoutException (whereas the timeout's value given to the @TimedInterrupt annotation is 60 seconds) :

       
      java.util.concurrent.TimeoutException: Execution timed out after 60 units. Start time: null
      	at GroovyTimedInterruptAndWithTest$_test_closure1.doCall(script.groovy)
      	at GroovyTimedInterruptAndWithTest.test(script.groovy:8)
      	at GroovyTimedInterruptAndWithTest$test.call(Unknown Source)
      	at script.run(script.groovy:17)
      

      The Start time displayed in this stacktrace, which is null, is another strange fact.

      Experienced on 1.8.6 but might also occur on all versions including @TimedInterrupt (1.8.0+).

      This is not very critical as it's of course possible to write instead:

      map['key1']='foo'
      map['key2']=42
      

      but the thing is that the script runs fine when commenting the @TimedInterrupt annotation ; so this bug might hide another strange behaviours when using @TimedInterrupt annotation.

      Attachments

        1. script.groovy
          0.2 kB
          Guillaume CERNIER

        Activity

          People

            paulk Paul King
            guillaume.cernier Guillaume CERNIER
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: