mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
rename RetiableCall to Retry
GitOrigin-RevId: 4c34e28d31d9a3943e856300193e7b6dc61c7882
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8e13b683e8
commit
05ecffb3cf
+2
-2
@@ -8,7 +8,7 @@ import org.apache.http.entity.ContentType
|
||||
import org.apache.http.impl.client.HttpClientBuilder
|
||||
import org.apache.http.util.EntityUtils
|
||||
import org.jetbrains.intellij.build.BuildContext
|
||||
import org.jetbrains.intellij.build.impl.retry.RetriableCall
|
||||
import org.jetbrains.intellij.build.impl.retry.Retry
|
||||
|
||||
/**
|
||||
* Download a default version of feature usage statistics white list to be bundled with IDE.
|
||||
@@ -26,7 +26,7 @@ class StatisticsRecorderBundledWhiteListProvider {
|
||||
if (!list.parentFile.mkdirs() || !list.createNewFile()) {
|
||||
context.messages.error("Unable to create $list")
|
||||
}
|
||||
list.write new RetriableCall(context.messages).retry {
|
||||
list.write new Retry(context.messages).call {
|
||||
download(context, whiteListServiceUri(context).with {
|
||||
def name = context.applicationInfo.productCode + '.json'
|
||||
it.endsWith('/') ? "$it$name" : "$it/$name"
|
||||
|
||||
+3
-3
@@ -7,18 +7,18 @@ import org.jetbrains.intellij.build.BuildMessages
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@CompileStatic
|
||||
class RetriableCall {
|
||||
class Retry {
|
||||
private final int retries
|
||||
private final long delayMs
|
||||
private final BuildMessages log
|
||||
|
||||
RetriableCall(BuildMessages log, int retries = 10, long delayMs = 1000) {
|
||||
Retry(BuildMessages log, int retries = 10, long delayMs = 1000) {
|
||||
this.log = log
|
||||
this.delayMs = delayMs
|
||||
this.retries = retries
|
||||
}
|
||||
|
||||
def <T> T retry(Closure<T> operation) {
|
||||
def <T> T call(Closure<T> operation) {
|
||||
def delayMs = delayMs
|
||||
for (i in 1..retries) {
|
||||
try {
|
||||
+4
-4
@@ -4,7 +4,7 @@ package org.jetbrains.intellij.build.impl.retry
|
||||
import org.jetbrains.intellij.build.BuildMessages
|
||||
import org.junit.Test
|
||||
|
||||
class RetriableCallTest {
|
||||
class RetryTest {
|
||||
@Test
|
||||
void 'retry test'() {
|
||||
def log = [
|
||||
@@ -12,12 +12,12 @@ class RetriableCallTest {
|
||||
error: { throw new Exception(it) }
|
||||
] as BuildMessages
|
||||
def retries = 10
|
||||
def retriableCall = new RetriableCall(log, retries, 1)
|
||||
assert retriableCall.retry {
|
||||
def retry = new Retry(log, retries, 1)
|
||||
assert retry.call {
|
||||
42
|
||||
} == 42
|
||||
def attempts = 0
|
||||
assert retriableCall.retry {
|
||||
assert retry.call {
|
||||
if (it > retries / 2) return 42
|
||||
attempts++
|
||||
throw new Exception("${it}th failure")
|
||||
Reference in New Issue
Block a user