Needs feature to specify charset in StringHttpMessageConverter
Hi, there. I'm using Spring Android 1.0.0RC1 and it works great. thanks.
And I suggests some improvement in StringHttpMessageConverter.
In default constructor of StringHttpMessageConverter, it searches availableCharsets using Charset.availableCharsets().
Code:
public StringHttpMessageConverter() {
super(new MediaType("text", "plain", DEFAULT_CHARSET), MediaType.ALL);
this.availableCharsets = new ArrayList<Charset>(Charset.availableCharsets().values());
}
And in my profiling result, this method spent 50% of time in creating RestTemplate instance. So I planned to make my own StringHttpMessageConverter (I just use UTF-8 in all requests), but RestTemplate create StringHttpMessageConverter in its constructor.
Code:
public RestTemplate() {
this.messageConverters.add(new ByteArrayHttpMessageConverter());
this.messageConverters.add(new StringHttpMessageConverter());
this.messageConverters.add(new ResourceHttpMessageConverter());
More over, Charset.availableCharsets() uses native icu4j method and it sometimes fail. So if I could specify charset in somewhere, or just not using Charset.availableCharsets(), I can improve performance and some problems that icu4j makes. Thanks.