When I run `DELETE` operation with `spring-r2dbc` ...
# spring
r
When I run
DELETE
operation with
spring-r2dbc
and coroutines, by using such code inside a suspending function:
Copy code
databaseClient.execute("DELETE FROM tab WHERE field = :field").bind("field", 5).then().awaitFirstOrNull()
Spring Boot gives me the following exception in logs:
Copy code
2019-09-12 19:52:05,849 [reactor-tcp-epoll-3] ERROR i.r.p.client.ReactorNettyClient - Connection Error
io.netty.util.IllegalReferenceCountException: refCnt: 0
        at io.netty.buffer.AbstractByteBuf.ensureAccessible(AbstractByteBuf.java:1464)
        at io.netty.buffer.CompositeByteBuf.discardReadComponents(CompositeByteBuf.java:1733)
        at io.r2dbc.postgresql.message.backend.BackendMessageEnvelopeDecoder.lambda$apply$0(BackendMessageEnvelopeDecoder.java:69)
        at reactor.core.publisher.FluxCreate.subscribe(FluxCreate.java:94)
        at reactor.core.publisher.Flux.subscribe(Flux.java:8127)
It looks like some kind of resource leak warning, because my code is running fine and SQL statement is executed correctly. If I run:
Copy code
databaseClient.delete().from("tab").matching(where("field").`is`(5)).then().awaitFirstOrNull()
there is no exception. And there are no problems with other kind of queries (SELECT, INSERT, UPDATE). Is this my bug? Or is this probably a bug in
spring boot
or
spring-r2dbc
?
s
Does the same code runs fine with Reactive API ? Unrelated, but any reason to use
then().awaitFirstOrNull()
instead of the provide extensions?
And what version of Boot + Spring Data R2DBC are you using?
r
I'm not using reactive api, so I'm not sure and I'm not really know how to check this. What should I use instead of
then().awaitFirstOrNull()
to execute the statement and suspend until it is done? I'm using: Spring Boot 2.2.0.BUILD-SNAPSHOT Spring Data R2DBC 1.0.0.BUILD-SNAPSHOT r2dbc-postgresql 0.8.0.BUILD-SNAPSHOT (the only combination that works for me at the moment)
Try
.fetch().awaitOneOrNull
maybe
We provide Kotlin extensions
For Coroutines directly
It lacks of documentation for now
r
Apparently the problem solved itself ... Gradle downloaded some new snapshots and the exception is gone 🙂 Thx for your support anyway.
One more question - is there any significant difference in using await* kotlin extensions from spring-data and await* extensions from coroutines.rective?
I haven't even noticed I'm mixing those extensions in my code until your question
s
Nope they are just shortcuts