Skip to content

Commit debccff

Browse files
committed
fix ISE when synchronizing claims
1 parent 48b6f26 commit debccff

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

claimManagement/src/main/java/org/openimis/imisclaims/usecase/CheckMutation.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,29 @@ public CheckMutation(long timeOutMs, long delayMs, @NonNull CheckMutationGraphQL
4040
public Integer execute(@NonNull String uuid, @NonNull String message) throws Exception {
4141
long start = System.currentTimeMillis();
4242
CheckMutationQuery.Node node = null;
43-
Integer status;
43+
Integer status = null;
4444
do {
45+
if (System.currentTimeMillis() >= start + timeOutMs) {
46+
throw new TimeoutException("Could not retrieve the mutation status of '" + uuid + "' within " + timeOutMs + "ms");
47+
}
4548
if (node != null) {
4649
Thread.sleep(delayMs);
4750
}
48-
node = request.execute(uuid);
49-
status = node.status();
50-
if (System.currentTimeMillis() >= start + timeOutMs) {
51-
throw new TimeoutException("Could not retrieve the mutation status of '" + uuid + "' within " + timeOutMs + "ms");
51+
try {
52+
node = request.execute(uuid);
53+
if (node != null) {
54+
status = node.status();
55+
} else {
56+
status = STATUS_RECEIVED;
57+
}
58+
} catch (Exception e) {
59+
status = STATUS_RECEIVED;
5260
}
5361
} while (status == null || status == STATUS_RECEIVED);
54-
5562
if (status == STATUS_ERROR) {
56-
throw new IllegalStateException(message + ":\n" + getErrorDetail(node.error()));
63+
String errorMsg = (node != null) ? getErrorDetail(node.error()) : "Unknown server error";
64+
throw new IllegalStateException(message + ":\n" + errorMsg);
5765
}
58-
5966
return status;
6067
}
6168

0 commit comments

Comments
 (0)