Fix possible Mockito concurrency issue

This commit is contained in:
Christian Beikov 2023-02-06 12:22:14 +01:00
parent 563880037e
commit 0e6c1110fa
1 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider {
super.configure( props ); super.configure( props );
DataSource ds = unwrap( DataSource.class ); DataSource ds = unwrap( DataSource.class );
DataSource dataSource = Mockito.mock( DataSource dataSource = Mockito.mock(
DataSource.class, ds.getClass(),
Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( ds ) Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( ds )
); );
@ -34,7 +34,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider {
Mockito.doAnswer( invocation -> { Mockito.doAnswer( invocation -> {
Connection connection = (Connection) invocation.callRealMethod(); Connection connection = (Connection) invocation.callRealMethod();
Connection connectionSpy = Mockito.mock( Connection connectionSpy = Mockito.mock(
Connection.class, connection.getClass(),
Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( connection ) Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( connection )
); );
connectionSpyMap.put( connectionSpy, connection ); connectionSpyMap.put( connectionSpy, connection );