mirror of
https://github.com/apache/activemq.git
synced 2025-02-15 14:36:59 +00:00
[AMQ-8400] Add synchronization handling for Transaction to prevent CME (#720)
This commit is contained in:
parent
c58e531584
commit
f2dbc92743
@ -87,16 +87,20 @@ public abstract class Transaction {
|
||||
}
|
||||
|
||||
public Synchronization findMatching(Synchronization r) {
|
||||
synchronized(synchronizations) {
|
||||
int existing = synchronizations.indexOf(r);
|
||||
if (existing != -1) {
|
||||
return synchronizations.get(existing);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeSynchronization(Synchronization r) {
|
||||
synchronized(synchronizations) {
|
||||
synchronizations.remove(r);
|
||||
}
|
||||
}
|
||||
|
||||
public void prePrepare() throws Exception {
|
||||
|
||||
@ -121,26 +125,32 @@ public abstract class Transaction {
|
||||
}
|
||||
|
||||
protected void fireBeforeCommit() throws Exception {
|
||||
synchronized(synchronizations) {
|
||||
for (Iterator<Synchronization> iter = synchronizations.iterator(); iter.hasNext();) {
|
||||
Synchronization s = iter.next();
|
||||
s.beforeCommit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void fireAfterCommit() throws Exception {
|
||||
synchronized(synchronizations) {
|
||||
for (Iterator<Synchronization> iter = synchronizations.iterator(); iter.hasNext();) {
|
||||
Synchronization s = iter.next();
|
||||
s.afterCommit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fireAfterRollback() throws Exception {
|
||||
synchronized(synchronizations) {
|
||||
Collections.reverse(synchronizations);
|
||||
for (Iterator<Synchronization> iter = synchronizations.iterator(); iter.hasNext();) {
|
||||
Synchronization s = iter.next();
|
||||
s.afterRollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user