From 60cb3762ba26810370c1955605c22ea840b7df13 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 14 Aug 2019 11:55:11 +0100 Subject: [PATCH] HHH-13577 LockTest.testContendedPessimisticLock and StatementIsClosedAfterALockExceptionTest.testStatementIsClosed tests fail on Sybase HHH-13577 : Re-enable LockTest for SybaseASE15Dialect (cherry picked from commit 210aff098c2b1d1c59e7780829d9c19bfff08e46) --- .../java/org/hibernate/jpa/test/lock/LockTest.java | 1 - .../testing/transaction/TransactionUtil.java | 7 +++++++ .../org/hibernate/testing/util/ExceptionUtil.java | 12 +++++++----- 3 files changed, 14 insertions(+), 6 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 dc6e41c282..09c149d46c 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 @@ -559,7 +559,6 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { @SkipForDialect(HSQLDialect.class) // ASE15.5 will generate select...holdlock and fail at this test, but ASE15.7 passes it. Skip it for ASE15.5 // only. - @SkipForDialect(value = { SybaseASE15Dialect.class }, strictMatching = true, jiraKey = "HHH-6820") @SkipForDialect(value = { SQLServerDialect.class }) public void testContendedPessimisticLock() throws Exception { final CountDownLatch latch = new CountDownLatch( 1 ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java b/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java index 02cd8cd5ac..15a63d29c5 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java @@ -28,6 +28,7 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.SQLServerDialect; +import org.hibernate.dialect.SybaseASE15Dialect; import org.jboss.logging.Logger; @@ -568,6 +569,12 @@ public class TransactionUtil { st.execute(String.format( "SET TRANSACTION LOCK WAIT TIMEOUT %d", millis )); } } + else if( Dialect.getDialect() instanceof SybaseASE15Dialect) { + try (Statement st = connection.createStatement()) { + //Prepared Statements fail for SET commands + st.execute(String.format( "SET LOCK WAIT %d", millis/1000 )); + } + } else { try { connection.setNetworkTimeout( Executors.newSingleThreadExecutor(), (int) millis ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/util/ExceptionUtil.java b/hibernate-testing/src/main/java/org/hibernate/testing/util/ExceptionUtil.java index cb244aecea..c2ef8bef79 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/util/ExceptionUtil.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/util/ExceptionUtil.java @@ -79,11 +79,13 @@ public class ExceptionUtil { else { Throwable rootCause = ExceptionUtil.rootCause( e ); if ( - rootCause != null && ( - rootCause.getMessage().contains( "timeout" ) || - rootCause.getMessage().contains( "timed out" ) || - rootCause.getMessage().contains( "lock(s) could not be acquired" ) - ) + rootCause != null && ( + rootCause.getMessage().contains( "timeout" ) || + rootCause.getMessage().contains( "timed out" ) || + rootCause.getMessage().contains( "lock(s) could not be acquired" ) || + rootCause.getMessage().contains( "Could not acquire a lock" ) + + ) ) { return true; }