Skip to content

Commit dcd025d

Browse files
committed
Catching exception inside retries
1 parent 1dedc1d commit dcd025d

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/Admin.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,8 @@ public Database createDatabase(Database database) throws IOException {
213213
}
214214
Database response = post(v1(BDBS), database, Database.class);
215215
long uid = response.getUid();
216-
Awaitility.await().pollInterval(Duration.ofSeconds(1)).until(() -> {
217-
Command command = new Command();
218-
command.setCommand("PING");
219-
try {
220-
return executeCommand(uid, command).getResponse().asBoolean();
221-
} catch (HttpResponseException e) {
222-
log.info("PING unsuccessful, retrying...");
223-
return false;
224-
}
225-
});
216+
Awaitility.await().pollInterval(Duration.ofSeconds(1)).ignoreExceptions()
217+
.until(() -> executeCommand(uid, new Command("PING")).getResponse().asBoolean());
226218
return response;
227219
}
228220

@@ -256,20 +248,13 @@ public ModuleInstallResponse installModule(String filename, InputStream inputStr
256248
ModuleInstallResponse response = read(post, SimpleType.constructUnsafe(ModuleInstallResponse.class),
257249
HttpStatus.SC_ACCEPTED);
258250
baos.close();
259-
Awaitility.await().timeout(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1)).until(() -> {
260-
log.info("Checking status of action {}", response.getActionUid());
261-
Action status = getAction(response.getActionUid());
262-
if ("completed".equals(status.getStatus())) {
263-
return true;
264-
}
265-
log.info("Action {} status: {}", response.getActionUid(), status.getStatus());
266-
return false;
267-
});
251+
Awaitility.await().timeout(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1)).ignoreExceptions()
252+
.until(() -> "completed".equals(getAction(response.getActionUid()).getStatus()));
268253
return response;
269254
}
270255

271256
public void waitForBoostrap() {
272-
Awaitility.await().pollInterval(Duration.ofSeconds(1)).timeout(Duration.ofMinutes(1))
257+
Awaitility.await().timeout(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1)).ignoreExceptions()
273258
.until(() -> "idle".equals(getBootstrap().getStatus().getState()));
274259

275260
}

subprojects/redis-enterprise-admin/src/main/java/com/redis/enterprise/Command.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ public class Command {
1111
private String command;
1212
private List<String> args = new ArrayList<>();
1313

14+
public Command() {
15+
}
16+
17+
public Command(String command) {
18+
this.command = command;
19+
}
20+
1421
public String getCommand() {
1522
return command;
1623
}

0 commit comments

Comments
 (0)