From 9d37794ebcc403e33f343e41ec121ddb83e30328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Tue, 30 Jun 2020 11:50:26 +0200 Subject: [PATCH] Avoid using LiveBeansView in GraalVM native images Closes gh-25344 --- .../context/support/AbstractApplicationContext.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 69a88ae0fd..1788845a0c 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -916,7 +916,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader publishEvent(new ContextRefreshedEvent(this)); // Participate in LiveBeansView MBean, if active. - LiveBeansView.registerApplicationContext(this); + if (!IN_NATIVE_IMAGE) { + LiveBeansView.registerApplicationContext(this); + } } /** @@ -1024,7 +1026,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader logger.debug("Closing " + this); } - LiveBeansView.unregisterApplicationContext(this); + if (!IN_NATIVE_IMAGE) { + LiveBeansView.unregisterApplicationContext(this); + } try { // Publish shutdown event.