MongoDbInboundChAdapterIntTests race condition
Since we can have a result message in the `replyChannel` before the TX commit, a subsequent adapter `stop()` causes the current task interruption, therefore TX rallback. That's why we see `semaphore.acquire()` interruption and don't see message in the `afterCommitChannel` **Cherry-pick to 4.3.x**
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||||
@@ -218,11 +219,10 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
|||||||
assertNotNull(replyChannel.receive(10000));
|
assertNotNull(replyChannel.receive(10000));
|
||||||
assertNull(replyChannel.receive(100));
|
assertNull(replyChannel.receive(100));
|
||||||
|
|
||||||
this.inboundAdapterWithOnSuccessDisposition.stop();
|
|
||||||
|
|
||||||
assertNotNull(this.afterCommitChannel.receive(10000));
|
assertNotNull(this.afterCommitChannel.receive(10000));
|
||||||
|
|
||||||
assertNull(this.mongoTemplate.findOne(new Query(Criteria.where("name").is("Bob")), Person.class, "data"));
|
assertNull(this.mongoTemplate.findOne(new Query(Criteria.where("name").is("Bob")), Person.class, "data"));
|
||||||
|
this.inboundAdapterWithOnSuccessDisposition.stop();
|
||||||
this.replyChannel.purge(null);
|
this.replyChannel.purge(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user