fixed WebSphereUowTransactionManager regression: correctly roll back in case of exception (SPR-6695)

This commit is contained in:
Juergen Hoeller 2010-02-03 19:41:14 +00:00
parent 6e21c17253
commit 41ecbc6814
2 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2010 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -339,6 +339,7 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager
} }
catch (Throwable ex) { catch (Throwable ex) {
this.exception = ex; this.exception = ex;
uowManager.setRollbackOnly();
} }
finally { finally {
if (status.isLocalRollbackOnly()) { if (status.isLocalRollbackOnly()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2010 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,9 +20,12 @@ import javax.transaction.RollbackException;
import javax.transaction.Status; import javax.transaction.Status;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import com.ibm.wsspi.uow.UOWAction;
import com.ibm.wsspi.uow.UOWException;
import com.ibm.wsspi.uow.UOWManager;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.MockControl; import org.easymock.MockControl;
import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.mock.jndi.ExpectedLookupTemplate; import org.springframework.mock.jndi.ExpectedLookupTemplate;
import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.IllegalTransactionStateException;
@ -34,10 +37,6 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
import com.ibm.wsspi.uow.UOWAction;
import com.ibm.wsspi.uow.UOWException;
import com.ibm.wsspi.uow.UOWManager;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
@ -383,7 +382,7 @@ public class WebSphereUowTransactionManagerTests extends TestCase {
assertEquals(0, manager.getUOWTimeout()); assertEquals(0, manager.getUOWTimeout());
assertEquals(UOWManager.UOW_TYPE_GLOBAL_TRANSACTION, manager.getUOWType()); assertEquals(UOWManager.UOW_TYPE_GLOBAL_TRANSACTION, manager.getUOWType());
assertFalse(manager.getJoined()); assertFalse(manager.getJoined());
assertFalse(manager.getRollbackOnly()); assertTrue(manager.getRollbackOnly());
} }
public void testNewTransactionWithRollbackOnly() { public void testNewTransactionWithRollbackOnly() {