When a web application I noticed there were cases where the resonse.getWriter()
was called and output to it, this PrintWriter
is never flushed nor closed.
There are no further writes, so I could probably flush or close it safely. The application seems to work fine without closing the writers and in org.apache.catalina.connector.CoyoteAdapter
does call finishResponse()/finishRequest()
anyway but this is the inner workings of tomcat and seems wrong to rely on.
Closing the writer seems wrong because I'm not sure if I actually opened the writer with the response.getWriter()
call. (usually not I think)
Flushing seem more like a good idea, but I'm sure if this is considered the 'right' way.
Not doing any flush or close feels like I might leak resources in certain cases.