HHH-7265 : Test case to repro ConcurrentModificationException
This commit is contained in:
parent
3cd58b6e79
commit
fc068be040
|
@ -25,6 +25,7 @@ package org.hibernate.ejb.test.transaction;
|
|||
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Synchronization;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -108,4 +109,33 @@ public class TransactionJoiningTest extends BaseEntityManagerFunctionalTestCase
|
|||
|
||||
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImplicitJoiningWithExtraSynchronization() throws Exception {
|
||||
assertFalse( JtaStatusHelper.isActive( TestingJtaPlatformImpl.INSTANCE.getTransactionManager() ) );
|
||||
|
||||
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
|
||||
EntityManager entityManager = entityManagerFactory().createEntityManager();
|
||||
SessionImplementor session = entityManager.unwrap( SessionImplementor.class );
|
||||
Transaction hibernateTransaction = ( (Session) session ).getTransaction();
|
||||
assertTrue( CMTTransaction.class.isInstance( hibernateTransaction ) );
|
||||
assertTrue( session.getTransactionCoordinator().isSynchronizationRegistered() );
|
||||
assertTrue( hibernateTransaction.isParticipating() );
|
||||
|
||||
entityManager.close();
|
||||
|
||||
hibernateTransaction.registerSynchronization(
|
||||
new Synchronization() {
|
||||
public void beforeCompletion() {
|
||||
// nothing to do
|
||||
}
|
||||
public void afterCompletion( int i ) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
);
|
||||
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue