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.
AbstractTraceAdviceListener的102行有一个todo,此pr解决该问题
// TODO: concurrency issue to abort process
abortProcess可能会重复执行,表现形式为重复输出“Command execution times exceed limit..."
该问题可以直接利用AtomicInteger的原子性来解决,在自增时同时获取自增后的当前值(原子操作),并以该值作为判定依据,该值会递增且连续,那么只须判断该值是否与limit相等,便可保证有且只有一个线程调用abortProcess
原来使用AtomicInteger.get,无法保证连续(比如当前值为9,两个线程同时执行incrementAndGet,然后再同时执行get,两个线程获取到的值均为11,10这个数值便被跳过了),因而只能用大于等于来判定,从而导致并发时,可能多个线程同时满足条件