public static void addBodyMutations()

in callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java [110:135]


    public static void addBodyMutations(
            BodyResponse.Builder bodyResponseBuilder,
            String body,
            Boolean clearBody,
            Boolean clearRouteCache) {
        CommonResponse.Builder responseBuilder = bodyResponseBuilder.getResponseBuilder();
        BodyMutation.Builder bodyBuilder = responseBuilder.getBodyMutationBuilder();

        if (body != null) {
            // Set the body, ignore clearBody if body is provided
            bodyBuilder.setBody(ByteString.copyFromUtf8(body));

            // Log a warning if both body and clearBody are provided
            if (Boolean.TRUE.equals(clearBody)) {
                logger.log(Level.WARNING, "Body and clearBody are mutually exclusive. clearBody will be ignored.");
            }
        } else {
            // If body is not provided, use clearBody
            bodyBuilder.setClearBody(clearBody);
        }

        // Handle clearRouteCache if provided
        if (clearRouteCache != null) {
            responseBuilder.setClearRouteCache(clearRouteCache);
        }
    }