From 518f56d5402f5d2e28f8595bea9911f734e7d1f2 Mon Sep 17 00:00:00 2001 From: chanikag Date: Wed, 23 Aug 2023 10:00:43 +0530 Subject: [PATCH] Add review sugessions --- .../synapse/config/SequenceFlowObserversLoader.java | 3 ++- .../apache/synapse/mediators/AbstractListMediator.java | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/synapse/config/SequenceFlowObserversLoader.java b/modules/core/src/main/java/org/apache/synapse/config/SequenceFlowObserversLoader.java index e4cff53ae5..94ef9cadc1 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/SequenceFlowObserversLoader.java +++ b/modules/core/src/main/java/org/apache/synapse/config/SequenceFlowObserversLoader.java @@ -19,6 +19,7 @@ package org.apache.synapse.config; import org.apache.axiom.om.OMElement; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.synapse.SequenceFlowObserver; @@ -63,7 +64,7 @@ public static List loadObservers() { if (observerElem.getAttribute(CLASS_Q) != null) { String className = observerElem.getAttributeValue(CLASS_Q); - if (!"".equals(className)) { + if (StringUtils.isNotBlank(className)) { SequenceFlowObserver observer = createObserver(className); if (observer != null) { observers.add(observer); diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/AbstractListMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/AbstractListMediator.java index 79ce14b6fb..ead1f90a90 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/AbstractListMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/AbstractListMediator.java @@ -82,7 +82,7 @@ public boolean mediate(MessageContext synCtx, int mediatorPosition) { // to pass it on; else, do nothing -> i.e. let the parents state flow setEffectiveTraceState(synCtx); int myEffectiveTraceState = synCtx.getTracingState(); - if (this instanceof SequenceMediator) { + if (this instanceof SequenceMediator & mediatorPosition == 0) { List observers = synCtx.getEnvironment().getSequenceObservers(); for (SequenceFlowObserver observer : observers) { observer.start(synCtx, ((SequenceMediator) this).getName()); @@ -112,6 +112,14 @@ public boolean mediate(MessageContext synCtx, int mediatorPosition) { returnVal = false; break; } + if (i == mediators.size() - 1) { + if (this instanceof SequenceMediator) { + List observers = synCtx.getEnvironment().getSequenceObservers(); + for (SequenceFlowObserver observer : observers) { + observer.complete(synCtx, ((SequenceMediator) this).getName()); + } + } + } mediator.reportCloseStatistics(synCtx, statisticReportingIndex); } else { synCtx.setTracingState(myEffectiveTraceState);