From 2ea6f6174423d426205a5e047e2bd5e4b4cd2bd9 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 11 May 2022 18:21:21 +0200 Subject: Shell removal task exception handling Signed-off-by: Georg Pfuetzenreuter --- src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java b/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java index 26408df..135a424 100644 --- a/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java +++ b/src/main/java/net/libertacasa/pubsh/web/SchedulerBean.java @@ -29,9 +29,13 @@ public class SchedulerBean { return Tasks.oneTime("shell-removal") .execute((instance, ctx) -> { System.out.printf("Running container removal task - Instance: %s, ctx: %s\n", instance, ctx); - String username = instance.getId().split("&")[0]; - String containerid = instance.getId().split("&")[1]; - Docker.deleteShell(username, containerid); + try { + String username = instance.getId().split("&")[0]; + String containerid = instance.getId().split("&")[1]; + Docker.deleteShell(username, containerid); + } catch (com.github.dockerjava.api.exception.NotFoundException exception) { + System.out.printf("Container does not exist\n"); + } }); } -- cgit v1.2.3