@Bean
    @ConditionalOnMissingBean(TaskQueue.class)
    @Qualifier("taskQueue")
    @ConditionalOnProperty("shenyu.shared-pool.max-free-memory")
    public TaskQueue<Runnable> memorySafeTaskQueue(final ShenyuConfig shenyuConfig) {
        final ShenyuConfig.SharedPool sharedPool = shenyuConfig.getSharedPool();
        final Integer maxFreeMemory = sharedPool.getMaxFreeMemory();
        if (maxFreeMemory <= 0) {
            throw new ShenyuException("${shenyu.sharedPool.maxFreeMemory} must bigger than 0 !");
        }
        return new MemorySafeTaskQueue<>(maxFreeMemory);
    }
@Test
    public void testMemorySafeTaskQueue() {
        ShenyuConfig shenyuConfig = mock(ShenyuConfig.class);
        ShenyuConfig.SharedPool sharedPool = mock(ShenyuConfig.SharedPool.class);
        when(shenyuConfig.getSharedPool()).thenReturn(sharedPool);
        when(sharedPool.getMaxFreeMemory()).thenReturn(1024);
        assertTrue(shenyuThreadPoolConfiguration.memorySafeTaskQueue(shenyuConfig) instanceof MemorySafeTaskQueue);
        when(sharedPool.getMaxFreeMemory()).thenReturn(0);
        assertThrows(ShenyuException.class, () -> shenyuThreadPoolConfiguration.memorySafeTaskQueue(shenyuConfig));

    }