Source:
<code>public Action<?, ?> failedAction() { return new AbstractSdxAction<>(SdxDeletionFailedEvent.class) { @Override protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDeletionFailedEvent payload) { return SdxContext.from(flowParameters, payload); } @Override protected void doExecute(SdxContext context, SdxDeletionFailedEvent payload, Map<Object, Object> variables) throws Exception { Exception exception = payload.getException(); LOGGER.error("Datalake delete failed for datalake: {}", payload.getResourceId(), exception); String statusReason = "Datalake deletion failed"; if (exception.getMessage() != null) { statusReason = exception.getMessage(); } <START> if (payload.isForced()) { <END> Long datalakeId = payload.getResourceId(); LOGGER.info("Datalake delete finalized: {}", datalakeId); SdxCluster sdxCluster = sdxService.getById(datalakeId); if (sdxCluster != null) { metricService.incrementMetricCounter(MetricType.SDX_DELETION_FINISHED, sdxCluster); } sendEvent(context, SDX_DELETE_FINALIZED_EVENT.event(), payload); } else { try { SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETE_FAILED, statusReason, payload.getResourceId()); metricService.incrementMetricCounter(MetricType.SDX_DELETION_FAILED, sdxCluster); } catch (NotFoundException notFoundException) { LOGGER.info("Can not set status to SDX_DELETION_FAILED because data lake was not found"); } sendEvent(context, SDX_DELETE_FAILED_HANDLED_EVENT.event(), payload); } } @Override protected Object getFailurePayload(SdxDeletionFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) { return null; } }; }</code><technical_language>I is a good idea check "forced" flag here. a approach if handle separately in stack deletion rds deletion phase. this implementation, hide error is related stack rds delete. For example is a nullpointer exception somewhere, set sdx delete status happen. move a logic this StackDeletionHandler RdsDeletionHandler</technical_language>

Target:
public Action<?, ?> failedAction() { return new AbstractSdxAction<>(SdxDeletionFailedEvent.class) { @Override protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDeletionFailedEvent payload) { return SdxContext.from(flowParameters, payload); } @Override protected void doExecute(SdxContext context, SdxDeletionFailedEvent payload, Map<Object, Object> variables) throws Exception { Exception exception = payload.getException(); LOGGER.error("Datalake delete failed for datalake: {}", payload.getResourceId(), exception); String statusReason = "Datalake deletion failed"; if (exception.getMessage() != null) { statusReason = exception.getMessage(); } try { SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETE_FAILED, statusReason, payload.getResourceId()); metricService.incrementMetricCounter(MetricType.SDX_DELETION_FAILED, sdxCluster); } catch (NotFoundException notFoundException) { LOGGER.info("Can not set status to SDX_DELETION_FAILED because data lake was not found"); } sendEvent(context, SDX_DELETE_FAILED_HANDLED_EVENT.event(), payload); } @Override protected Object getFailurePayload(SdxDeletionFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) { return null; } }; }