diff --git a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java index dc15005483..b8c6a1943d 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -43,7 +43,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter availableCharsets; + private volatile List availableCharsets; private boolean writeAcceptCharset = true; @@ -62,7 +62,6 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter(Charset.availableCharsets().values()); } @@ -115,6 +114,10 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter getAcceptedCharsets() { + if (this.availableCharsets == null) { + this.availableCharsets = new ArrayList( + Charset.availableCharsets().values()); + } return this.availableCharsets; }