From 0e6c1110fa6a357ef16e0b3bb9d8b222349eeba3 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 6 Feb 2023 12:22:14 +0100 Subject: [PATCH] Fix possible Mockito concurrency issue --- .../org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java index 414ab42441..6f48265d14 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java @@ -26,7 +26,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider { super.configure( props ); DataSource ds = unwrap( DataSource.class ); DataSource dataSource = Mockito.mock( - DataSource.class, + ds.getClass(), Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( ds ) ); @@ -34,7 +34,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider { Mockito.doAnswer( invocation -> { Connection connection = (Connection) invocation.callRealMethod(); Connection connectionSpy = Mockito.mock( - Connection.class, + connection.getClass(), Mockito.withSettings().defaultAnswer( Answers.CALLS_REAL_METHODS ).spiedInstance( connection ) ); connectionSpyMap.put( connectionSpy, connection );