Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dataweave recursion limit?

Tags:

dataweave

I have the following DW 2.0 function for trimming white space on any string values in a JSON payload:

fun whiteSpaceTrimmer(item) = item match {
    case is Array -> $ map whiteSpaceTrimmer($)
    case is Object -> $ mapObject {
        ($$): $ match {
            case is String -> trim($)
            case is Object -> whiteSpaceTrimmer($)
            case is Array -> $ map whiteSpaceTrimmer($)
            else -> $
        }
    }
    case is String -> trim($)
    else -> $
}

Since it is recursive and I am not sure how deep of a nested structure it could handle before throwing an exception. Is there a limit on how many nested elements I can pass into this function? And if so is there a better approach?

like image 278
short stack stevens Avatar asked Mar 04 '23 09:03

short stack stevens


1 Answers

Hi the current MaxExecutionStack is 256. So this means that your data structure can have as much as 255 levels of nestedness before it throws StackOverflow. If this number is not enough for you there is a System Property called com.mulesoft.dw.stacksize that allows you to change this value.

like image 75
machaval Avatar answered Mar 08 '23 08:03

machaval