Browse code

BM-15426 Fix: eas, move items: catch timeout

David Phan authored on 27/11/2019 09:17:43
Showing 4 changed files
... ...
@@ -305,7 +305,8 @@ public class ImapMailboxRecordsService extends BaseMailboxRecordsService impleme
305 305
 								.thenCompose(selec -> fast.fetch(current.value.imapUid, p.address))
306 306
 								.get(DEFAULT_TIMEOUT, TimeUnit.SECONDS);
307 307
 					} catch (TimeoutException e) {
308
-						throw new ServerFault("Failed to fetch part " + p.address + " from current. Timeout occured");
308
+						throw new ServerFault("Failed to fetch part " + p.address + " from current. Timeout occured",
309
+								ErrorCode.TIMEOUT);
309 310
 					}
310 311
 
311 312
 				});
... ...
@@ -432,7 +432,13 @@ public class ImapReplicatedMailboxesService extends BaseReplicatedMailboxesServi
432 432
 						});
433 433
 					}
434 434
 
435
-					rootPromise.get(15, TimeUnit.SECONDS);
435
+					try {
436
+						rootPromise.get(15, TimeUnit.SECONDS);
437
+					} catch (TimeoutException timeoutException) {
438
+						logger.warn(timeoutException.getMessage(), timeoutException);
439
+					} catch (Exception e) {
440
+						throw e;
441
+					}
436 442
 				}
437 443
 
438 444
 				return ret;
... ...
@@ -208,7 +208,13 @@ public class EmailManager extends CoreConnect {
208 208
 			ContainerChangeset<ItemVersion> changeset = service.filteredChangesetById(0L,
209 209
 					ItemFlagFilter.create().mustNot(ItemFlag.Deleted));
210 210
 			changeset.created.forEach(iv -> {
211
-				service.deleteById(iv.id);
211
+				try {
212
+					service.deleteById(iv.id);
213
+				} catch (ServerFault serverFault) {
214
+					if (serverFault.getCode() != ErrorCode.TIMEOUT) {
215
+						throw serverFault;
216
+					}
217
+				}
212 218
 			});
213 219
 		}
214 220
 
... ...
@@ -51,6 +51,8 @@ import net.bluemind.calendar.api.ICalendarUids;
51 51
 import net.bluemind.calendar.api.VEvent;
52 52
 import net.bluemind.calendar.api.VEventOccurrence;
53 53
 import net.bluemind.calendar.api.VEventSeries;
54
+import net.bluemind.core.api.fault.ErrorCode;
55
+import net.bluemind.core.api.fault.ServerFault;
54 56
 import net.bluemind.core.container.api.ContainerHierarchyNode;
55 57
 import net.bluemind.core.container.model.ContainerChangeset;
56 58
 import net.bluemind.core.container.model.ItemFlag;
... ...
@@ -232,7 +234,13 @@ public class MailBackend extends CoreConnect {
232 234
 					IMailboxItems service = getMailboxItemsService(bs, folder.uid);
233 235
 					items.get(folder).forEach(id -> {
234 236
 						logger.info("[{}] Delete mail {}", bs.getUser().getUid(), id);
235
-						service.deleteById(id);
237
+						try {
238
+							service.deleteById(id);
239
+						} catch (ServerFault sf) {
240
+							if (sf.getCode() != ErrorCode.TIMEOUT) {
241
+								throw sf;
242
+							}
243
+						}
236 244
 					});
237 245
 				}
238 246
 
... ...
@@ -275,8 +283,13 @@ public class MailBackend extends CoreConnect {
275 283
 					item.value.systemFlags.removeIf(f -> f == SystemFlag.flagged);
276 284
 				}
277 285
 			}
278
-
279
-			service.updateById(id, item.value);
286
+			try {
287
+				service.updateById(id, item.value);
288
+			} catch (ServerFault sf) {
289
+				if (sf.getCode() != ErrorCode.TIMEOUT) {
290
+					throw sf;
291
+				}
292
+			}
280 293
 
281 294
 			return ci;
282 295
 		}