Skip to content

Commit 3c9cfa8

Browse files
committed
Revise order of method declarations in WebFluxConfigurer
See gh-30678
1 parent b016f38 commit 3c9cfa8

File tree

3 files changed

+109
-108
lines changed

3 files changed

+109
-108
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,56 +53,55 @@ public void setConfigurers(List<WebFluxConfigurer> configurers) {
5353

5454

5555
@Override
56-
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
57-
this.configurers.configureContentTypeResolver(builder);
56+
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
57+
this.configurers.configureHttpMessageCodecs(configurer);
5858
}
5959

6060
@Override
61-
protected void addCorsMappings(CorsRegistry registry) {
62-
this.configurers.addCorsMappings(registry);
61+
protected void addFormatters(FormatterRegistry registry) {
62+
this.configurers.addFormatters(registry);
6363
}
6464

6565
@Override
66-
public void configurePathMatching(PathMatchConfigurer configurer) {
67-
this.configurers.configurePathMatching(configurer);
66+
protected Validator getValidator() {
67+
Validator validator = this.configurers.getValidator();
68+
return (validator != null ? validator : super.getValidator());
6869
}
6970

7071
@Override
71-
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
72-
this.configurers.addResourceHandlers(registry);
72+
protected MessageCodesResolver getMessageCodesResolver() {
73+
MessageCodesResolver messageCodesResolver = this.configurers.getMessageCodesResolver();
74+
return (messageCodesResolver != null ? messageCodesResolver : super.getMessageCodesResolver());
7375
}
7476

7577
@Override
76-
protected void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
77-
this.configurers.configureArgumentResolvers(configurer);
78+
protected void addCorsMappings(CorsRegistry registry) {
79+
this.configurers.addCorsMappings(registry);
7880
}
7981

8082
@Override
81-
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
82-
this.configurers.configureHttpMessageCodecs(configurer);
83+
protected void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
84+
this.configurers.configureBlockingExecution(configurer);
8385
}
8486

8587
@Override
86-
protected void addFormatters(FormatterRegistry registry) {
87-
this.configurers.addFormatters(registry);
88+
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
89+
this.configurers.configureContentTypeResolver(builder);
8890
}
8991

9092
@Override
91-
protected Validator getValidator() {
92-
Validator validator = this.configurers.getValidator();
93-
return (validator != null ? validator : super.getValidator());
93+
public void configurePathMatching(PathMatchConfigurer configurer) {
94+
this.configurers.configurePathMatching(configurer);
9495
}
9596

9697
@Override
97-
protected MessageCodesResolver getMessageCodesResolver() {
98-
MessageCodesResolver messageCodesResolver = this.configurers.getMessageCodesResolver();
99-
return (messageCodesResolver != null ? messageCodesResolver : super.getMessageCodesResolver());
98+
protected void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
99+
this.configurers.configureArgumentResolvers(configurer);
100100
}
101101

102102
@Override
103-
protected WebSocketService getWebSocketService() {
104-
WebSocketService service = this.configurers.getWebSocketService();
105-
return (service != null ? service : super.getWebSocketService());
103+
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
104+
this.configurers.addResourceHandlers(registry);
106105
}
107106

108107
@Override
@@ -111,7 +110,9 @@ protected void configureViewResolvers(ViewResolverRegistry registry) {
111110
}
112111

113112
@Override
114-
protected void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
115-
this.configurers.configureBlockingExecution(configurer);
113+
protected WebSocketService getWebSocketService() {
114+
WebSocketService service = this.configurers.getWebSocketService();
115+
return (service != null ? service : super.getWebSocketService());
116116
}
117+
117118
}

spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurer.java

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,6 @@
4545
*/
4646
public interface WebFluxConfigurer {
4747

48-
/**
49-
* Configure how the content type requested for the response is resolved
50-
* when handling requests with annotated controllers.
51-
* @param builder for configuring the resolvers to use
52-
*/
53-
default void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
54-
}
55-
56-
/**
57-
* Configure "global" cross-origin request processing. The configured CORS
58-
* mappings apply to annotated controllers, functional endpoints, and static
59-
* resources.
60-
* <p>Annotated controllers can further declare more fine-grained config via
61-
* {@link org.springframework.web.bind.annotation.CrossOrigin @CrossOrigin}.
62-
* In such cases "global" CORS configuration declared here is
63-
* {@link org.springframework.web.cors.CorsConfiguration#combine(CorsConfiguration) combined}
64-
* with local CORS configuration defined on a controller method.
65-
* @see CorsRegistry
66-
* @see CorsConfiguration#combine(CorsConfiguration)
67-
*/
68-
default void addCorsMappings(CorsRegistry registry) {
69-
}
70-
71-
/**
72-
* Configure path matching options.
73-
* <p>The configured path matching options will be used for mapping to
74-
* annotated controllers and also
75-
* {@link #addResourceHandlers(ResourceHandlerRegistry) static resources}.
76-
* @param configurer the {@link PathMatchConfigurer} instance
77-
*/
78-
default void configurePathMatching(PathMatchConfigurer configurer) {
79-
}
80-
81-
/**
82-
* Add resource handlers for serving static resources.
83-
* @see ResourceHandlerRegistry
84-
*/
85-
default void addResourceHandlers(ResourceHandlerRegistry registry) {
86-
}
87-
88-
/**
89-
* Configure resolvers for custom {@code @RequestMapping} method arguments.
90-
* @param configurer to configurer to use
91-
*/
92-
default void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
93-
}
94-
9548
/**
9649
* Configure the HTTP message readers and writers for reading from the
9750
* request body and for writing to the response body in annotated controllers
@@ -134,15 +87,50 @@ default MessageCodesResolver getMessageCodesResolver() {
13487
}
13588

13689
/**
137-
* Provide the {@link WebSocketService} to create
138-
* {@link org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter}
139-
* with. This can be used to configure server-specific properties through the
140-
* {@link org.springframework.web.reactive.socket.server.RequestUpgradeStrategy}.
141-
* @since 5.3
90+
* Configure "global" cross-origin request processing. The configured CORS
91+
* mappings apply to annotated controllers, functional endpoints, and static
92+
* resources.
93+
* <p>Annotated controllers can further declare more fine-grained config via
94+
* {@link org.springframework.web.bind.annotation.CrossOrigin @CrossOrigin}.
95+
* In such cases "global" CORS configuration declared here is
96+
* {@link org.springframework.web.cors.CorsConfiguration#combine(CorsConfiguration) combined}
97+
* with local CORS configuration defined on a controller method.
98+
* @see CorsRegistry
99+
* @see CorsConfiguration#combine(CorsConfiguration)
142100
*/
143-
@Nullable
144-
default WebSocketService getWebSocketService() {
145-
return null;
101+
default void addCorsMappings(CorsRegistry registry) {
102+
}
103+
104+
/**
105+
* Configure settings related to blocking execution in WebFlux.
106+
* @since 6.1
107+
*/
108+
default void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
109+
}
110+
111+
/**
112+
* Configure how the content type requested for the response is resolved
113+
* when handling requests with annotated controllers.
114+
* @param builder for configuring the resolvers to use
115+
*/
116+
default void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
117+
}
118+
119+
/**
120+
* Configure path matching options.
121+
* <p>The configured path matching options will be used for mapping to
122+
* annotated controllers and also
123+
* {@link #addResourceHandlers(ResourceHandlerRegistry) static resources}.
124+
* @param configurer the {@link PathMatchConfigurer} instance
125+
*/
126+
default void configurePathMatching(PathMatchConfigurer configurer) {
127+
}
128+
129+
/**
130+
* Configure resolvers for custom {@code @RequestMapping} method arguments.
131+
* @param configurer to configurer to use
132+
*/
133+
default void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
146134
}
147135

148136
/**
@@ -156,10 +144,22 @@ default void configureViewResolvers(ViewResolverRegistry registry) {
156144
}
157145

158146
/**
159-
* Configure settings related to blocking execution in WebFlux.
160-
* @since 6.1
147+
* Add resource handlers for serving static resources.
148+
* @see ResourceHandlerRegistry
161149
*/
162-
default void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
150+
default void addResourceHandlers(ResourceHandlerRegistry registry) {
151+
}
152+
153+
/**
154+
* Provide the {@link WebSocketService} to create
155+
* {@link org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter}
156+
* with. This can be used to configure server-specific properties through the
157+
* {@link org.springframework.web.reactive.socket.server.RequestUpgradeStrategy}.
158+
* @since 5.3
159+
*/
160+
@Nullable
161+
default WebSocketService getWebSocketService() {
162+
return null;
163163
}
164164

165165
}

spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurerComposite.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,64 +51,64 @@ public void addWebFluxConfigurers(List<WebFluxConfigurer> configurers) {
5151

5252

5353
@Override
54-
public void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
55-
this.delegates.forEach(delegate -> delegate.configureContentTypeResolver(builder));
54+
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
55+
this.delegates.forEach(delegate -> delegate.configureHttpMessageCodecs(configurer));
5656
}
5757

5858
@Override
59-
public void addCorsMappings(CorsRegistry registry) {
60-
this.delegates.forEach(delegate -> delegate.addCorsMappings(registry));
59+
public void addFormatters(FormatterRegistry registry) {
60+
this.delegates.forEach(delegate -> delegate.addFormatters(registry));
6161
}
6262

6363
@Override
64-
public void configurePathMatching(PathMatchConfigurer configurer) {
65-
this.delegates.forEach(delegate -> delegate.configurePathMatching(configurer));
64+
public Validator getValidator() {
65+
return createSingleBean(WebFluxConfigurer::getValidator, Validator.class);
6666
}
6767

6868
@Override
69-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
70-
this.delegates.forEach(delegate -> delegate.addResourceHandlers(registry));
69+
public MessageCodesResolver getMessageCodesResolver() {
70+
return createSingleBean(WebFluxConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
7171
}
7272

73-
@Nullable
7473
@Override
75-
public WebSocketService getWebSocketService() {
76-
return createSingleBean(WebFluxConfigurer::getWebSocketService, WebSocketService.class);
74+
public void addCorsMappings(CorsRegistry registry) {
75+
this.delegates.forEach(delegate -> delegate.addCorsMappings(registry));
7776
}
7877

7978
@Override
80-
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
81-
this.delegates.forEach(delegate -> delegate.configureArgumentResolvers(configurer));
79+
public void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
80+
this.delegates.forEach(delegate -> delegate.configureBlockingExecution(configurer));
8281
}
8382

8483
@Override
85-
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
86-
this.delegates.forEach(delegate -> delegate.configureHttpMessageCodecs(configurer));
84+
public void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
85+
this.delegates.forEach(delegate -> delegate.configureContentTypeResolver(builder));
8786
}
8887

8988
@Override
90-
public void addFormatters(FormatterRegistry registry) {
91-
this.delegates.forEach(delegate -> delegate.addFormatters(registry));
89+
public void configurePathMatching(PathMatchConfigurer configurer) {
90+
this.delegates.forEach(delegate -> delegate.configurePathMatching(configurer));
9291
}
9392

9493
@Override
95-
public Validator getValidator() {
96-
return createSingleBean(WebFluxConfigurer::getValidator, Validator.class);
94+
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
95+
this.delegates.forEach(delegate -> delegate.configureArgumentResolvers(configurer));
9796
}
9897

9998
@Override
100-
public MessageCodesResolver getMessageCodesResolver() {
101-
return createSingleBean(WebFluxConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
99+
public void configureViewResolvers(ViewResolverRegistry registry) {
100+
this.delegates.forEach(delegate -> delegate.configureViewResolvers(registry));
102101
}
103102

104103
@Override
105-
public void configureViewResolvers(ViewResolverRegistry registry) {
106-
this.delegates.forEach(delegate -> delegate.configureViewResolvers(registry));
104+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
105+
this.delegates.forEach(delegate -> delegate.addResourceHandlers(registry));
107106
}
108107

108+
@Nullable
109109
@Override
110-
public void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
111-
this.delegates.forEach(delegate -> delegate.configureBlockingExecution(configurer));
110+
public WebSocketService getWebSocketService() {
111+
return createSingleBean(WebFluxConfigurer::getWebSocketService, WebSocketService.class);
112112
}
113113

114114
@Nullable

0 commit comments

Comments
 (0)