Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
162b9e84
Commit
162b9e84
authored
Jul 27, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
618e6d6b
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
87 additions
and
30 deletions
+87
-30
HttpEncodingAutoConfiguration.java
...boot/autoconfigure/web/HttpEncodingAutoConfiguration.java
+3
-1
HttpEncodingAutoConfigurationTests.java
...autoconfigure/web/HttpEncodingAutoConfigurationTests.java
+10
-8
AutoConfigureJsonTesters.java
...oot/test/autoconfigure/json/AutoConfigureJsonTesters.java
+1
-0
RelaxedDataBinder.java
...java/org/springframework/boot/bind/RelaxedDataBinder.java
+0
-1
RelaxedNames.java
...main/java/org/springframework/boot/bind/RelaxedNames.java
+23
-1
YamlJavaBeanPropertyConstructor.java
...gframework/boot/bind/YamlJavaBeanPropertyConstructor.java
+1
-2
AbstractConfigurableEmbeddedServletContainer.java
...mbedded/AbstractConfigurableEmbeddedServletContainer.java
+1
-0
JettyEmbeddedServletContainerFactory.java
.../embedded/jetty/JettyEmbeddedServletContainerFactory.java
+11
-4
TomcatEmbeddedServletContainerFactory.java
...mbedded/tomcat/TomcatEmbeddedServletContainerFactory.java
+24
-9
UndertowEmbeddedServletContainerFactory.java
...ded/undertow/UndertowEmbeddedServletContainerFactory.java
+11
-4
JettyEmbeddedServletContainerFactoryTests.java
...dded/jetty/JettyEmbeddedServletContainerFactoryTests.java
+1
-0
UndertowEmbeddedServletContainerFactoryTests.java
...ndertow/UndertowEmbeddedServletContainerFactoryTests.java
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpEncodingAutoConfiguration.java
View file @
162b9e84
...
...
@@ -67,7 +67,8 @@ public class HttpEncodingAutoConfiguration {
return
new
LocaleCharsetMappingsCustomizer
(
this
.
properties
);
}
private
static
class
LocaleCharsetMappingsCustomizer
implements
EmbeddedServletContainerCustomizer
,
Ordered
{
private
static
class
LocaleCharsetMappingsCustomizer
implements
EmbeddedServletContainerCustomizer
,
Ordered
{
private
final
HttpEncodingProperties
properties
;
...
...
@@ -86,6 +87,7 @@ public class HttpEncodingAutoConfiguration {
public
int
getOrder
()
{
return
0
;
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/HttpEncodingAutoConfigurationTests.java
View file @
162b9e84
...
...
@@ -145,8 +145,8 @@ public class HttpEncodingAutoConfigurationTests {
@Test
public
void
noLocaleCharsetMapping
()
{
load
(
EmptyConfiguration
.
class
);
Map
<
String
,
EmbeddedServletContainerCustomizer
>
beans
=
this
.
context
.
getBeansOfType
(
EmbeddedServletContainerCustomizer
.
class
);
Map
<
String
,
EmbeddedServletContainerCustomizer
>
beans
=
this
.
context
.
getBeansOfType
(
EmbeddedServletContainerCustomizer
.
class
);
assertThat
(
beans
.
size
()).
isEqualTo
(
1
);
assertThat
(
this
.
context
.
getBean
(
MockEmbeddedServletContainerFactory
.
class
)
.
getLocaleCharsetMappings
().
size
()).
isEqualTo
(
0
);
...
...
@@ -156,15 +156,17 @@ public class HttpEncodingAutoConfigurationTests {
public
void
customLocaleCharsetMappings
()
{
load
(
EmptyConfiguration
.
class
,
"spring.http.encoding.mapping.en:UTF-8"
,
"spring.http.encoding.mapping.fr_FR:UTF-8"
);
Map
<
String
,
EmbeddedServletContainerCustomizer
>
beans
=
this
.
context
.
getBeansOfType
(
EmbeddedServletContainerCustomizer
.
class
);
Map
<
String
,
EmbeddedServletContainerCustomizer
>
beans
=
this
.
context
.
getBeansOfType
(
EmbeddedServletContainerCustomizer
.
class
);
assertThat
(
beans
.
size
()).
isEqualTo
(
1
);
assertThat
(
this
.
context
.
getBean
(
MockEmbeddedServletContainerFactory
.
class
)
.
getLocaleCharsetMappings
().
size
()).
isEqualTo
(
2
);
assertThat
(
this
.
context
.
getBean
(
MockEmbeddedServletContainerFactory
.
class
)
.
getLocaleCharsetMappings
().
get
(
Locale
.
ENGLISH
)).
isEqualTo
(
Charset
.
forName
(
"UTF-8"
));
.
getLocaleCharsetMappings
().
get
(
Locale
.
ENGLISH
))
.
isEqualTo
(
Charset
.
forName
(
"UTF-8"
));
assertThat
(
this
.
context
.
getBean
(
MockEmbeddedServletContainerFactory
.
class
)
.
getLocaleCharsetMappings
().
get
(
Locale
.
FRANCE
)).
isEqualTo
(
Charset
.
forName
(
"UTF-8"
));
.
getLocaleCharsetMappings
().
get
(
Locale
.
FRANCE
))
.
isEqualTo
(
Charset
.
forName
(
"UTF-8"
));
}
private
void
assertCharacterEncodingFilter
(
CharacterEncodingFilter
actual
,
...
...
@@ -233,10 +235,10 @@ public class HttpEncodingAutoConfigurationTests {
}
@Bean
public
EmbeddedServletContainerCustomizerBeanPostProcessor
embeddedServletContainerCustomizerBeanPostProcessor
()
{
public
EmbeddedServletContainerCustomizerBeanPostProcessor
embeddedServletContainerCustomizerBeanPostProcessor
()
{
return
new
EmbeddedServletContainerCustomizerBeanPostProcessor
();
}
}
}
spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/AutoConfigureJsonTesters.java
View file @
162b9e84
...
...
@@ -33,6 +33,7 @@ import org.springframework.boot.test.json.JacksonTester;
* auto-configuration of JSON testers.
*
* @author Phillip Webb
* @since 1.4.0
*/
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
...
...
spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java
View file @
162b9e84
...
...
@@ -276,7 +276,6 @@ public class RelaxedDataBinder extends DataBinder {
if
(
path
.
name
(++
index
)
==
null
)
{
return
path
.
toString
();
}
String
name
=
path
.
prefix
(
index
);
TypeDescriptor
descriptor
=
wrapper
.
getPropertyTypeDescriptor
(
name
);
if
(
descriptor
==
null
||
descriptor
.
isMap
())
{
...
...
spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java
View file @
162b9e84
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -79,24 +79,30 @@ public final class RelaxedNames implements Iterable<String> {
enum
Variation
{
NONE
{
@Override
public
String
apply
(
String
value
)
{
return
value
;
}
},
LOWERCASE
{
@Override
public
String
apply
(
String
value
)
{
return
value
.
toLowerCase
();
}
},
UPPERCASE
{
@Override
public
String
apply
(
String
value
)
{
return
value
.
toUpperCase
();
}
};
public
abstract
String
apply
(
String
value
);
...
...
@@ -109,34 +115,43 @@ public final class RelaxedNames implements Iterable<String> {
enum
Manipulation
{
NONE
{
@Override
public
String
apply
(
String
value
)
{
return
value
;
}
},
HYPHEN_TO_UNDERSCORE
{
@Override
public
String
apply
(
String
value
)
{
return
value
.
replace
(
"-"
,
"_"
);
}
},
UNDERSCORE_TO_PERIOD
{
@Override
public
String
apply
(
String
value
)
{
return
value
.
replace
(
"_"
,
"."
);
}
},
PERIOD_TO_UNDERSCORE
{
@Override
public
String
apply
(
String
value
)
{
return
value
.
replace
(
"."
,
"_"
);
}
},
CAMELCASE_TO_UNDERSCORE
{
@Override
public
String
apply
(
String
value
)
{
Matcher
matcher
=
CAMEL_CASE_PATTERN
.
matcher
(
value
);
...
...
@@ -148,9 +163,11 @@ public final class RelaxedNames implements Iterable<String> {
matcher
.
appendTail
(
result
);
return
result
.
toString
();
}
},
CAMELCASE_TO_HYPHEN
{
@Override
public
String
apply
(
String
value
)
{
Matcher
matcher
=
CAMEL_CASE_PATTERN
.
matcher
(
value
);
...
...
@@ -162,20 +179,25 @@ public final class RelaxedNames implements Iterable<String> {
matcher
.
appendTail
(
result
);
return
result
.
toString
();
}
},
SEPARATED_TO_CAMELCASE
{
@Override
public
String
apply
(
String
value
)
{
return
separatedToCamelCase
(
value
,
false
);
}
},
CASE_INSENSITIVE_SEPARATED_TO_CAMELCASE
{
@Override
public
String
apply
(
String
value
)
{
return
separatedToCamelCase
(
value
,
true
);
}
};
public
abstract
String
apply
(
String
value
);
...
...
spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java
View file @
162b9e84
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -69,7 +69,6 @@ public class YamlJavaBeanPropertyConstructor extends Constructor {
typeMap
=
new
HashMap
<
String
,
Property
>();
this
.
properties
.
put
(
type
,
typeMap
);
}
try
{
typeMap
.
put
(
alias
,
this
.
propertyUtils
.
getProperty
(
type
,
name
));
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java
View file @
162b9e84
...
...
@@ -342,6 +342,7 @@ public abstract class AbstractConfigurableEmbeddedServletContainer
return
this
.
localeCharsetMappings
;
}
@Override
public
void
setLocaleCharsetMappings
(
Map
<
Locale
,
Charset
>
localeCharsetMappings
)
{
Assert
.
notNull
(
localeCharsetMappings
,
"localeCharsetMappings must not be null"
);
this
.
localeCharsetMappings
=
localeCharsetMappings
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java
View file @
162b9e84
...
...
@@ -20,12 +20,14 @@ import java.io.File;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.servlet.ServletException
;
...
...
@@ -355,10 +357,7 @@ public class JettyEmbeddedServletContainerFactory
addJspServlet
(
context
);
context
.
addBean
(
new
JasperInitializer
(
context
),
true
);
}
for
(
Locale
locale
:
getLocaleCharsetMappings
().
keySet
())
{
context
.
addLocaleEncoding
(
locale
.
toString
(),
getLocaleCharsetMappings
().
get
(
locale
).
toString
());
}
addLocaleMappings
(
context
);
ServletContextInitializer
[]
initializersToUse
=
mergeInitializers
(
initializers
);
Configuration
[]
configurations
=
getWebAppContextConfigurations
(
context
,
initializersToUse
);
...
...
@@ -367,6 +366,14 @@ public class JettyEmbeddedServletContainerFactory
postProcessWebAppContext
(
context
);
}
private
void
addLocaleMappings
(
WebAppContext
context
)
{
for
(
Map
.
Entry
<
Locale
,
Charset
>
entry
:
getLocaleCharsetMappings
().
entrySet
())
{
Locale
locale
=
entry
.
getKey
();
Charset
charset
=
entry
.
getValue
();
context
.
addLocaleEncoding
(
locale
.
toString
(),
charset
.
toString
());
}
}
private
void
configureSession
(
WebAppContext
context
)
{
SessionManager
sessionManager
=
context
.
getSessionHandler
().
getSessionManager
();
int
sessionTimeout
=
(
getSessionTimeout
()
>
0
?
getSessionTimeout
()
:
-
1
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java
View file @
162b9e84
...
...
@@ -27,6 +27,7 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -194,15 +195,8 @@ public class TomcatEmbeddedServletContainerFactory
context
.
setParentClassLoader
(
this
.
resourceLoader
!=
null
?
this
.
resourceLoader
.
getClassLoader
()
:
ClassUtils
.
getDefaultClassLoader
());
// override defaults, see org.apache.catalina.util.CharsetMapperDefault.properties
context
.
addLocaleEncodingMappingParameter
(
Locale
.
ENGLISH
.
toString
(),
DEFAULT_CHARSET
.
displayName
());
context
.
addLocaleEncodingMappingParameter
(
Locale
.
FRENCH
.
toString
(),
DEFAULT_CHARSET
.
displayName
());
for
(
Locale
locale
:
getLocaleCharsetMappings
().
keySet
())
{
context
.
addLocaleEncodingMappingParameter
(
locale
.
toString
(),
getLocaleCharsetMappings
().
get
(
locale
).
toString
());
}
resetDefaultLocaleMapping
(
context
);
addLocaleMappings
(
context
);
try
{
context
.
setUseRelativeRedirects
(
false
);
}
...
...
@@ -228,6 +222,27 @@ public class TomcatEmbeddedServletContainerFactory
postProcessContext
(
context
);
}
/**
* Override Tomcat's default locale mappings to align with other containers. See
* {@code org.apache.catalina.util.CharsetMapperDefault.properties}.
* @param context the context to reset
*/
private
void
resetDefaultLocaleMapping
(
TomcatEmbeddedContext
context
)
{
context
.
addLocaleEncodingMappingParameter
(
Locale
.
ENGLISH
.
toString
(),
DEFAULT_CHARSET
.
displayName
());
context
.
addLocaleEncodingMappingParameter
(
Locale
.
FRENCH
.
toString
(),
DEFAULT_CHARSET
.
displayName
());
}
private
void
addLocaleMappings
(
TomcatEmbeddedContext
context
)
{
for
(
Map
.
Entry
<
Locale
,
Charset
>
entry
:
getLocaleCharsetMappings
().
entrySet
())
{
Locale
locale
=
entry
.
getKey
();
Charset
charset
=
entry
.
getValue
();
context
.
addLocaleEncodingMappingParameter
(
locale
.
toString
(),
charset
.
toString
());
}
}
private
void
addDefaultServlet
(
Context
context
)
{
Wrapper
defaultServlet
=
context
.
createWrapper
();
defaultServlet
.
setName
(
"default"
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java
View file @
162b9e84
...
...
@@ -19,6 +19,7 @@ package org.springframework.boot.context.embedded.undertow;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.security.KeyManagementException
;
import
java.security.KeyStore
;
import
java.security.NoSuchAlgorithmException
;
...
...
@@ -28,6 +29,7 @@ import java.util.Collection;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.net.ssl.KeyManager
;
...
...
@@ -383,10 +385,7 @@ public class UndertowEmbeddedServletContainerFactory
File
dir
=
getValidSessionStoreDir
();
deployment
.
setSessionPersistenceManager
(
new
FileSessionPersistence
(
dir
));
}
for
(
Locale
locale
:
getLocaleCharsetMappings
().
keySet
())
{
deployment
.
addLocaleCharsetMapping
(
locale
.
toString
(),
getLocaleCharsetMappings
().
get
(
locale
).
toString
());
}
addLocaleMappings
(
deployment
);
DeploymentManager
manager
=
Servlets
.
newContainer
().
addDeployment
(
deployment
);
manager
.
deploy
();
SessionManager
sessionManager
=
manager
.
getDeployment
().
getSessionManager
();
...
...
@@ -435,6 +434,14 @@ public class UndertowEmbeddedServletContainerFactory
OptionMap
.
builder
().
set
(
Options
.
THREAD_DAEMON
,
true
).
getMap
());
}
private
void
addLocaleMappings
(
DeploymentInfo
deployment
)
{
for
(
Map
.
Entry
<
Locale
,
Charset
>
entry
:
getLocaleCharsetMappings
().
entrySet
())
{
Locale
locale
=
entry
.
getKey
();
Charset
charset
=
entry
.
getValue
();
deployment
.
addLocaleCharsetMapping
(
locale
.
toString
(),
charset
.
toString
());
}
}
private
void
registerServletContainerInitializerToDriveServletContextInitializers
(
DeploymentInfo
deployment
,
ServletContextInitializer
...
initializers
)
{
ServletContextInitializer
[]
mergedInitializers
=
mergeInitializers
(
initializers
);
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java
View file @
162b9e84
...
...
@@ -335,4 +335,5 @@ public class JettyEmbeddedServletContainerFactoryTests
String
charsetName
=
context
.
getLocaleEncoding
(
locale
);
return
(
charsetName
!=
null
)
?
Charset
.
forName
(
charsetName
)
:
null
;
}
}
spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java
View file @
162b9e84
...
...
@@ -277,4 +277,5 @@ public class UndertowEmbeddedServletContainerFactoryTests
String
charsetName
=
info
.
getLocaleCharsetMapping
().
get
(
locale
.
toString
());
return
(
charsetName
!=
null
)
?
Charset
.
forName
(
charsetName
)
:
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment