Я нахожусь в странной ситуации, когда возникает исключение при чтении из входного потока и записи в выходной поток. Файл загружается правильно, но я вижу это исключение. Невозможно понять, почему мы получаем эти исключения.
final URL url = new URL(reportLink);
final URLConnection urlConnection = url.openConnection();
final InputStream inputStream = urlConnection.getInputStream();
final OutputStream outputStream = httpServletResponse.getOutputStream();
final String contentTypeHeader = urlConnection.getHeaderField(CONTENT_TYPE);
final String contentType = ContentType.getContentType(contentTypeHeader);
final String fileName = urlConnection.getHeaderField(CONTENT_DISPOSITION);
httpServletResponse.setContentType(contentType);
httpServletResponse.setHeader(CONTENT_DISPOSITION, getContentDispositionWithUniqueFileName(fileName,
reportIds));
final byte[] chunk = new byte[CHUNK_SIZE];
int numberOfBytes, chunkCount = 0;
while ((numberOfBytes = inputStream.read(chunk)) != -1) {
outputStream.write(chunk, 0, numberOfBytes);
totalNumOfBytesTransferred += numberOfBytes;
}
outputStream.flush();
outputStream.close();
inputStream.close();
ниже получено исключение:
org.springframework.web.servlet. mvc .method .annotation.ExceptionHandlerExceptionResolver: не удалось вызвать метод @ExceptionHandler: public com.amazon.apa.web.model.ErrorResponse com.amazon.apa.web.controller.core.BaseController.handleUnexpectedException (java .langaxException, servlet.http.HttpServletRequest) {org. apache .catalina.connector.ClientAbortException: java .io.IOException: Broken pipe | в орг. apache .catalina.connector.OutputBuffer.realWriteBytes (OutputBuffer. java: 396) | в орг. apache .tomcat.util.buf.ByteChunk.flushBuffer (ByteChunk. java: 426) | в орг. apache .tomcat.util.buf.ByteChunk.append (ByteChunk. java: 339) | at org. apache .catalina.connector.OutputBuffer.writeBytes (OutputBuffer. java: 421) | в организации. apache .catalina.connector.OutputBuffer.write (OutputBuffer. java: 409) | в орг. apache .catalina.connector.CoyoteOutputStream.write (CoyoteOutputStream. java: 97) | на com.faster xml .jackson.core. json .UTF8JsonGenerator._flushBuffer (UTF8JsonGenerator. java: 2039) | на com.faster xml .jackson.core. json .UTF8JsonGenerator.flu sh (UTF8JsonGenerator. java: 1051) | на com.faster xml .jackson.databind.ObjectWriter.writeValue (ObjectWriter. java: 953) | at org.springframework.http.converter. json .AbstractJackson2HttpMessageConverter.writeInternal (AbstractJackson2HttpMessageConverter. java: 285) | at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write (AbstractGenericHttpMessageConverter. java: 106) | в org.springframework.web.servlet. mvc .method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters (AbstractMessageConverterMethodProcessor. java: 231) | в org.springframework.web.servlet. mvc .method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue (RequestResponseBodyMethodProcessor. java: 174) | at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue (HandlerMethodReturnValueHandlerComposite. java: 81) | в org.springframework.web.servlet. mvc .method.annotation.ServletInvocableHandlerMethod.invokeAndHandle (ServletInvocableHandlerMethod. java: 113) | в org.springframework.web.servlet. mvc .method.annotation.ExceptionHandlerExceptionResolver.doResolveHandlerMethodException (ExceptionHandlerExceptionResolver. java: 385) | at org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver.doResolveException (AbstractHandlerMethodExceptionResolver. java: 59) | at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException (AbstractHandlerExceptionResolver. java: 132) | в org.springframework.web.servlet.handler.HandlerExceptionResolverComposite.resolveException (HandlerExceptionResolverComposite. java: 76) | в org.springframework.web.servlet.DispatcherServlet.processHandlerException (DispatcherServlet. java: 1222) | в org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet. java: 1034) | в org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet. java: 984) | в org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet. java: 901) | в org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet. java: 970) | atg.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet. java: 861) | на javax.servlet.http.HttpServlet.service (HttpServlet. java: 622) | в org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet. java: 846) | на javax.servlet.http.HttpServlet.service (HttpServlet. java: 729) | в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 292) | в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 207) | at com.amazon.core.platform.runtime.FinalRequestFilter.doFilter (FinalRequestFilter. java: 87) | в org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy. java: 347) | в org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy. java: 263) | в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 240) | в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 207) | в com.amazon.cloudauth.resourceserver.servlet.CloudAuthResourceFilter.handleAuthrotivationResult (CloudAuthResourceFilter. java: 117) | в