Skip to content

Commit 3e70013

Browse files
committed
JmsResourceHolder checks for nested DataSource transactions as well (for Oracle AQ compatibility)
Issue: SPR-11791 (cherry picked from commit 5faacd5)
1 parent ea9ad4e commit 3e70013

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -191,10 +191,20 @@ public void commitAll() throws JMSException {
191191
try {
192192
Method getDataSourceMethod = this.connectionFactory.getClass().getMethod("getDataSource");
193193
Object ds = ReflectionUtils.invokeMethod(getDataSourceMethod, this.connectionFactory);
194-
if (ds != null && TransactionSynchronizationManager.hasResource(ds)) {
195-
// IllegalStateException from sharing the underlying JDBC Connection
196-
// which typically gets committed first, e.g. with Oracle AQ --> ignore
197-
return;
194+
while (ds != null) {
195+
if (TransactionSynchronizationManager.hasResource(ds)) {
196+
// IllegalStateException from sharing the underlying JDBC Connection
197+
// which typically gets committed first, e.g. with Oracle AQ --> ignore
198+
return;
199+
}
200+
try {
201+
// Check for decorated DataSource a la Spring's DelegatingDataSource
202+
Method getTargetDataSourceMethod = ds.getClass().getMethod("getTargetDataSource");
203+
ds = ReflectionUtils.invokeMethod(getTargetDataSourceMethod, ds);
204+
}
205+
catch (NoSuchMethodException nsme) {
206+
ds = null;
207+
}
198208
}
199209
}
200210
catch (Throwable ex2) {

0 commit comments

Comments
 (0)