mpenet/jet

Jet does not handle a nil :body in the Ring response properly [0.5.9]

Closed this issue · 7 comments

Since upgrading to ring-middleware-format:0.5.0 I have an issue with empty responses.

Previously, a nil :body would be converted to the text "nil".

Since the upgrade, the :body key is actually nil.

I end up seeing the following exceptions in my console:

09:49:14.633 WARN  no-correlation-id [qtp731357691-96] o.e.j.s.HttpChannel - /auth/users/6a0f761e-e38e-4f08-adef-4e28cdbf2dd7
clojure.lang.ArityException: Wrong number of args (3) passed to: servlet/eval17168/fn--17169
    at clojure.lang.AFn.throwArity(AFn.java:429) ~[clojure-1.7.0-alpha5.jar:na]
    at clojure.lang.AFn.invoke(AFn.java:40) ~[clojure-1.7.0-alpha5.jar:na]
    at qbits.jet.servlet$eval17103$fn__17104$G__17094__17113.invoke(servlet.clj:88) ~[na:na]
    at qbits.jet.servlet$set_response_body_BANG_.invoke(servlet.clj:93) ~[na:na]
    at qbits.jet.servlet$set_body_BANG_.invoke(servlet.clj:204) ~[na:na]
    at qbits.jet.servlet$eval17297$fn__17298.invoke(servlet.clj:238) ~[na:na]
    at qbits.jet.servlet$eval17268$fn__17269$G__17259__17276.invoke(servlet.clj:211) ~[na:na]
    at qbits.jet.servlet$update_response.invoke(servlet.clj:216) ~[na:na]
    at qbits.jet.server$make_handler$fn__17611.invoke(server.clj:72) ~[na:na]
    at qbits.jet.server.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source) ~[na:na]
    at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.server.Server.handle(Server.java:497) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]

I've partly addressed this as follows:

(extend-protocol PBodyWritable

  nil
  (write-body! [body servlet-response request-map]))

... and that solves my server-side exception, but a few of my tests are still failing because I think the combination of a content-type header and no response body at all is invalid. I'll update with more information shortly.

that's odd:

in the latest version: https://github.com/mpenet/jet/blob/master/src/clj/qbits/jet/servlet.clj#L168-L170

maybe try upgrading

Tested this in 0.6.0, same problem.

Thanks, I ll check this tomorrow morning first thing.

Cheers

fixed in 0.6.1

Thanks for the report!

Thanks again; I've upgraded my code and am running my test suite right now.

... and all my tests pass with 0.6.1.

Glad to hear that.