Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
public static final String ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY =
"spring.main.allow-bean-definition-overriding";

public static final String DUBBO_THREAD_POOL_PROPERTY = "dubbo.protocol.threadpool";

public static final String VIRTUAL_THREAD = "virtual";

public static final String SPRING_THREAD_POOL_PROPERTY = "spring.threads.virtual.enabled";

private static final String ENABLED_VALUE = "true";

@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();
Expand All @@ -73,9 +81,17 @@ private Map<String, Object> createDefaultProperties(ConfigurableEnvironment envi
Map<String, Object> defaultProperties = new HashMap<>();
setDubboApplicationNameProperty(environment, defaultProperties);
setDubboConfigMultipleProperty(defaultProperties);
setDubboVirtualThreadsProperty(environment, defaultProperties);
return defaultProperties;
}

private void setDubboVirtualThreadsProperty(Environment environment, Map<String, Object> defaultProperties) {
String virtualEnabled = environment.getProperty(SPRING_THREAD_POOL_PROPERTY);
if (ENABLED_VALUE.equals(virtualEnabled)) {
defaultProperties.put(DUBBO_THREAD_POOL_PROPERTY, VIRTUAL_THREAD);
}
}

private void setDubboApplicationNameProperty(Environment environment, Map<String, Object> defaultProperties) {
String springApplicationName = environment.getProperty(SPRING_APPLICATION_NAME_PROPERTY);
if (StringUtils.hasLength(springApplicationName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,15 @@ void testPostProcessEnvironment() {
instance.postProcessEnvironment(environment, springApplication);
assertEquals("false", environment.getProperty("dubbo.config.multiple"));
assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));

// Case 6 : Test virtual thread property when spring.threads.virtual.enabled=true
environment = new MockEnvironment();
propertySources = environment.getPropertySources();
propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap<String, Object>()));
environment.setProperty("spring.threads.virtual.enabled", "true");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
assertNotNull(defaultPropertySource);
assertEquals("virtual", defaultPropertySource.getProperty("dubbo.protocol.threadpool"));
}
}
Loading