Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace命令可能在多次执行后,不打印结果 #1817

Closed
hengyunabc opened this issue Jun 9, 2021 · 0 comments
Closed

Trace命令可能在多次执行后,不打印结果 #1817

hengyunabc opened this issue Jun 9, 2021 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@hengyunabc
Copy link
Collaborator

测试代码:

public class AAA {
    
    public static void main(String[] args) {
        
        for(;;) {
            aaa();
        }
        
    }
    
    public static void aaa() {
        
        for(int i = 0; i < 10; ++i) {
            bbb(i);
            System.err.println(i);
        }
        
    }
    
    public static void bbb(int i ) {
        try {
            Thread.sleep(i * 100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

执行 trace AAA aaa ,然后q,停止后,再次执行trace AAA aaa。很大概率出现下面的信息:

$ trace AAA aaa
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 24 ms, listenerId: 2

然后一直挂起,不打印trace结果,好像是 aaa 函数没被调用,但实际上 aaa 一直在执行。


原因是trace在第一次执行时, before/after 的执行并不一定对等。可能没有执行before,只执行了 after,然后AbstractTraceAdviceListener里的判断就会出问题,出现 traceEntity.deep是负数。

@hengyunabc hengyunabc added the bug Something isn't working label Jun 9, 2021
@hengyunabc hengyunabc added this to the 3.5.2 milestone Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant