Browse code

BM-14982 Fix: catch exception on datasource error

David Phan authored on 26/06/2019 08:11:29
Showing 1 changed files
... ...
@@ -333,15 +333,19 @@ public class Containers implements IContainers {
333 333
 		List<BaseContainerDescriptor> ret = new ArrayList<BaseContainerDescriptor>();
334 334
 
335 335
 		dataSources.forEach(ds -> {
336
-			ContainerStore containerStore = new ContainerStore(context, ds, securityContext);
337
-			if (query.owner != null) {
338
-				// FIXME not everybody should be able to call this
339
-				ret.addAll(asDescriptorsLight(
340
-						doOrFail(() -> containerStore.findByTypeOwnerReadOnly(query.type, query.owner, query.readonly)),
341
-						securityContext));
342
-			} else {
343
-				ret.addAll(asDescriptorsLight(doOrFail(() -> containerStore.findAccessiblesByType(query)),
344
-						securityContext));
336
+			try {
337
+				ContainerStore containerStore = new ContainerStore(context, ds, securityContext);
338
+				if (query.owner != null) {
339
+					// FIXME not everybody should be able to call this
340
+					ret.addAll(asDescriptorsLight(doOrFail(
341
+							() -> containerStore.findByTypeOwnerReadOnly(query.type, query.owner, query.readonly)),
342
+							securityContext));
343
+				} else {
344
+					ret.addAll(asDescriptorsLight(doOrFail(() -> containerStore.findAccessiblesByType(query)),
345
+							securityContext));
346
+				}
347
+			} catch (Exception e) {
348
+				logger.warn("Fail to fetch containers on datasource {}", ds);
345 349
 			}
346 350
 
347 351
 		});
... ...
@@ -363,13 +367,18 @@ public class Containers implements IContainers {
363 367
 		List<ContainerDescriptor> ret = new ArrayList<ContainerDescriptor>();
364 368
 
365 369
 		dataSources.forEach(ds -> {
366
-			ContainerStore suContainerStore = new ContainerStore(context, ds, sc);
367
-			if (query.owner != null && query.type != null) {
368
-				ret.addAll(asDescriptors(doOrFail(() -> suContainerStore.findByTypeAndOwner(query.type, query.owner)),
369
-						sc));
370
-			} else {
371
-				ret.addAll(asDescriptors(doOrFail(() -> suContainerStore.findAccessiblesByType(query)), sc));
370
+			try {
371
+				ContainerStore suContainerStore = new ContainerStore(context, ds, sc);
372
+				if (query.owner != null && query.type != null) {
373
+					ret.addAll(asDescriptors(
374
+							doOrFail(() -> suContainerStore.findByTypeAndOwner(query.type, query.owner)), sc));
375
+				} else {
376
+					ret.addAll(asDescriptors(doOrFail(() -> suContainerStore.findAccessiblesByType(query)), sc));
377
+				}
378
+			} catch (Exception e) {
379
+				logger.warn("Fail to fetch containers for user {} on datasource {}", userUid, ds);
372 380
 			}
381
+
373 382
 		});
374 383
 		return dedup(ret);
375 384