@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        rejectCount.incrementAndGet();
        if (ApplicationContextHolder.getInstance() != null) {
            try {
                ThreadPoolCheckAlarm alarmHandler = ApplicationContextHolder.getBean(ThreadPoolCheckAlarm.class);
                alarmHandler.asyncSendRejectedAlarm(threadPoolId);
            } catch (Throwable ex) {
                log.error("Failed to send rejection policy alert.", ex);
            }
        }
        try {
            return method.invoke(target, args);
        } catch (InvocationTargetException ex) {
            throw ex.getCause();
        }
    }
@Test
    public void testInvoke() throws Throwable {
        Object[] mockArgs = new Object[]{"arg1", "arg2"};
        MockedStatic<ApplicationContextHolder> mockedStatic = Mockito.mockStatic(ApplicationContextHolder.class);
        mockedStatic.when(ApplicationContextHolder::getInstance).thenReturn(applicationContext);
        mockedStatic.when(() -> ApplicationContextHolder.getBean(ThreadPoolCheckAlarm.class)).thenReturn(mockAlarmHandler);
        Mockito.doNothing().when(mockAlarmHandler).asyncSendRejectedAlarm("test-pool");
        handler.invoke(null, mockMethod, mockArgs);
        Mockito.doThrow(new InvocationTargetException(new Throwable())).when(mockMethod).invoke(target, mockArgs);
        Assertions.assertThrows(Throwable.class, () -> handler.invoke(null, mockMethod, mockArgs));
        Assertions.assertSame(rejectCount.get(), 2L);
    }