Skip to content

Commit 565dc0c

Browse files
committed
Merge branch '2.4.x'
Closes gh-25556
2 parents 6e5c510 + ba5c57c commit 565dc0c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,6 +78,7 @@ RSocketWebSocketNettyRouteProvider rSocketWebsocketRouteProvider(RSocketProperti
7878
}
7979

8080
@ConditionalOnProperty(prefix = "spring.rsocket.server", name = "port")
81+
@ConditionalOnClass(ReactorResourceFactory.class)
8182
@Configuration(proxyBeanMethods = false)
8283
static class EmbeddedServerAutoConfiguration {
8384

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,17 +19,21 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.boot.autoconfigure.AutoConfigurations;
22+
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
23+
import org.springframework.boot.logging.LogLevel;
2224
import org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer;
2325
import org.springframework.boot.rsocket.context.RSocketServerBootstrap;
2426
import org.springframework.boot.rsocket.server.RSocketServerCustomizer;
2527
import org.springframework.boot.rsocket.server.RSocketServerFactory;
28+
import org.springframework.boot.test.context.FilteredClassLoader;
2629
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2730
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
2831
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
2932
import org.springframework.context.annotation.Bean;
3033
import org.springframework.context.annotation.Configuration;
3134
import org.springframework.core.codec.CharSequenceEncoder;
3235
import org.springframework.core.codec.StringDecoder;
36+
import org.springframework.http.client.reactive.ReactorResourceFactory;
3337
import org.springframework.messaging.rsocket.RSocketStrategies;
3438
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
3539
import org.springframework.util.unit.DataSize;
@@ -141,6 +145,14 @@ void shouldUseCustomNettyRouteProvider() {
141145
.containsExactly("customNettyRouteProvider"));
142146
}
143147

148+
@Test
149+
void whenSpringWebIsNotPresentThenEmbeddedServerConfigurationBacksOff() {
150+
contextRunner().withClassLoader(new FilteredClassLoader(ReactorResourceFactory.class))
151+
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO))
152+
.withPropertyValues("spring.rsocket.server.port=0")
153+
.run((context) -> assertThat(context).doesNotHaveBean(RSocketServerFactory.class));
154+
}
155+
144156
private ApplicationContextRunner contextRunner() {
145157
return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class)
146158
.withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class));

0 commit comments

Comments
 (0)