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
2de0247c
Commit
2de0247c
authored
Nov 16, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11036 from dreis2211:standard-charsets-polishing
* pr/11036: Use StandardCharsets where possible
parents
bcab23e5
1e4941e2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
11 deletions
+21
-11
MessageSourceProperties.java
...k/boot/autoconfigure/context/MessageSourceProperties.java
+2
-1
HttpEncodingProperties.java
...ework/boot/autoconfigure/http/HttpEncodingProperties.java
+2
-1
MailProperties.java
...ringframework/boot/autoconfigure/mail/MailProperties.java
+2
-1
AbstractViewResolverProperties.java
...utoconfigure/template/AbstractViewResolverProperties.java
+2
-1
ThymeleafProperties.java
...ork/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
+2
-1
ViewResolverPropertiesTests.java
...t/autoconfigure/template/ViewResolverPropertiesTests.java
+4
-4
JavaCompilerFieldValuesParser.java
...ssor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
+4
-0
FieldValues.java
...ork/boot/configurationsample/fieldvalues/FieldValues.java
+3
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
context
;
package
org
.
springframework
.
boot
.
autoconfigure
.
context
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
/**
/**
* Configuration properties for Message Source.
* Configuration properties for Message Source.
...
@@ -37,7 +38,7 @@ public class MessageSourceProperties {
...
@@ -37,7 +38,7 @@ public class MessageSourceProperties {
/**
/**
* Message bundles encoding.
* Message bundles encoding.
*/
*/
private
Charset
encoding
=
Charset
.
forName
(
"UTF-8"
)
;
private
Charset
encoding
=
StandardCharsets
.
UTF_8
;
/**
/**
* Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles
* Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
http
;
package
org
.
springframework
.
boot
.
autoconfigure
.
http
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -32,7 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -32,7 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties
(
prefix
=
"spring.http.encoding"
)
@ConfigurationProperties
(
prefix
=
"spring.http.encoding"
)
public
class
HttpEncodingProperties
{
public
class
HttpEncodingProperties
{
public
static
final
Charset
DEFAULT_CHARSET
=
Charset
.
forName
(
"UTF-8"
)
;
public
static
final
Charset
DEFAULT_CHARSET
=
StandardCharsets
.
UTF_8
;
/**
/**
* Charset of HTTP requests and responses. Added to the "Content-Type" header if not
* Charset of HTTP requests and responses. Added to the "Content-Type" header if not
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
mail
;
package
org
.
springframework
.
boot
.
autoconfigure
.
mail
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -33,7 +34,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -33,7 +34,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties
(
prefix
=
"spring.mail"
)
@ConfigurationProperties
(
prefix
=
"spring.mail"
)
public
class
MailProperties
{
public
class
MailProperties
{
private
static
final
Charset
DEFAULT_CHARSET
=
Charset
.
forName
(
"UTF-8"
)
;
private
static
final
Charset
DEFAULT_CHARSET
=
StandardCharsets
.
UTF_8
;
/**
/**
* SMTP server host.
* SMTP server host.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
template
;
package
org
.
springframework
.
boot
.
autoconfigure
.
template
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,7 +37,7 @@ public abstract class AbstractViewResolverProperties {
...
@@ -36,7 +37,7 @@ public abstract class AbstractViewResolverProperties {
private
static
final
MimeType
DEFAULT_CONTENT_TYPE
=
MimeType
.
valueOf
(
"text/html"
);
private
static
final
MimeType
DEFAULT_CONTENT_TYPE
=
MimeType
.
valueOf
(
"text/html"
);
private
static
final
Charset
DEFAULT_CHARSET
=
Charset
.
forName
(
"UTF-8"
)
;
private
static
final
Charset
DEFAULT_CHARSET
=
StandardCharsets
.
UTF_8
;
/**
/**
* Enable MVC view resolution for this technology.
* Enable MVC view resolution for this technology.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
thymeleaf
;
package
org
.
springframework
.
boot
.
autoconfigure
.
thymeleaf
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
...
@@ -34,7 +35,7 @@ import org.springframework.util.MimeType;
...
@@ -34,7 +35,7 @@ import org.springframework.util.MimeType;
@ConfigurationProperties
(
prefix
=
"spring.thymeleaf"
)
@ConfigurationProperties
(
prefix
=
"spring.thymeleaf"
)
public
class
ThymeleafProperties
{
public
class
ThymeleafProperties
{
private
static
final
Charset
DEFAULT_ENCODING
=
Charset
.
forName
(
"UTF-8"
)
;
private
static
final
Charset
DEFAULT_ENCODING
=
StandardCharsets
.
UTF_8
;
public
static
final
String
DEFAULT_PREFIX
=
"classpath:/templates/"
;
public
static
final
String
DEFAULT_PREFIX
=
"classpath:/templates/"
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/ViewResolverPropertiesTests.java
View file @
2de0247c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
template
;
package
org
.
springframework
.
boot
.
autoconfigure
.
template
;
import
java.nio.charset.
Charset
;
import
java.nio.charset.
StandardCharsets
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -47,7 +47,7 @@ public class ViewResolverPropertiesTests {
...
@@ -47,7 +47,7 @@ public class ViewResolverPropertiesTests {
@Test
@Test
public
void
defaultContentTypeCustomCharset
()
{
public
void
defaultContentTypeCustomCharset
()
{
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
properties
.
setCharset
(
Charset
.
forName
(
"UTF-16"
)
);
properties
.
setCharset
(
StandardCharsets
.
UTF_16
);
assertThat
(
properties
.
getContentType
()).
hasToString
(
"text/html;charset=UTF-16"
);
assertThat
(
properties
.
getContentType
()).
hasToString
(
"text/html;charset=UTF-16"
);
}
}
...
@@ -55,7 +55,7 @@ public class ViewResolverPropertiesTests {
...
@@ -55,7 +55,7 @@ public class ViewResolverPropertiesTests {
public
void
customContentTypeCustomCharset
()
{
public
void
customContentTypeCustomCharset
()
{
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
properties
.
setContentType
(
MimeTypeUtils
.
parseMimeType
(
"text/plain"
));
properties
.
setContentType
(
MimeTypeUtils
.
parseMimeType
(
"text/plain"
));
properties
.
setCharset
(
Charset
.
forName
(
"UTF-16"
)
);
properties
.
setCharset
(
StandardCharsets
.
UTF_16
);
assertThat
(
properties
.
getContentType
()).
hasToString
(
"text/plain;charset=UTF-16"
);
assertThat
(
properties
.
getContentType
()).
hasToString
(
"text/plain;charset=UTF-16"
);
}
}
...
@@ -63,7 +63,7 @@ public class ViewResolverPropertiesTests {
...
@@ -63,7 +63,7 @@ public class ViewResolverPropertiesTests {
public
void
customContentTypeWithPropertyAndCustomCharset
()
{
public
void
customContentTypeWithPropertyAndCustomCharset
()
{
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
ViewResolverProperties
properties
=
new
ViewResolverProperties
();
properties
.
setContentType
(
MimeTypeUtils
.
parseMimeType
(
"text/plain;foo=bar"
));
properties
.
setContentType
(
MimeTypeUtils
.
parseMimeType
(
"text/plain;foo=bar"
));
properties
.
setCharset
(
Charset
.
forName
(
"UTF-16"
)
);
properties
.
setCharset
(
StandardCharsets
.
UTF_16
);
assertThat
(
properties
.
getContentType
())
assertThat
(
properties
.
getContentType
())
.
hasToString
(
"text/plain;charset=UTF-16;foo=bar"
);
.
hasToString
(
"text/plain;charset=UTF-16;foo=bar"
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java
View file @
2de0247c
...
@@ -94,6 +94,10 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
...
@@ -94,6 +94,10 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
Map
<
String
,
Object
>
values
=
new
HashMap
<>();
values
.
put
(
"Boolean.TRUE"
,
true
);
values
.
put
(
"Boolean.TRUE"
,
true
);
values
.
put
(
"Boolean.FALSE"
,
false
);
values
.
put
(
"Boolean.FALSE"
,
false
);
values
.
put
(
"StandardCharsets.ISO_8859_1"
,
"ISO-8859-1"
);
values
.
put
(
"StandardCharsets.UTF_8"
,
"UTF-8"
);
values
.
put
(
"StandardCharsets.UTF_16"
,
"UTF-16"
);
values
.
put
(
"StandardCharsets.US_ASCII"
,
"US-ASCII"
);
wellKnownStaticFinals
=
Collections
.
unmodifiableMap
(
values
);
wellKnownStaticFinals
=
Collections
.
unmodifiableMap
(
values
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/fieldvalues/FieldValues.java
View file @
2de0247c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
configurationsample
.
fieldvalues
;
package
org
.
springframework
.
boot
.
configurationsample
.
fieldvalues
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
org.springframework.boot.configurationsample.ConfigurationProperties
;
import
org.springframework.boot.configurationsample.ConfigurationProperties
;
import
org.springframework.util.MimeType
;
import
org.springframework.util.MimeType
;
...
@@ -41,7 +42,7 @@ public class FieldValues {
...
@@ -41,7 +42,7 @@ public class FieldValues {
private
static
final
Integer
INTEGER_OBJ_CONST
=
4
;
private
static
final
Integer
INTEGER_OBJ_CONST
=
4
;
private
static
final
Charset
DEFAULT_CHARSET
=
Charset
.
forName
(
"UTF-8"
)
;
private
static
final
Charset
DEFAULT_CHARSET
=
StandardCharsets
.
UTF_8
;
private
static
final
MimeType
DEFAULT_MIME_TYPE
=
MimeType
.
valueOf
(
"text/plain"
);
private
static
final
MimeType
DEFAULT_MIME_TYPE
=
MimeType
.
valueOf
(
"text/plain"
);
...
@@ -77,7 +78,7 @@ public class FieldValues {
...
@@ -77,7 +78,7 @@ public class FieldValues {
private
Integer
integerObjectConst
=
INTEGER_OBJ_CONST
;
private
Integer
integerObjectConst
=
INTEGER_OBJ_CONST
;
private
Charset
charset
=
Charset
.
forName
(
"US-ASCII"
)
;
private
Charset
charset
=
StandardCharsets
.
US_ASCII
;
private
Charset
charsetConst
=
DEFAULT_CHARSET
;
private
Charset
charsetConst
=
DEFAULT_CHARSET
;
...
...
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