You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2021/03/26 19:30:00 UTC
[jira] [Commented] (IO-728) IOUtils.copy throws NPE while setting
MimeHeaders
[ https://issues.apache.org/jira/browse/IO-728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309673#comment-17309673 ]
Gary D. Gregory commented on IO-728:
------------------------------------
The title of this ticket is misleading since the NPE is not in Commons IO, see the stack trace. Make sure you are using the latest Tomcat since the NPE is there.
> IOUtils.copy throws NPE while setting MimeHeaders
> -------------------------------------------------
>
> Key: IO-728
> URL: https://issues.apache.org/jira/browse/IO-728
> Project: Commons IO
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.5
> Environment: Java Version: 1.8
> Spring version: 4.3.11.RELEASE
> Spring boot version: 2.0.5.RELEASE
> Jersey version: 2.16
> Reporter: Anuj PB
> Priority: Major
> Attachments: StackTrace
>
>
> I have a Spring Boot Microservice and I am using *IOUtils.copy(InputStream, OutputStream)* which sporadically throws NPE while setting MimeHeaders as shown below:
> 2021-03-18 18:14:05.081 ERROR [http-nio-80-exec-8] o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] threw exception2021-03-18 18:14:05.081 ERROR [http-nio-80-exec-8] o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] threw exception
> java.lang.NullPointerException: null at
> org.apache.tomcat.util.http.MimeHeaders.setValue(MimeHeaders.java:318) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1285) at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:374) at org.apache.coyote.Response.action(Response.java:206) at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:219) at org.apache.coyote.Response.doWrite(Response.java:602) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:352) at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:833) at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:738) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:399) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:377) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639) at
> org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2147) at
> org.apache.commons.io.IOUtils.copy(IOUtils.java:2102) at
> org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123) at
> org.apache.commons.io.IOUtils.copy(IOUtils.java:2078)
> I have attached the complete stack trace in the attachment and also provided the environment where this appears.
> I feel that there is some issue with the Commons IO lib and would like to know if this can be fixed.
> My application has the following code to which the stack trace points to:
> {quote}FileInputStream fis = new FileInputStream(tempOutputFile);
> return outputStream -> \{ IOUtils._copy_(fis, outputStream); }
> ;
> {quote}
> Found the page [http://tomcat.10.x6.nabble.com/NullPointerException-in-MimeHeaders-td2054107.html] which talks about a similar problem and coincidentally we too use *org.apache.catalina.connector.RECYCLE_FACADES=true* system property to avoid reuse of request and response objects, but it isn't not working for us as well.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)