sendError() method does not check the current state

alterrebe avataralterrebe created an issue

I have a lot of messages in my log, looking like:

12:54:29.450 [qtp980075617-23] ERROR sonia.scm.web.HgCGIExceptionHandler - not able to handle mercurial request java.lang.IllegalStateException: STREAM at org.eclipse.jetty.server.Response.getWriter(Response.java:673) [jetty-server-7.6.4.v20120524.jar:7.6.4.v20120524] at sonia.scm.web.HgCGIExceptionHandler.sendError(HgCGIExceptionHandler.java:194) [scm-hg-plugin-1.16.jar:na] at sonia.scm.web.HgCGIExceptionHandler.handleException(HgCGIExceptionHandler.java:115) [scm-hg-plugin-1.16.jar:na] at sonia.scm.web.cgi.DefaultCGIExecutor.execute(DefaultCGIExecutor.java:190) [classes/:na]

...

It seems that sendError() method makes an attempt to set HTTP status or headers after the OutputStream is opened. I saw it with both Mercurial and Git requests.

Comments (8)

  1. alterrebe

    Also there is another error that looks alike this:

    2012-06-13 13:09:30.745:WARN:oejs.ServletHandler:/scm/hg/xxxxxxx java.lang.IllegalStateException: Committed at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1087) at org.eclipse.jetty.server.Response.sendRedirect(Response.java:469) at sonia.scm.web.filter.PermissionFilter.doFilter(PermissionFilter.java:188) at sonia.scm.web.filter.HttpFilter.doFilter(HttpFilter.java:102) at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) at sonia.scm.web.filter.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:139) at sonia.scm.web.filter.HttpFilter.doFilter(HttpFilter.java:102)

    Here it seems that the filter calls sendRedirect() after some other data have been already send.

  2. alterrebe

    I have installed the fix. Still see the error traces:

    2012-06-25 08:48:39.272:WARN:oejs.ServletHandler:/scm/hg/xxx/some/file.cpp
    java.lang.IllegalStateException: Committed
            at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1087)
            at org.eclipse.jetty.server.Response.sendRedirect(Response.java:469)
            at sonia.scm.web.filter.PermissionFilter.doFilter(PermissionFilter.java:188)
            at sonia.scm.web.filter.HttpFilter.doFilter(HttpFilter.java:102)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at sonia.scm.web.filter.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:139)
            at sonia.scm.web.filter.HttpFilter.doFilter(HttpFilter.java:102)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:168)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at sonia.scm.filter.BaseUrlFilter.doFilter(BaseUrlFilter.java:100)
            at sonia.scm.web.filter.HttpFilter.doFilter(HttpFilter.java:102)
            at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
            at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
            at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
            at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
            at sonia.scm.boot.BootstrapFilter.doFilter(BootstrapFilter.java:104)
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1332)
            at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:477)
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
            at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
            at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
            at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
            at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
            at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
            at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
            at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
            at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
            at org.eclipse.jetty.server.Server.handle(Server.java:348)
            at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
            at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
            at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
            at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
            at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
            at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
            at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:620)
            at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
            at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
            at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
            at java.lang.Thread.run(Thread.java:662)
    
  3. alterrebe

    It looks strange for me that it calls the authentication filter somewhere after processing the header (see AbstractHttpConnection.headerComplete() method in the trace).

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.