Skip to content
Advertisement

argument mismatch; invalid functional descriptor for lambda expression

I am using the jdbi library like so:

JavaScript

This try catch pattern is repeated a few times, with various different queries passed to the jdbi.withHandle method. Another example:

JavaScript

The jdbi.withHandle method has this signature:

JavaScript

I am trying to find a way to reduce the duplication around the try-catch, so that I can use something like this instead:

JavaScript

i.e. the handleTransientExceptions function would contain the try-catch boilderplate.

I’ve begun with the following:

JavaScript

however, when I try to call it like this:

JavaScript

I get the error:

JavaScript

Advertisement

Answer

Types cannot be inferred, because your functional interface JdbiCall doesn’t have neither generics at the class declaration level nor parameters for call method by which these types can be inferred. So, your FI might look like this:

JavaScript

and handleTransientExceptions method:

JavaScript

Also it can be simplified to:

JavaScript

handleTransientExceptions method:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement