Hibernate SVN: r21032 - search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/worker.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2012-05-17 11:18:07 -0400 (Thu, 17 May 2012)
New Revision: 21032
Modified:
search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
JBPAPP-6856 hibernate - SyncWorkerTest sometimes hangs with mysql 5.5
Modified: search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2012-05-17 06:50:31 UTC (rev 21031)
+++ search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/worker/WorkerTestCase.java 2012-05-17 15:18:07 UTC (rev 21032)
@@ -58,6 +58,7 @@
while ( work.count.get() < iteration - 1 ) {
Thread.sleep( 20 );
}
+ es.shutdown();
getSessions().close();
System.out.println( iteration + " iterations (8 tx per iteration) in " + nThreads + " threads: " + ( System
.currentTimeMillis() - start ) );
@@ -145,8 +146,11 @@
}
public void run() {
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
+ Session s = null;
+ Transaction tx=null;
+ try{
+ s = sf.openSession();
+ tx = s.beginTransaction();
Employer er = new Employer();
er.setName( "RH" );
s.persist( er );
@@ -173,6 +177,18 @@
s.delete( ee );
tx.commit();
s.close();
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ } finally {
+ try {
+ if ( tx != null && tx.isActive() )
+ tx.rollback();
+ if ( s != null && s.isOpen() )
+ s.close();
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ }
+ }
}
}