From cbe07cf1047ceb8b2e0e56637b869f3e46fc9758 Mon Sep 17 00:00:00 2001 From: mvanzalu Date: Wed, 15 Jan 2025 14:50:18 +0000 Subject: [PATCH] refactor: throw IOException instead of wrapping in Runtime ICIJ/datashare#1535 --- .../java/org/icij/datashare/web/ProjectResource.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/datashare-app/src/main/java/org/icij/datashare/web/ProjectResource.java b/datashare-app/src/main/java/org/icij/datashare/web/ProjectResource.java index c7b1d5dbb..4122fa51d 100644 --- a/datashare-app/src/main/java/org/icij/datashare/web/ProjectResource.java +++ b/datashare-app/src/main/java/org/icij/datashare/web/ProjectResource.java @@ -212,7 +212,7 @@ public Payload isDownloadAllowed(String id, Context context) { @Operation(description = "Deletes all user's projects from database and elasticsearch index.") @ApiResponse(responseCode = "204", description = "if projects are deleted") @Delete("/") - public Payload deleteProjects(Context context) { + public Payload deleteProjects(Context context) throws IOException { DatashareUser user = (DatashareUser) context.currentUser(); Logger logger = LoggerFactory.getLogger(getClass()); getUserProjects(user).forEach(project -> { @@ -222,13 +222,9 @@ public Payload deleteProjects(Context context) { throw new RuntimeException(e); } }); - try { - logger.info("Stopping tasks : {}", taskManager.stopAllTasks(user)); - taskManager.waitTasksToBeDone(TaskManager.POLLING_INTERVAL*2, MILLISECONDS); - logger.info("Deleted tasks : {}", !taskManager.clearDoneTasks().isEmpty()); - } catch (IOException e) { - throw new RuntimeException(e); - } + logger.info("Stopping tasks : {}", taskManager.stopAllTasks(user)); + taskManager.waitTasksToBeDone(TaskManager.POLLING_INTERVAL*2, MILLISECONDS); + logger.info("Deleted tasks : {}", !taskManager.clearDoneTasks().isEmpty()); return new Payload(204); }