Skip to content

Commit 711391c

Browse files
committed
Move spring.http.* config properties namespace
Closes gh-18827
1 parent 7f6b01c commit 711391c

File tree

15 files changed

+300
-205
lines changed

15 files changed

+300
-205
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/codec/CodecProperties.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -28,13 +28,26 @@
2828
@ConfigurationProperties(prefix = "spring.codec")
2929
public class CodecProperties {
3030

31+
/**
32+
* Whether to log form data at DEBUG level, and headers at TRACE level.
33+
*/
34+
private boolean logRequestDetails;
35+
3136
/**
3237
* Limit on the number of bytes that can be buffered whenever the input stream needs
3338
* to be aggregated. By default this is not set, in which case individual codec
3439
* defaults apply. Most codecs are limited to 256K by default.
3540
*/
3641
private DataSize maxInMemorySize;
3742

43+
public boolean isLogRequestDetails() {
44+
return this.logRequestDetails;
45+
}
46+
47+
public void setLogRequestDetails(boolean logRequestDetails) {
48+
this.logRequestDetails = logRequestDetails;
49+
}
50+
3851
public DataSize getMaxInMemorySize() {
3952
return this.maxInMemorySize;
4053
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -30,6 +30,7 @@
3030
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration.NotReactiveWebApplicationCondition;
3131
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
3232
import org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration;
33+
import org.springframework.boot.autoconfigure.web.ServerProperties;
3334
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3435
import org.springframework.context.annotation.Bean;
3536
import org.springframework.context.annotation.Conditional;
@@ -60,7 +61,7 @@
6061
JsonbHttpMessageConvertersConfiguration.class })
6162
public class HttpMessageConvertersAutoConfiguration {
6263

63-
static final String PREFERRED_MAPPER_PROPERTY = "spring.http.converters.preferred-json-mapper";
64+
static final String PREFERRED_MAPPER_PROPERTY = "spring.mvc.converters.preferred-json-mapper";
6465

6566
@Bean
6667
@ConditionalOnMissingBean
@@ -70,14 +71,14 @@ public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConvert
7071

7172
@Configuration(proxyBeanMethods = false)
7273
@ConditionalOnClass(StringHttpMessageConverter.class)
73-
@EnableConfigurationProperties(HttpProperties.class)
74+
@EnableConfigurationProperties(ServerProperties.class)
7475
protected static class StringHttpMessageConverterConfiguration {
7576

7677
@Bean
7778
@ConditionalOnMissingBean
78-
public StringHttpMessageConverter stringHttpMessageConverter(HttpProperties httpProperties) {
79+
public StringHttpMessageConverter stringHttpMessageConverter(ServerProperties serverProperties) {
7980
StringHttpMessageConverter converter = new StringHttpMessageConverter(
80-
httpProperties.getEncoding().getCharset());
81+
serverProperties.getServlet().getEncoding().getCharset());
8182
converter.setWriteAcceptCharset(false);
8283
return converter;
8384
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpProperties.java

Lines changed: 0 additions & 154 deletions
This file was deleted.

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/codec/CodecsAutoConfiguration.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -23,7 +23,6 @@
2323
import org.springframework.boot.autoconfigure.codec.CodecProperties;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
26-
import org.springframework.boot.autoconfigure.http.HttpProperties;
2726
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
2827
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2928
import org.springframework.boot.context.properties.PropertyMapper;
@@ -49,7 +48,7 @@
4948
@Configuration(proxyBeanMethods = false)
5049
@ConditionalOnClass({ CodecConfigurer.class, WebClient.class })
5150
@AutoConfigureAfter(JacksonAutoConfiguration.class)
52-
@EnableConfigurationProperties({ HttpProperties.class, CodecProperties.class })
51+
@EnableConfigurationProperties(CodecProperties.class)
5352
public class CodecsAutoConfiguration {
5453

5554
private static final MimeType[] EMPTY_MIME_TYPES = {};
@@ -76,11 +75,11 @@ static class DefaultCodecsConfiguration {
7675

7776
@Bean
7877
@Order(0)
79-
CodecCustomizer defaultCodecCustomizer(HttpProperties httpProperties, CodecProperties codecProperties) {
78+
CodecCustomizer defaultCodecCustomizer(CodecProperties codecProperties) {
8079
return (configurer) -> {
8180
PropertyMapper map = PropertyMapper.get();
8281
CodecConfigurer.DefaultCodecs defaultCodecs = configurer.defaultCodecs();
83-
defaultCodecs.enableLoggingRequestDetails(httpProperties.isLogRequestDetails());
82+
defaultCodecs.enableLoggingRequestDetails(codecProperties.isLogRequestDetails());
8483
map.from(codecProperties.getMaxInMemorySize()).whenNonNull().asInt(DataSize::toBytes)
8584
.to(defaultCodecs::maxInMemorySize);
8685
};

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.boot.web.server.Compression;
3838
import org.springframework.boot.web.server.Http2;
3939
import org.springframework.boot.web.server.Ssl;
40+
import org.springframework.boot.web.servlet.server.Encoding;
4041
import org.springframework.boot.web.servlet.server.Jsp;
4142
import org.springframework.boot.web.servlet.server.Session;
4243
import org.springframework.util.StringUtils;
@@ -246,6 +247,9 @@ public static class Servlet {
246247
*/
247248
private String applicationDisplayName = "application";
248249

250+
@NestedConfigurationProperty
251+
private final Encoding encoding = new Encoding();
252+
249253
@NestedConfigurationProperty
250254
private final Jsp jsp = new Jsp();
251255

@@ -280,6 +284,10 @@ public Map<String, String> getContextParameters() {
280284
return this.contextParameters;
281285
}
282286

287+
public Encoding getEncoding() {
288+
return this.encoding;
289+
}
290+
283291
public Jsp getJsp() {
284292
return this.jsp;
285293
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -36,7 +36,6 @@
3636
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
3737
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
3838
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
39-
import org.springframework.boot.autoconfigure.http.HttpProperties;
4039
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4140
import org.springframework.boot.web.servlet.ServletRegistrationBean;
4241
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@@ -83,17 +82,17 @@ public class DispatcherServletAutoConfiguration {
8382
@Configuration(proxyBeanMethods = false)
8483
@Conditional(DefaultDispatcherServletCondition.class)
8584
@ConditionalOnClass(ServletRegistration.class)
86-
@EnableConfigurationProperties({ HttpProperties.class, WebMvcProperties.class })
85+
@EnableConfigurationProperties(WebMvcProperties.class)
8786
protected static class DispatcherServletConfiguration {
8887

8988
@Bean(name = DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
90-
public DispatcherServlet dispatcherServlet(HttpProperties httpProperties, WebMvcProperties webMvcProperties) {
89+
public DispatcherServlet dispatcherServlet(WebMvcProperties webMvcProperties) {
9190
DispatcherServlet dispatcherServlet = new DispatcherServlet();
9291
dispatcherServlet.setDispatchOptionsRequest(webMvcProperties.isDispatchOptionsRequest());
9392
dispatcherServlet.setDispatchTraceRequest(webMvcProperties.isDispatchTraceRequest());
9493
dispatcherServlet.setThrowExceptionIfNoHandlerFound(webMvcProperties.isThrowExceptionIfNoHandlerFound());
9594
dispatcherServlet.setPublishEvents(webMvcProperties.isPublishRequestHandledEvents());
96-
dispatcherServlet.setEnableLoggingRequestDetails(httpProperties.isLogRequestDetails());
95+
dispatcherServlet.setEnableLoggingRequestDetails(webMvcProperties.isLogRequestDetails());
9796
return dispatcherServlet;
9897
}
9998

0 commit comments

Comments
 (0)