I have the following code, where I am trying to return a value through a lambda expression.
{ message: Any ->
try {
ObjectMappers.getObjectMapper().writeValueAsString(message).toByteArray()
}
catch(e: JsonProcessingException)
{
e.printStackTrace()
}
null
},
However, the code always returns null. On debugging, I found that program execution is going through the try block executing its code but then also executing the null
outside the try catch block? Why is this happening? Should it not return from inside the try block and exit the lambda expression?
(The expression is being passed as an argument to a function that is expecting functional values)