From 41ecbc6814fa930a6ea68f336b5a12bc662578bb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 3 Feb 2010 19:41:14 +0000 Subject: [PATCH] fixed WebSphereUowTransactionManager regression: correctly roll back in case of exception (SPR-6695) --- .../jta/WebSphereUowTransactionManager.java | 3 ++- .../jta/WebSphereUowTransactionManagerTests.java | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/org.springframework.transaction/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java b/org.springframework.transaction/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java index c727a07a412..c5fbafa5376 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java +++ b/org.springframework.transaction/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java @@ -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"); * you may not use this file except in compliance with the License. @@ -339,6 +339,7 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager } catch (Throwable ex) { this.exception = ex; + uowManager.setRollbackOnly(); } finally { if (status.isLocalRollbackOnly()) { diff --git a/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java index 91adf3f4cde..b6dbf51348f 100644 --- a/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java +++ b/org.springframework.transaction/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java @@ -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"); * 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.UserTransaction; +import com.ibm.wsspi.uow.UOWAction; +import com.ibm.wsspi.uow.UOWException; +import com.ibm.wsspi.uow.UOWManager; import junit.framework.TestCase; - import org.easymock.MockControl; + import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.mock.jndi.ExpectedLookupTemplate; 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.TransactionSynchronizationManager; -import com.ibm.wsspi.uow.UOWAction; -import com.ibm.wsspi.uow.UOWException; -import com.ibm.wsspi.uow.UOWManager; - /** * @author Juergen Hoeller */ @@ -383,7 +382,7 @@ public class WebSphereUowTransactionManagerTests extends TestCase { assertEquals(0, manager.getUOWTimeout()); assertEquals(UOWManager.UOW_TYPE_GLOBAL_TRANSACTION, manager.getUOWType()); assertFalse(manager.getJoined()); - assertFalse(manager.getRollbackOnly()); + assertTrue(manager.getRollbackOnly()); } public void testNewTransactionWithRollbackOnly() {