IllegalStateException

45 views
Skip to first unread message

Andrew Gaydenko

unread,
Aug 14, 2014, 2:31:37 AM8/14/14
to unfilter...@googlegroups.com
Hi! I'm trying async response:

package com.example

import unfiltered.request._
import unfiltered.response._

import unfiltered.directives._, Directives._
import scala.concurrent.ExecutionContext.Implicits.global

class App extends unfiltered.filter.async.Plan {

 
def intent = {
   
case req @ GET(Path("/ok")) =>
      scala
.concurrent.Future(req.respond(ResponseString("ok") ~> Ok))
 
}
}

object Server {
 
def main(args: Array[String]) {
    unfiltered
.jetty.Server.local(8080).context("/assets") {
      _
.resources(new java.net.URL(getClass().getResource("/www/css"), "."))
   
}.plan(new App).run({ svr =>
      unfiltered
.util.Browser.open(svr.portBindings.head.url)
   
})
 
}
}

After few runs of

 wrk -c 1000 -t 1000 -d 10s "http://127.0.0.1:8080/ok"

... server stops to respond with plenty of exception in sbt console:

2014-08-14 10:26:52.480:WARN:oejs.ServletHandler:/ok
java
.lang.IllegalStateException: Committed
        at org
.eclipse.jetty.server.Response.resetBuffer(Response.java:1154)
        at org
.eclipse.jetty.server.Response.sendError(Response.java:317)
        at org
.eclipse.jetty.server.Response.sendError(Response.java:419)
        at org
.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:486)
        at javax
.servlet.http.HttpServlet.service(HttpServlet.java:735)
        at javax
.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at org
.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
        at org
.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
        at org
.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
        at org
.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
        at org
.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
        at org
.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        at org
.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:193)
        at org
.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        at org
.eclipse.jetty.server.Server.handleAsync(Server.java:410)
        at org
.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:502)
        at org
.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
        at org
.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
        at org
.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
        at org
.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
        at org
.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
        at org
.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
        at org
.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
        at org
.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        at org
.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        at java
.lang.Thread.run(Thread.java:745)

After few minutes the servers can start to respond again - until the next kilometre of exceptions. Where is my mistake?



Erlend Hamnaberg

unread,
Aug 14, 2014, 4:50:42 AM8/14/14
to unfilter...@googlegroups.com
Try reversing the ResponseString("ok") ~> Ok

The ReponseString should always be the last thing you are sending.

-E






--
You received this message because you are subscribed to the Google Groups "Unfiltered" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unfiltered-sca...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Gaydenko

unread,
Aug 14, 2014, 5:03:09 AM8/14/14
to unfilter...@googlegroups.com
On Thursday, August 14, 2014 12:50:42 PM UTC+4, Erlend Hamnaberg wrote:
Try reversing the ResponseString("ok") ~> Ok

Would you, please, elaborate it with a code fragment?

Erlend Hamnaberg

unread,
Aug 14, 2014, 5:29:17 AM8/14/14
to unfilter...@googlegroups.com
Ok ~> ResponseString("ok")

-E


--

Andrew Gaydenko

unread,
Aug 14, 2014, 5:40:39 AM8/14/14
to unfilter...@googlegroups.com
On Thursday, August 14, 2014 1:29:17 PM UTC+4, Erlend Hamnaberg wrote:
Ok ~> ResponseString("ok")

With

  def intent = {
   
case req @ GET(Path("/ok")) =>
 
      scala
.concurrent.Future { req.respond{Ok ~> ResponseString("ok")} }
 
}



I get the same result.

By the way, how to overwrite (set the last) jetty/servlet-api versions?

Reply all
Reply to author
Forward
0 new messages