Server 1 calls service on server 3
Server 3 calls back to server 1 and here we do a call to server 2 before returning
Server 3 calls now again server 1 and here we get a problem:
in com.atomikos.icatch.imp.CoordinatorStateHandler.setCascadeList(Map<String, Integer>) the cascadeList_ is overriden by the last 'allParticipants'. We loose the cascade entry for the call to server 1 here.
During prepare of server 2 we get then a NullPointerException:
java.lang.NullPointerException: null
at com.atomikos.remoting.twopc.AtomikosRestPort.prepare(AtomikosRestPort.java:134) ~[transactions-remoting-6.0.1-SNAPSHOT.jar:na]
the Line 134 is:
part.setGlobalSiblingCount(count);
count is null as the cascadeList has no entry for server 2
Tested with 6.0.1-SNAPSHOT and older versions.
In my pull request you will find 3 adaptions that we need for recursive calls (Server 1 calls Server 2 and Server 2 calls back to Server 1)-
The adaptions are done in ParticipantAdapter, CoordinatorImp and DefaultExportingTransactionManager. These fixes are well tested and are used in a complex production environment for a long time.
The fix for this NullPointerException is simple, i just merge the cascade maps in CoordinatorStateHandler :
protected void setCascadeList ( Map<String, Integer> allParticipants )
{
// we merge the maps and override values in cascadeList_
// if we dont merge we get a problem with callbacks
if (cascadeList_ != null) {
**cascadeList_.putAll(allParticipants);**
}
else {
cascadeList_ = allParticipants;
}
}
We have a complex scenario:
Server 1 calls service on server 3 Server 3 calls back to server 1 and here we do a call to server 2 before returning Server 3 calls now again server 1 and here we get a problem:
in com.atomikos.icatch.imp.CoordinatorStateHandler.setCascadeList(Map<String, Integer>) the cascadeList_ is overriden by the last 'allParticipants'. We loose the cascade entry for the call to server 1 here.
During prepare of server 2 we get then a NullPointerException:
java.lang.NullPointerException: null at com.atomikos.remoting.twopc.AtomikosRestPort.prepare(AtomikosRestPort.java:134) ~[transactions-remoting-6.0.1-SNAPSHOT.jar:na]
the Line 134 is: part.setGlobalSiblingCount(count); count is null as the cascadeList has no entry for server 2
Tested with 6.0.1-SNAPSHOT and older versions.
In my pull request you will find 3 adaptions that we need for recursive calls (Server 1 calls Server 2 and Server 2 calls back to Server 1)- The adaptions are done in ParticipantAdapter, CoordinatorImp and DefaultExportingTransactionManager. These fixes are well tested and are used in a complex production environment for a long time.
The fix for this NullPointerException is simple, i just merge the cascade maps in CoordinatorStateHandler :
Pull request containing fixes for recursive calls and a fix for the NullPointerException: https://github.com/atomikos/transactions-essentials/pull/187
To reproduce the error you have to start 3 sample applications in this repo: https://github.com/martinaubele/transactions-over-rest-with-hybrid-jaxrs-stack/tree/cascadeListBug Please do first a maven install on my pull request https://github.com/atomikos/transactions-essentials/pull/187 because you need fixes to enable recursive calls. If you want to see the NullPointerException please change the code in CoordinatorStateHandler back to