Add RestTemplate constructor with custom converters
Prior to this commit, RestTemplate's constructors were all initializing
default HTTPMessageConverters. Its API provides a way to replace
those converters with custom ones, but default converters are already
defined and initialized at that point, which can be an issue in some
cases (performance, classpath...).
This commits adds a new constructor for RestTemplate with a list
of message converters as argument. With this new constructor,
default message converters are never initialized.
Issue: SPR-11351
(cherry picked from commit 425e5a0)
This commit is contained in:
committed by
Juergen Hoeller
parent
fe4b57c199
commit
1cb9b9cf52
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -68,9 +68,9 @@ public class RestTemplateTests {
|
||||
response = mock(ClientHttpResponse.class);
|
||||
errorHandler = mock(ResponseErrorHandler.class);
|
||||
converter = mock(HttpMessageConverter.class);
|
||||
template = new RestTemplate(requestFactory);
|
||||
template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
template.setRequestFactory(requestFactory);
|
||||
template.setErrorHandler(errorHandler);
|
||||
template.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user