From f225de5925efd224f0720e417442fb76af76dd2c Mon Sep 17 00:00:00 2001 From: Joseph Cosentino Date: Wed, 17 Jul 2024 16:35:44 -0700 Subject: [PATCH] fix(deployment): propagate interrupt from list groups operation (#1554) --- .../aws/greengrass/deployment/DefaultDeploymentTask.java | 4 +++- .../com/aws/greengrass/deployment/DeploymentTaskTest.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/aws/greengrass/deployment/DefaultDeploymentTask.java b/src/main/java/com/aws/greengrass/deployment/DefaultDeploymentTask.java index e0c02a6a5e..aecbf51cd6 100644 --- a/src/main/java/com/aws/greengrass/deployment/DefaultDeploymentTask.java +++ b/src/main/java/com/aws/greengrass/deployment/DefaultDeploymentTask.java @@ -181,7 +181,7 @@ public DeploymentResult call() throws InterruptedException { } } - @SuppressWarnings({"PMD.AvoidCatchingGenericException"}) + @SuppressWarnings({"PMD.AvoidCatchingGenericException", "PMD.AvoidRethrowingException"}) private Map> getNonTargetGroupToRootPackagesMap( DeploymentDocument deploymentDocument) throws DeploymentTaskFailureException, InterruptedException { @@ -208,6 +208,8 @@ private Map> getNonTargetGroupToRoot } else { throw new DeploymentTaskFailureException("Error fetching thing group information", e); } + } catch (InterruptedException e) { + throw e; } catch (Exception e) { if (isLocalDeployment && ThingGroupHelper.RETRYABLE_EXCEPTIONS.contains(e.getClass())) { logger.atWarn().setCause(e).log("Failed to get thing group hierarchy, local deployment will proceed"); diff --git a/src/test/java/com/aws/greengrass/deployment/DeploymentTaskTest.java b/src/test/java/com/aws/greengrass/deployment/DeploymentTaskTest.java index 1ca4cd77be..80a3068a23 100644 --- a/src/test/java/com/aws/greengrass/deployment/DeploymentTaskTest.java +++ b/src/test/java/com/aws/greengrass/deployment/DeploymentTaskTest.java @@ -170,6 +170,12 @@ void GIVEN_deploymentDocument_WHEN_thingGroupHelper_throws_error_THEN_deployment assertEquals("Error fetching thing group information. Original error message", failureMessage); } + @Test + void GIVEN_deploymentDocument_WHEN_thingGroupHelper_interrupted_THEN_deployment_task_interrupted() throws Exception { + when(mockThingGroupHelper.listThingGroupsForDevice(anyInt())).thenThrow(InterruptedException.class); + assertThrows(InterruptedException.class, deploymentTask::call); + } + @Test void GIVEN_deploymentDocument_WHEN_resolveDependencies_errored_THEN_deploymentTask_aborted(ExtensionContext context) throws Exception {