From c28e7e027ee567188bb680a562c4950322d2607d Mon Sep 17 00:00:00 2001 From: Jonatan Ivanov Date: Mon, 18 Jul 2022 16:47:33 -0700 Subject: [PATCH] Fix Blockhound config for micrometer-context-propagation Since the ServiceLoader reads the files in a blocking way, Blockhound can detect these and cause java.lang.NoClassDefFoundError: Could not initialize class errors if the ServiceLoader is called from a static scope (static variable init or static block). --- .../cloud/gateway/test/CustomBlockHoundIntegration.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/CustomBlockHoundIntegration.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/CustomBlockHoundIntegration.java index d8453442..c7ad30aa 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/CustomBlockHoundIntegration.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/test/CustomBlockHoundIntegration.java @@ -93,9 +93,9 @@ public class CustomBlockHoundIntegration implements BlockHoundIntegration { "org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader", "loadBeanDefinitions"); builder.allowBlockingCallsInside("org.springframework.core.type.classreading.SimpleMetadataReader", "getClassReader"); - builder.allowBlockingCallsInside("io.micrometer.contextpropagation.ThreadLocalAccessorLoader", - "getThreadLocalAccessors"); - builder.allowBlockingCallsInside("io.micrometer.contextpropagation.PropagatorLoader", "getPropagatorForSet"); + + builder.allowBlockingCallsInside("io.micrometer.context.ContextRegistry", "loadContextAccessors"); + builder.allowBlockingCallsInside("io.micrometer.context.ContextRegistry", "loadThreadLocalAccessors"); } }