Skip to content

Commit a92bb2f

Browse files
committed
Improve null-safety of module/spring-boot-graphql
See spring-projectsgh-46926
1 parent 1546853 commit a92bb2f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

module/spring-boot-graphql/src/main/java/org/springframework/boot/graphql/autoconfigure/reactive/GraphQlWebFluxAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.springframework.http.HttpStatus;
6060
import org.springframework.http.MediaType;
6161
import org.springframework.http.codec.ServerCodecConfigurer;
62+
import org.springframework.util.Assert;
6263
import org.springframework.web.cors.CorsConfiguration;
6364
import org.springframework.web.reactive.HandlerMapping;
6465
import org.springframework.web.reactive.config.CorsRegistry;
@@ -190,6 +191,7 @@ GraphQlWebSocketHandler graphQlWebSocketHandler(WebGraphQlHandler webGraphQlHand
190191
HandlerMapping graphQlWebSocketEndpoint(GraphQlWebSocketHandler graphQlWebSocketHandler,
191192
GraphQlProperties properties) {
192193
String path = properties.getWebsocket().getPath();
194+
Assert.state(path != null, "'path' must not be null");
193195
logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path));
194196
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
195197
mapping.setHandlerPredicate(new WebSocketUpgradeHandlerPredicate());

module/spring-boot-graphql/src/main/java/org/springframework/boot/graphql/autoconfigure/servlet/GraphQlWebMvcAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.springframework.http.MediaType;
6363
import org.springframework.http.converter.GenericHttpMessageConverter;
6464
import org.springframework.http.converter.HttpMessageConverter;
65+
import org.springframework.util.Assert;
6566
import org.springframework.web.cors.CorsConfiguration;
6667
import org.springframework.web.servlet.HandlerMapping;
6768
import org.springframework.web.servlet.config.annotation.CorsRegistry;
@@ -212,6 +213,7 @@ private GenericHttpMessageConverter<Object> asGenericHttpMessageConverter(HttpMe
212213
@Bean
213214
HandlerMapping graphQlWebSocketMapping(GraphQlWebSocketHandler handler, GraphQlProperties properties) {
214215
String path = properties.getWebsocket().getPath();
216+
Assert.state(path != null, "'path' must not be null");
215217
logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path));
216218
WebSocketHandlerMapping mapping = new WebSocketHandlerMapping();
217219
mapping.setWebSocketUpgradeMatch(true);

0 commit comments

Comments
 (0)