Skip to content

Commit

Permalink
refactor: throw IOException instead of wrapping in Runtime #1535
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanzalu committed Jan 15, 2025
1 parent abbf08d commit cbe07cf
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand All @@ -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);
}

Expand Down

0 comments on commit cbe07cf

Please sign in to comment.