-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointer when using R2DBC Pool 0.9.0.RELEASE with version 0.4.0 #64
Comments
By the way, even this simple statement throws the same null pointer Mono.from(connectionPool.create())
.flatMapMany(connection ->
Flux.from(connection.createStatement("SELECT 1 FROM dual").execute())
.flatMap(result ->
result.map((row, metadata) -> row.get(0, Integer.class)))
).subscribe(s -> System.out.println("Value: " + s ));
return Mono.empty(); |
I will make a test with java 11. I am not sure if oracle jdbc already supports java 17 |
Thanks for all these details, @sgtcortez. This NPE looks like the same issue we saw here: #63 |
Thank you @Michael-A-McMahon. I will make this test, and, I will come back here with the result. |
Hi, @Michael-A-McMahon I tested, and, now I am facing another problem ... oracle.r2dbc.impl.OracleR2dbcExceptions$OracleR2dbcException: Closed Statement: getStatement
at oracle.r2dbc.impl.OracleR2dbcExceptions.toR2dbcException(OracleR2dbcExceptions.java:217)
at oracle.r2dbc.impl.OracleR2dbcExceptions.fromJdbc(OracleR2dbcExceptions.java:282)
at oracle.r2dbc.impl.OracleReactiveJdbcAdapter.publishRows(OracleReactiveJdbcAdapter.java:747)
at oracle.r2dbc.impl.OracleResultImpl$ResultSetResult.publishSegments(OracleResultImpl.java:479)
at oracle.r2dbc.impl.OracleResultImpl.publishSegments(OracleResultImpl.java:150)
at oracle.r2dbc.impl.OracleResultImpl.map(OracleResultImpl.java:219)
at br.com.dimed.catalogservice.repository.TaxRuleRepository.lambda$fetchTaxRule$6(TaxRuleRepository.java:116)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onNext(MonoFlatMapMany.java:163)
at reactor.core.publisher.MonoUsingWhen$MonoUsingWhenSubscriber.deferredComplete(MonoUsingWhen.java:278)
at reactor.core.publisher.FluxUsingWhen$CommitInner.onComplete(FluxUsingWhen.java:540)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260)
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:209)
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onComplete(MonoIgnoreThen.java:209)
at reactor.pool.SimpleDequePool.lambda$maybeRecycleAndDrain$19(SimpleDequePool.java:513)
at reactor.core.publisher.LambdaMonoSubscriber.onComplete(LambdaMonoSubscriber.java:135)
at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onComplete(FluxDoFinally.java:145)
at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:102)
at reactor.core.publisher.MonoNext$NextSubscriber.onComplete(MonoNext.java:102)
at oracle.r2dbc.impl.AsyncLock$UsingConnectionSubscriber.onComplete(AsyncLock.java:497) // This one works
Mono.from(connectionPool.create())
.flatMapMany(connection ->
Flux.from(connection.createStatement("SELECT 1 FROM dual").execute())
.flatMap(result ->
result.map((row, metadata) -> row.get(0, Integer.class)))
).subscribe(s -> System.out.println("Value: " + s ));
// This one does not work
return Mono.usingWhen(
connectionPool.create(),
connection -> Mono.from(connection.createStatement(QUERY)
.bind(0, destinationState)
.bind(1, subsidiaryId)
.bind(2, itemId)
.bind(3, destinationState)
.bind(4, itemId)
.bind(5, destinationState)
.bind(6, itemId)
.execute()
),
Connection::close,
((connection, throwable) -> connection.close()),
Connection::close
)
.flatMapMany(it -> it.map(mapper))
.next(); I am not sure, but, might call close before create. Dependencies: implementation 'io.r2dbc:r2dbc-pool:0.9.0.RELEASE'
implementation 'io.r2dbc:r2dbc-spi:0.9.0.RELEASE'
implementation 'com.oracle.database.jdbc:ojdbc11:21.3.0.0'
runtimeOnly 'com.oracle.database.r2dbc:oracle-r2dbc:0.4.0' |
We have: .flatMapMany(it -> it.map(mapper)) And it is downstream of the usingWhen publisher, so the Connection::close happens before the invocation of map on the Result. You could try moving the flatMapMany operator into the connection using function, like this: ...
.execute()
.flatMapMany(it -> it.map(mapper)) The main thing to understand is that anything inside of the try (Connection connection = dataSource.getConnection()) {
... Connection, and any Statements or ResultSets it creates are only valid inside of this try block
} |
@Michael-A-McMahon thank you for your help. With your help, I changed the code, and now, It works ! public Mono<TaxRuleDto> fetchTaxRule(
final long itemId,
final long subsidiaryId,
final String destinationState) {
return Flux.usingWhen(
connectionPool.create(),
connection -> Mono.from(connection.createStatement(QUERY)
.bind(0, destinationState)
.bind(1, subsidiaryId)
.bind(2, itemId)
.bind(3, destinationState)
.bind(4, itemId)
.bind(5, destinationState)
.bind(6, itemId)
.execute()
).flatMapMany(it -> it.map(mapper)),
Connection::close,
((connection, throwable) -> connection.close()),
Connection::close
).next(); This query can return only one row, but, I could make it work with Mono, so, for now, It is fine! Again, thanks for your time & help. |
Hi All, |
Hi @vedhavi. Thanks for bringing this to my attention. |
Hi, I am facing a weird problem using:
Java Version: Oracle JDK 17
First of all, I was using the version 0.1.0 with R2DBC POOL, and, it works when executing a single statement, but, with paralell calls, I face the problem with: Multiple subscribers ...
So, I came here, and, read that thats a know problem with version 0.1.0. Then, I upgrade to the version 0.4.0 which, is the latest.
But, trying to execute the same query(which works with version 0.1.0) , but, I am receiving a NullPointer inside oracle r2dbc classes.
StackTrace:
How I execute the query:
How I create the connection pool:
I thought that I would be a problem with dependency versions, but, I checked the dependencies and, I am using the correct ones.
Please, tell me where I am making a mistake
Dependencies:
The text was updated successfully, but these errors were encountered: