HHH-12769 - Rework LockTest#testContendedPessimisticLock so that it can work on Oracle without throwing exceptions
This commit is contained in:
parent
6b3e4e6f56
commit
8fff54d6ee
|
@ -425,9 +425,10 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
final CountDownLatch latch = new CountDownLatch( 1 );
|
final CountDownLatch latch = new CountDownLatch( 1 );
|
||||||
final Lock lock = new Lock();
|
final Lock lock = new Lock();
|
||||||
|
|
||||||
|
final AtomicBoolean backgroundThreadHasReadNewValue = new AtomicBoolean();
|
||||||
|
|
||||||
FutureTask<Boolean> bgTask = new FutureTask<>(
|
FutureTask<Boolean> bgTask = new FutureTask<>(
|
||||||
() -> {
|
() -> {
|
||||||
AtomicBoolean backgroundThreadHasReadNewValue = new AtomicBoolean();
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
doInJPA( this::entityManagerFactory, _entityManager -> {
|
doInJPA( this::entityManagerFactory, _entityManager -> {
|
||||||
|
@ -490,29 +491,22 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
if ( backGroundThreadCompleted ) {
|
if ( backGroundThreadCompleted ) {
|
||||||
// the background thread read a value. At the very least we need to assert that he did not see the
|
// the background thread read a value. At the very least we need to assert that he did not see the
|
||||||
// changed value
|
// changed value
|
||||||
boolean backgroundThreadHasReadNewValue = bgTask.get();
|
|
||||||
assertFalse(
|
assertFalse(
|
||||||
"The background thread is not allowed to see the updated value while the first transaction has not committed yet",
|
"The background thread is not allowed to see the updated value while the first transaction has not committed yet",
|
||||||
backgroundThreadHasReadNewValue
|
backgroundThreadHasReadNewValue.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug( "The background thread was blocked" );
|
log.debug( "The background thread was blocked" );
|
||||||
boolean backgroundThreadHasReadNewValue = bgTask.get();
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Background thread should read the new value after being unblocked",
|
"Background thread should read the new value after being unblocked",
|
||||||
backgroundThreadHasReadNewValue
|
backgroundThreadHasReadNewValue.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
Thread.interrupted();
|
Thread.interrupted();
|
||||||
}
|
}
|
||||||
catch (ExecutionException e) {
|
|
||||||
if ( !Oracle8iDialect.class.isAssignableFrom( Dialect.getDialect().getClass() ) ) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
Loading…
Reference in New Issue