bugfix: fixed bugs in EventBus unit tests #3607
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ⅰ. Describe what this PR did
单独测试DefaultCoreForEventBusTest#test时并不会出现,当与coordinator目录下的其它单元测试一并测试时,由于其中也存在需要异步提交的事务单测,导致GlobalTransactionEventSubscriber中的processGlobalTransactionEvent会进入多次相同的事务状态更改通知,导致单测无法通过
![image](https://user-images.githubusercontent.com/19943636/113500495-ee211580-9550-11eb-9239-37a3f6e20fc5.png)
目前有2个修复方案:
1.如上面说的sleep,比较粗暴,但是能解决
2.Assertions.assertEquals强行要求了事务状态变更只能1次的通知,我觉得只要不是null就可以接受了
pr中采用方案1
理由:方案一虽然粗暴但是不会改变此单测的目的,而方案二的话就把结果改变了
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews