-
Notifications
You must be signed in to change notification settings - Fork 40.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestRestTemplate PUT and POST requests not working when adding Netty as a dependency #7240
Comments
@eseidinger Can you please provide a small sample that reproduces the problem? |
@wilkinsona I created a little project on GitHub to isolate the problem. It's just one
You can see that by removing the comments in the build.gradle file from the line That's why I added the Netty dependency to my project in the first place.
So it looks like the error is caused by |
Thanks for the sample. It appears to be a problem with Spring Framework's |
Here's a couple of stripped down tests that don't use Spring Boot at all and illustrate the problem:
@eseidinger Unfortunately, I think this needs to be addressed by the Spring Framework team (or perhaps the Netty team). Can you please open an SPR Jira ticket (https://jira.spring.io/browse/SPR) in the first instance? |
I wrote this before I saw that you closed this issue but maybe you find it interesting anyway... @wilkinsona Thanks for your feedback. The JavaDoc for This works just fine without the dependency on Netty. But when I add the dependencies BOTH tests fail. If the problem was the I updated the sample accordingly. Maybe you want to have a look. |
Each method on the builder returns a new instance so the code that you had was returning the builder in its default form. This meant that both tests were now be using the Netty client. Your method that configures the builder should look like this: @Bean
public RestTemplateBuilder restTemplateBuilder() {
return new RestTemplateBuilder().requestFactory(SimpleClientHttpRequestFactory.class);
} |
@wilkinsona Thanks for your help. The workaround with the |
When adding Netty as Dependency (
compile 'io.netty:netty-all:4.1.6.Final'
) to my Spring Boot project my tests usingTestRestTemplate.postForObject(...)
andTestRestTemplate.put(...)
aren't working anymore. I get the following error:Using
TestRestTemplate.getForObject(...)
works fine.RestTemplate.postForObject(...)
andRestTemplate.put(...)
are also working fine so I use those as a workaround for the moment.I am using Spring Boot version 1.4.1.RELEASE
The text was updated successfully, but these errors were encountered: