diff --git a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/RuntimeContextBeanFactoryPostProcessor.java b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/RuntimeContextBeanFactoryPostProcessor.java index 42f11a782..bc8129287 100644 --- a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/RuntimeContextBeanFactoryPostProcessor.java +++ b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/RuntimeContextBeanFactoryPostProcessor.java @@ -64,12 +64,8 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) .addBeanPostProcessor(new ReferenceAnnotationBeanPostProcessor(applicationContext, sofaRuntimeContext, bindingAdapterFactory, bindingConverterFactory)); - // work on all bean on the beginning, then reorder after all bean post processors being registered - RuntimeShutdownAwarePostProcessor runtimeShutdownAwarePostProcessor = new RuntimeShutdownAwarePostProcessor( - sofaRuntimeContext.getSofaRuntimeManager()); - beanFactory.addBeanPostProcessor(runtimeShutdownAwarePostProcessor); - beanFactory.registerSingleton(RuntimeShutdownAwarePostProcessor.class.getCanonicalName(), - runtimeShutdownAwarePostProcessor); + beanFactory.registerSingleton(RuntimeShutdownAwarePostProcessor.class.getSimpleName(), + new RuntimeShutdownAwarePostProcessor(sofaRuntimeContext.getSofaRuntimeManager())); if (beanFactory instanceof AbstractAutowireCapableBeanFactory) { ((AbstractAutowireCapableBeanFactory) beanFactory) diff --git a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/test/java/com/alipay/sofa/runtime/test/BeanPostProcessorOrderTest.java b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/test/java/com/alipay/sofa/runtime/test/BeanPostProcessorOrderTest.java index 645310859..0bbe45c62 100644 --- a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/test/java/com/alipay/sofa/runtime/test/BeanPostProcessorOrderTest.java +++ b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/test/java/com/alipay/sofa/runtime/test/BeanPostProcessorOrderTest.java @@ -68,13 +68,6 @@ public void testSofaRuntimeContextInject() { Assert.assertNotNull(highOrderBeanPostProcessor.getSofaRuntimeContext()); } - @Test - public void testShutDownHook() throws Exception { - List applicationShutdownAwares = getApplicationShutdownAwares(); - Assert.assertNotNull(applicationShutdownAwares); - Assert.assertTrue(applicationShutdownAwares.contains(highOrderBeanPostProcessor)); - } - @Test @SuppressWarnings("unchecked") public void testShutDownHookReordered() throws Exception {