Groovy with @Compilestatic problem

tathuan96
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 16, 2019

When I compile to class, Groovy pass my RetryPolicy to Failsafe.with(P...) 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.

 

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);

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events