From 8fff54d6ee7dd2b807c5d7560c0f29587609754e Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Wed, 4 Jul 2018 21:00:11 +0300 Subject: [PATCH] HHH-12769 - Rework LockTest#testContendedPessimisticLock so that it can work on Oracle without throwing exceptions --- .../java/org/hibernate/jpa/test/lock/LockTest.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java index db068fe947..9f07cd1272 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/lock/LockTest.java @@ -425,9 +425,10 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { final CountDownLatch latch = new CountDownLatch( 1 ); final Lock lock = new Lock(); + final AtomicBoolean backgroundThreadHasReadNewValue = new AtomicBoolean(); + FutureTask bgTask = new FutureTask<>( () -> { - AtomicBoolean backgroundThreadHasReadNewValue = new AtomicBoolean(); try { doInJPA( this::entityManagerFactory, _entityManager -> { @@ -490,29 +491,22 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { if ( backGroundThreadCompleted ) { // the background thread read a value. At the very least we need to assert that he did not see the // changed value - boolean backgroundThreadHasReadNewValue = bgTask.get(); assertFalse( "The background thread is not allowed to see the updated value while the first transaction has not committed yet", - backgroundThreadHasReadNewValue + backgroundThreadHasReadNewValue.get() ); } else { log.debug( "The background thread was blocked" ); - boolean backgroundThreadHasReadNewValue = bgTask.get(); assertTrue( "Background thread should read the new value after being unblocked", - backgroundThreadHasReadNewValue + backgroundThreadHasReadNewValue.get() ); } } catch (InterruptedException e) { Thread.interrupted(); } - catch (ExecutionException e) { - if ( !Oracle8iDialect.class.isAssignableFrom( Dialect.getDialect().getClass() ) ) { - fail(e.getMessage()); - } - } } ); } finally {