Describe the bug Context: I'm using Spring Cloud 2020.0.1 and Spring Boot 2.4.3
Scenario:
Frontend app calls an API on Service 1
This API calls another bunch of APIs of Service 2 using Spring Cloud OpenFeign
Everythings works as expected, but if the frontend app (a simple SPA) changes page before the API returns, in the backend logs an error is thrown:
feign.codec.EncodeException: Couldn't serialize object createdAt: DESC\n\tat org.springframework.cloud.openfeign.support.SortJsonComponent$SortSerializer.lambda$serialize$0(SortJsonComponent.java:54)
java.lang.IllegalStateException: UT010019: Response already commited
Sample
My feign client declaration:
@FeignClient(
name = "${myclientName}",
fallbackFactory = MyClientFallbackFactory.class
)
public interface MyClient {
@GetMapping(path = "items/{id}", produces = APPLICATION_JSON_VALUE)
ItemDto getItem(@PathVariable UUID id, @RequestParam String myParam);
}
My feign configuration:
@Configuration
@EnableFeignClients
public class FeignConfig {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
@Bean
public Module pageJacksonModule() {
return new PageJacksonModule();
}
@Bean
public Module sortJacksonModule() {
return new SortJacksonModule();
}
}
This seems to happen only from when I upgraded to Spring Cloud 2020.0.1 from HOXTON.SR9
Comment From: giangur
Update: to workaround the issue I've changed the API of service 2 to reduce the number of API calls, but I'm still curious to understand why there's this problem.
Comment From: OlgaMaciaszek
@giangur please provide a minimal, complete, verifiable example that reproduces the issue.
Comment From: spring-cloud-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-cloud-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.