Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Mono.when not respond #226

@kevin70

Description

@kevin70

versions:

java 11
r2dbc-spi: 0.9.0-RELEASE
r2dbc-mysql: 0.9.0-SNAPSHOT

code:

Mono<Void> f1(Connection connection) {
  return Flux.from(connection.createStatement("this is bad sql").execute())
      .flatMap(Result::getRowsUpdated)
      .then();
}

Mono<Void> f2(Connection connection) {
  return Flux.from(connection.createStatement("this is bad sql").execute())
      .flatMap(Result::getRowsUpdated)
      .then();
}

Mono<Void> execWhen(Connection connection) {
  return Mono.when(f1(connection), f2(connection));
}

@Test
void testFailed() {
  var connectionFactory = super.rc.getConnectionFactory();
  Flux.usingWhen(
          connectionFactory.create(),
          connection -> {
            // transaction
            return Flux.from(connection.beginTransaction())
                .thenMany(execWhen(connection))
                .concatWith(connection.commitTransaction())
                .onErrorResume(
                    t -> Mono.from(connection.rollbackTransaction()).then(Mono.error(t)));
          },
          Connection::close)
      .as(StepVerifier::create)
      .expectError(R2dbcBadGrammarException.class)
      .verify(Duration.ofSeconds(10));
}

results:

AssertionError: VerifySubscriber timed out on reactor.core.publisher.FluxUsingWhen$ResourceSubscriber

expect:

R2dbcBadGrammarException

When I use Mono.when when an exception occurs when connecting multiple publishers, the upstream will not return the correct result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions