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

Groovy with @Compilestatic problem

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.15
    • 2.5.6
    • None

    Description

      When I compile to class, Groovy pass my RetryPolicy to Failsafe.with(Policy... policies) function as Object[]. However, I expect that Groovy will pass it as RetryPolicy[] instead of Object[].

      When it's Object[], my application will be wrong because I need to pass a Policy[] in to this function.

      (I'm using Failsafe lib [in here|https://github.com/jhalterman/failsafe)

      My code:

       

      final RetryPolicy<Object> RETRY_POLICY = new RetryPolicy<>()
       .withDelay(Duration.ofSeconds(5))
       .withMaxRetries(60)
       .onFailedAttempt({ error -> log.warn("@An error must be retried:", error.getLastFailure()) })
       .onRetry({ error -> log.info("@Failure #{}. Retrying...", error.getAttemptCount()) })
      Failsafe.with(RETRY_POLICY)

       

      Complicated code .class file:

       

      Failsafe.with(new Object[]{RETRY_POLICY});

       

      Complicated code .class file when I don't use @CompileStatic

       

      RetryPolicy RETRY_POLICY = (RetryPolicy)ScriptBytecodeAdapter.castToType(var2[9].call(var2[10].call(var2[11].call(var2[12].call(var2[13].callConstructor(RetryPolicy.class), var2[14].call(Duration.class, 5)), 60), new _fillWebsiteInfo_closure1(this, this)), new _fillWebsiteInfo_closure2(this, this)), RetryPolicy.class);
      var2[15].call(Failsafe.class, RETRY_POLICY);

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            huantt Huan Tu Tat
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: