diff --git a/dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java b/dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java index 2545d53a..350ae7c0 100644 --- a/dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java +++ b/dil/src/main/java/org/assimbly/dil/loader/FlowLoader.java @@ -255,6 +255,7 @@ private void removeRouteConfiguration(String flowId) { ModelCamelContext modelContext = (ModelCamelContext) context; List routeConfigurationsToRemove = modelContext.getRouteConfigurationDefinitions().stream() + .filter(Objects::nonNull) // Exclude null entries .filter(routeConfig -> routeConfig.getId().startsWith(flowId)) .toList(); // Collect into a new list to avoid modifying the original list during iteration diff --git a/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java b/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java index 5956dd89..336bbe97 100644 --- a/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java +++ b/integration/src/main/java/org/assimbly/integration/impl/CamelIntegration.java @@ -1315,7 +1315,7 @@ public String startFlow(String id, long timeout) { initFlowActionReport(id, "Start"); if(hasFlow(id)) { - stopFlow(id, timeout); + stopFlow(id, timeout, false); } boolean addFlow = false; @@ -1346,13 +1346,12 @@ public String startFlow(String id, long timeout) { if (!result.equals("loaded") && !result.equals("started")){ if(result.equalsIgnoreCase("error")){ String startReport = loadReport; - stopFlow(id, timeout); + stopFlow(id, timeout, false); loadReport = startReport; }else{ finishFlowActionReport(id, "error",result,"error"); } }else if(result.equals("loaded")) { - List steps = getRoutesByFlowId(id); log.info("Starting " + steps.size() + " steps"); @@ -1373,7 +1372,7 @@ public String startFlow(String id, long timeout) { }catch (Exception e) { if(context.isStarted()) { - stopFlow(id, stopTimeout); + stopFlow(id, stopTimeout, false); finishFlowActionReport(id, "error","Start flow failed | error=" + e.getMessage(),"error"); log.error("Start flow failed. | flowid=" + id,e); }else{ @@ -1426,14 +1425,7 @@ private ServiceStatus startStep(Route route){ public String restartFlow(String id, long timeout) { try { - - if(hasFlow(id)) { - stopFlow(id, timeout); - startFlow(id, timeout); - }else { - startFlow(id, timeout); - } - + startFlow(id, timeout); }catch (Exception e) { log.error("Restart flow failed. | flowid=" + id,e); finishFlowActionReport(id, "error", e.getMessage(),"error"); @@ -1444,8 +1436,14 @@ public String restartFlow(String id, long timeout) { } public String stopFlow(String id, long timeout) { + return stopFlow(id, timeout, true); + } + + public String stopFlow(String id, long timeout, boolean enableReport) { - initFlowActionReport(id, "stop"); + if(enableReport) { + initFlowActionReport(id, "stop"); + } try { @@ -1467,10 +1465,14 @@ public String stopFlow(String id, long timeout) { } - finishFlowActionReport(id, "stop","Stopped flow successfully","info"); + if(enableReport) { + finishFlowActionReport(id, "stop", "Stopped flow successfully", "info"); + } }catch (Exception e) { - finishFlowActionReport(id, "error","Stop flow failed | error=" + e.getMessage(),"error"); + if(enableReport) { + finishFlowActionReport(id, "error", "Stop flow failed | error=" + e.getMessage(), "error"); + } log.error("Stop flow failed. | flowid=" + id,e); } @@ -2337,7 +2339,7 @@ public String getStats(String mediaType) throws Exception { } return stats; - + } private double getMemoryUsage(){