static TtlAgentStatus getLoadedAgentOrEmpty()

in ttl-core/src/main/java/com/alibaba/ttl3/agent/EmptyTtlAgentStatus.java [24:47]


    static TtlAgentStatus getLoadedAgentOrEmpty() {
        if (ttlAgentStatus != null) return ttlAgentStatus;

        synchronized (EmptyTtlAgentStatus.class) {
            // double check
            if (ttlAgentStatus != null) return ttlAgentStatus;

            final String TTL_AGENT_CLASS = "com.alibaba.ttl3.agent.TtlAgent";

            TtlAgentStatus ret;
            try {
                ret = (TtlAgentStatus) Class.forName(TTL_AGENT_CLASS).getDeclaredConstructor().newInstance();
            } catch (ClassNotFoundException e) {
                ret = new EmptyTtlAgentStatus();
            } catch (Exception e) {
                propagateIfFatal(e);
                throw new IllegalStateException("Fail to create the TTL agent instance(" + TTL_AGENT_CLASS
                        + "), should be a bug! report to the TTL project. cause: " + e, e);
            }

            ttlAgentStatus = ret;
            return ret;
        }
    }