Skip to content

Commit

Permalink
Do not close transactional Connection in doReleaseConnection
Browse files Browse the repository at this point in the history
Closes gh-28133
  • Loading branch information
jhoeller committed Oct 11, 2023
1 parent 66ce8c9 commit 80e82cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public static Mono<Void> doReleaseConnection(Connection connection, ConnectionFa
if (conHolder != null && connectionEquals(conHolder, connection)) {
// It's the transactional Connection: Don't close it.
conHolder.released();
return Mono.empty();
}
return Mono.from(connection.close());
}).onErrorResume(NoTransactionException.class, ex -> Mono.from(connection.close()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,15 @@ void shouldEmitBoundConnection() {
ConnectionFactoryUtils.getConnection(connectionFactoryMock)
.doOnNext(transactionalConnection::set).flatMap(connection -> proxyCf.create()
.doOnNext(wrappedConnection -> assertThat(((Wrapped<?>) wrappedConnection).unwrap()).isSameAs(connection)))
.as(rxtx::transactional)
.flatMapMany(Connection::close)
.as(rxtx::transactional)
.as(StepVerifier::create)
.verifyComplete();

verify(connectionFactoryMock, times(1)).create();
verify(connectionMock1, times(1)).close();
verifyNoInteractions(connectionMock2);
verifyNoInteractions(connectionMock3);
verify(connectionFactoryMock, times(1)).create();
}

}

0 comments on commit 80e82cd

Please sign in to comment.