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

AnsiLog 的 static 初始化可能抛出异常 #2740

Closed
hengyunabc opened this issue Nov 28, 2023 · 1 comment
Closed

AnsiLog 的 static 初始化可能抛出异常 #2740

hengyunabc opened this issue Nov 28, 2023 · 1 comment
Milestone

Comments

@hengyunabc
Copy link
Collaborator

参考这个: #1686 (comment)

我们的找到问题了。
有个研发写的代码,强制把slot=0的shutdown hook位置占了。

SharedSecrets.getJavaLangAccess.registerShutdownHook(0, false, xx);

导致arthas的AnsiLog的class load异常,

    static {
        if (System.console() != null) {
            enableColor = true;
            // windows dos, do not support color
            if (OSUtils.isWindows()) {
                enableColor = false;
            }
        }
        // cygwin and mingw support color
        if (OSUtils.isCygwinOrMinGW()) {
            enableColor = true;
        }
    }

从而导致ArthasBootstrap的bind端口失败,所以后边就连不上端口了:

    private ArthasBootstrap(Instrumentation instrumentation, Map<String, String> args) throws Throwable {
        this.instrumentation = instrumentation;

        initFastjson();

        // 1. initSpy()
        initSpy();
        // 2. ArthasEnvironment
        initArthasEnvironment(args);

        String outputPathStr = configure.getOutputPath();
        if (outputPathStr == null) {
            outputPathStr = ArthasConstants.ARTHAS_OUTPUT;
        }
        outputPath = new File(outputPathStr);
        outputPath.mkdirs();

        // 3. init logger
        loggerContext = LogUtil.initLogger(arthasEnvironment);//异常

        // 4. 增强ClassLoader
        enhanceClassLoader();
        // 5. init beans
        initBeans();

        // 6. start agent server
        bind(configure);//bind端口失败
......
    }
@hengyunabc hengyunabc added this to the 4.0.0 milestone Nov 28, 2023
@iyangpengyu
Copy link

就加个catch能解决问题吗?这个slot=0的shutdown hook位置,不还是被占着么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants