Skip to content

Commit

Permalink
Merge pull request #2200 from wso2/revert-2162-enrich
Browse files Browse the repository at this point in the history
Revert "Fix enrich mediator failing continuously when a parse error happens"
  • Loading branch information
GDLMadushanka authored Jul 11, 2024
2 parents c56ed2f + b1266a4 commit 676bb92
Showing 1 changed file with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 676bb92

Please sign in to comment.