@@ -726,23 +726,32 @@ protected LRAStatus toLRAStatus(int atomicActionStatus) {
726
726
727
727
public LRAParticipantRecord enlistParticipant (URI coordinatorUrl , String participantUrl , String recoveryUrlBase ,
728
728
long timeLimit , String compensatorData ) throws UnsupportedEncodingException {
729
- LRAParticipantRecord participant = findLRAParticipant (participantUrl , false );
730
-
731
- if (participant != null ) {
732
- participant .setCompensatorData (compensatorData );
733
- return participant ; // must have already been enlisted
729
+ ReentrantLock lock = tryLockTransaction ();
730
+ if (lock == null ) {
731
+ LRALogger .i18nLogger .warn_enlistment ();
732
+ return null ;
734
733
}
735
-
736
- participant = doEnlistParticipant (coordinatorUrl , participantUrl , recoveryUrlBase ,
737
- timeLimit , compensatorData );
738
-
739
- if (participant != null ) {
740
- // need to remember that there is a new participant
741
- deactivate (); // if it fails the superclass will have logged a warning
742
- savedIntentionList = true ; // need this clean up if the LRA times out
734
+ else {
735
+ try {
736
+ LRAParticipantRecord participant = findLRAParticipant (participantUrl , false );
737
+ if (participant != null ) {
738
+ participant .setCompensatorData (compensatorData );
739
+ return participant ; // must have already been enlisted
740
+ }
741
+ participant = doEnlistParticipant (coordinatorUrl , participantUrl , recoveryUrlBase , timeLimit ,
742
+ compensatorData );
743
+ if (participant != null ) {
744
+ // need to remember that there is a new participant
745
+ deactivate (); // if it fails the superclass will have logged a warning
746
+ savedIntentionList = true ; // need this clean up if the LRA times out
747
+ }
748
+ return participant ;
749
+ }
750
+ finally {
751
+ lock .unlock ();
752
+ }
743
753
}
744
754
745
- return participant ;
746
755
}
747
756
748
757
private LRAParticipantRecord doEnlistParticipant (URI coordinatorUrl , String participantUrl , String recoveryUrlBase ,
0 commit comments