Home Programming Detect Unintentional Blocking Calls when Utilizing R2DBC – Java, SQL and jOOQ.

Detect Unintentional Blocking Calls when Utilizing R2DBC – Java, SQL and jOOQ.

Detect Unintentional Blocking Calls when Utilizing R2DBC – Java, SQL and jOOQ.


Some time in the past, jOOQ has added the org.jetbrains:annotations dependency to the jOOQ API, with a purpose to annotate return sorts with nullability data. For instance, your complete DSL is non-nullable:

public interface SelectWhereStep<R extends Document>
extends SelectConnectByStep<R> {

    @NotNull @CheckReturnValue
    SelectConditionStep<R> the place(Situation situation);

    // ...

It is smart to provide this assure particularly to kotlin customers, as they’ll do away with among the extra complicated sorts involving issues like Choose!<Document!>, which now turns into not less than Choose<Document!>. Discover additionally the @CheckReturnValue annotation, which IntelliJ makes use of for some introspections.

Different circumstances are extra apparent, equivalent to:

public interface ResultQuery<R extends Document> 
extends Fields, Question, Iterable<R>, Writer<R> {

    R fetchOne() throws TooManyRowsException;

    R fetchSingle() throws NoDataFoundException, TooManyRowsException;

    // ...

The distinction between these two sorts of fetch strategies is that fetchOne() expects 0-1 ensuing data, whereas fetchSingle() expects precisely 1 file. Each throw exceptions in any other case, however solely the latter can assure a non-nulllable file worth.

However wait, what’s this @Blocking annotation?

In jOOQ 3.17, we’ve added the org.jetbrains.annotations.Blocking annotation to all jOOQ API that executes a question on prime of JDBC. This doesn’t have an effect on customers of JDBC primarily based jOOQ queries in any respect, however for those who’re utilizing R2DBC for reactive querying with jOOQ, you is likely to be tempted to by accident name one in every of jOOQ’s many many blocking execution strategies.

No extra! IntelliJ will now complain about such a name being inappropriate:


Not less than as quickly as you allow the introspection:


It’s as much as you to determine whether or not you need this to be a warning or an error, however not less than, you’ll discover that you simply’re about to do one thing fallacious.

Eclipse doesn’t but assist this sort of introspection. Should you agree it ought to, you can upvote this situation right here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=578310.


Supply hyperlink


Please enter your comment!
Please enter your name here