From b1266a45166b5c81a084b8f8350a376d0e94aa58 Mon Sep 17 00:00:00 2001 From: Lahiru Madushanka Date: Thu, 11 Jul 2024 10:03:36 +0530 Subject: [PATCH] Revert "Fix enrich mediator failing continuously when a parse error happens" --- .../synapse/mediators/elementary/Source.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/elementary/Source.java b/modules/core/src/main/java/org/apache/synapse/mediators/elementary/Source.java index 7200998579..a43f516570 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/elementary/Source.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/elementary/Source.java @@ -321,27 +321,24 @@ public JsonElement evaluateJson(MessageContext synCtx, SynapseLog synLog, case EnrichMediator.INLINE: { assert inlineOMNode != null || inlineKey != null : "inlineJSONNode or key shouldn't be null when type is INLINE"; - try { - if (inlineOMNode instanceof OMText) { - object = JsonPath.parse(((OMTextImpl) inlineOMNode).getText()).json(); - } else if (inlineKey != null && !inlineKey.trim().equals("")) { - Object inlineObj = synCtx.getEntry(inlineKey); - if ((inlineObj instanceof String) && !(((String) inlineObj).trim().equals(""))) { - object = JsonPath.parse(((String) inlineObj)).json(); - } else { - synLog.error("Source failed to get inline JSON" + "inlineKey=" + inlineKey); - } + if (inlineOMNode instanceof OMText) { + object = JsonPath.parse(((OMTextImpl) inlineOMNode).getText()).json(); + } else if (inlineKey != null && !inlineKey.trim().equals("")) { + Object inlineObj = synCtx.getEntry(inlineKey); + if ((inlineObj instanceof String) && !(((String) inlineObj).trim().equals(""))) { + object = JsonPath.parse(((String) inlineObj)).json(); } else { - synLog.error("Source failed to get inline JSON" + "inlineJSONNode=" + inlineOMNode + ", inlineKey=" - + inlineKey); - } - } finally { - // If the initialInlineOMNode is not null, it means that inline OM Node has been overridden with the - // inline string containing resolved dynamic values. Therefore, we should set the initial OM Node back - // which contains the original inline value - if (initialInlineOMNode != null) { - this.inlineOMNode = initialInlineOMNode; + synLog.error("Source failed to get inline JSON" + "inlineKey=" + inlineKey); } + } else { + synLog.error("Source failed to get inline JSON" + "inlineJSONNode=" + inlineOMNode + ", inlineKey=" + + inlineKey); + } + // If the initialInlineOMNode is not null, it means that inline OM Node has been overridden with the + // inline string containing resolved dynamic values. Therefore, we should set the initial OM Node back + // which contains the original inline value + if (initialInlineOMNode != null) { + this.inlineOMNode = initialInlineOMNode; } break; }