<p>I have a Tomcat Filter that delegates requests to the a handling object depending on the URL. This is the only filter in the <code>FilterChain</code>. I have an Ajax app that hammers this filter with lots of requests.</p>

<p>Recently I noticed an issue where the filter's <code>doFilter</code> method is often called with a committed response as a parameter (Internally, it is the coyote response that is marked committed).</p>

<p>It seems to me that the only way that this can happen is if the <code>recycle()</code> method is not called on this coyote response. I have checked to make sure that I am not keeping references to any of the request, response, outputStream, or writer objects. Additionally, I made sure to close the outputStream in a finally block. However, this doesn't resolve this issue.</p>

<p>This sounds like I am doing something to abuse the servlet container but I am having trouble tracking it down.</p>

[{'answer_id': 45420, 'author': 'WMR', 'author_id': 2844, 'author_profile': 'https://Stackoverflow.com/users/2844', 'pm_score': 0, 'selected': False, 'text': "<p>What version of Tomcat are you using? To me this sounds like a bug in Tomcat, I can't think of any reason why your doFilter method should be called with a response that's already been committed (if that filter is the only one in the chain, are you sure about this?). </p>\n"}, {'answer_id': 46330, 'author': 'Casey Watson', 'author_id': 4682, 'author_profile': 'https://Stackoverflow.com/users/4682', 'pm_score': 3, 'selected': True, 'text': "<p>I have tried using Tomcat 6.16 and 6.18. This is definitely is the only filter in the chain.</p>\n\n<p>It seems that something is keeping a reference to the servlet outputStream. I wrapped the ServletOutputStream in my own OutputStream and then made sure the reference is destroyed. This fixed the issue so that I no longer see a committed response passed in.</p>\n\n<p>This is an odd side effect of holding a reference. But I don't think it qualifies as a Tomcat bug. More likely a bug in ImageIO.createImageOutputStream() that I suspect is holding the reference.</p>\n"}]
['https://Stackoverflow.com/questions/45361', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4682/']