@AfterAll
    public static void tearDownShiro() {
        doClearSubject();
        try {
            SecurityManager securityManager = getSecurityManager();
            LifecycleUtils.destroy(securityManager);
        } catch (UnavailableSecurityManagerException e) {
            //we don't care about this when cleaning up the test environment
            //(for example, maybe the subclass is a unit test and it didn't
            // need a SecurityManager instance because it was using only mock Subject instances)
        }
        setSecurityManager(null);
    }
Clears Shiro's thread state, ensuring the thread remains clean for future test execution.
core/src/test/java/org/apache/shiro/test/AbstractShiroTest.java