HHH-11267 Fix TombstoneTest
This commit is contained in:
parent
0728f7b35e
commit
4508a9e654
|
@ -12,13 +12,15 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.hibernate.PessimisticLockException;
|
import javax.persistence.OptimisticLockException;
|
||||||
import org.hibernate.StaleStateException;
|
import javax.persistence.PessimisticLockException;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||||
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
import org.hibernate.cache.infinispan.util.InfinispanMessageLogger;
|
||||||
import org.hibernate.cache.spi.Region;
|
import org.hibernate.cache.spi.Region;
|
||||||
|
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
import org.hibernate.test.cache.infinispan.functional.entities.Item;
|
import org.hibernate.test.cache.infinispan.functional.entities.Item;
|
||||||
|
@ -65,6 +67,18 @@ public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
|
||||||
|
// This applies to manually set LOCK_TIMEOUT for H2 DB. AvailableSettings.JPA_LOCK_TIMEOUT
|
||||||
|
// works only for queries, not for CRUDs, so we have to modify the connection URL.
|
||||||
|
// Alternative could be executing SET LOCK_TIMEOUT 1000 as a native query.
|
||||||
|
String url = (String) ssrb.getSettings().get(AvailableSettings.URL);
|
||||||
|
if (url != null && url.contains("LOCK_TIMEOUT")) {
|
||||||
|
url = url.replaceAll("LOCK_TIMEOUT=[^;]*", "LOCK_TIMEOUT=1000");
|
||||||
|
}
|
||||||
|
ssrb.applySetting(AvailableSettings.URL, url);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() {
|
protected void startUp() {
|
||||||
super.startUp();
|
super.startUp();
|
||||||
|
@ -105,7 +119,7 @@ public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
|
||||||
awaitOrThrow(preFlushLatch);
|
awaitOrThrow(preFlushLatch);
|
||||||
}
|
}
|
||||||
s.flush();
|
s.flush();
|
||||||
} catch (StaleStateException e) {
|
} catch (OptimisticLockException e) {
|
||||||
log.info("Exception thrown: ", e);
|
log.info("Exception thrown: ", e);
|
||||||
markRollbackOnly(s);
|
markRollbackOnly(s);
|
||||||
return false;
|
return false;
|
||||||
|
@ -135,7 +149,7 @@ public abstract class AbstractNonInvalidationTest extends SingleNodeTest {
|
||||||
awaitOrThrow(preFlushLatch);
|
awaitOrThrow(preFlushLatch);
|
||||||
}
|
}
|
||||||
s.flush();
|
s.flush();
|
||||||
} catch (StaleStateException e) {
|
} catch (OptimisticLockException e) {
|
||||||
log.info("Exception thrown: ", e);
|
log.info("Exception thrown: ", e);
|
||||||
markRollbackOnly(s);
|
markRollbackOnly(s);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue