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