I have a Java Spring Boot microservice which uploads documents to a Document Management System (Documentum) by calling a REST interface (Documentum REST). Spring Boot Version is 2.1.5.RELEASE, Spring Cloud Version is Greenwich.RELEASE and the service is deployed using the default embedded Tomcat container that comes with Spring Boot. The REST calls are actioned using the following class: -
org.springframework.web.client.RestTemplate
The service was written originally in Java 1.8 and it worked consistently well. I have recently re-complied the service in Java 11 and deployed to a Java 11 runtime. This required no code changes.
The issue is that since this upgrade, while it still works for small files, the following exception is thrown when the service attempts to upload any file over around 2MB in size: -
Broken pipe (Write failed); nested exception is java.net.SocketException: Broken pipe (Write failed)
My research tells me that this exception occurs when either the client or the server closes the HTTP connection while the other is still attempting to read/write data. I am experimenting with the header values when sending the request, such as increasing the Content-Length, but to no avail yet. Perhaps I should also set the 'Connection' header to 'keep-alive'?
I would be most grateful for any explanations as to why this has suddenly started to happen after a Java version upgrade and any suggestions as to how it may be solved. Many thanks