Bypassing Step response through getOutputStream, getWriter?

47 views
Skip to first unread message

Leif Warner

unread,
May 1, 2010, 5:03:43 PM5/1/10
to step-user
I'm using an API that sometimes wants to write content to either an
OutputStream or a Writer. They recommend using OutputStream to "avoid
character encoding issues".
When end my Step route with "model.write(response.getOutPutStream)",
everything looks works peachy from the client side, but on the Step
server side I get "java.lang.IllegalStateException: STREAM
at org.mortbay.jetty.Response.getWriter(Response.java:616)"
If instead I use response.getWriter, nothing complains.
Is there anything I can tell Step to let it know to ignore handling
the output, I've already got it covered, or should I just ignore that
error, or just stick with getWriter? Use StringWriter to return?
-Leif

More of that error:
[warn]
java.lang.IllegalStateException: STREAM
at org.mortbay.jetty.Response.getWriter(Response.java:616)
at com.thinkminimo.step.StepKernel
$class.renderResponseBody(StepKernel.scala:173)
at com.thinkminimo.step.Step.renderResponseBody(Step.scala:11)
at com.thinkminimo.step.StepKernel
$class.renderResponse(StepKernel.scala:157)
at com.thinkminimo.step.Step.renderResponse(Step.scala:11)
at com.thinkminimo.step.StepKernel$$anonfun$handle$1$$anonfun$apply$7$
$anonfun$apply$8.apply(StepKernel.scala:132)
at com.thinkminimo.step.StepKernel$$anonfun$handle$1$$anonfun$apply$7$
$anonfun$apply$8.apply(StepKernel.scala:115)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:73)
at com.thinkminimo.step.StepKernel$$anonfun$handle$1$$anonfun$apply
$7.apply(StepKernel.scala:115)
at com.thinkminimo.step.StepKernel$$anonfun$handle$1$$anonfun$apply
$7.apply(StepKernel.scala:115)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:73)
at com.thinkminimo.step.StepKernel$$anonfun$handle
$1.apply(StepKernel.scala:114)
at com.thinkminimo.step.StepKernel$$anonfun$handle
$1.apply(StepKernel.scala:114)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:73)
at com.thinkminimo.step.StepKernel$class.handle(StepKernel.scala:113)
at com.thinkminimo.step.Step.handle(Step.scala:11)
at com.thinkminimo.step.Step.service(Step.scala:15)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

Leif Warner

unread,
May 1, 2010, 5:23:20 PM5/1/10
to step-user
Sorry, nevermind. Should do my own homework before posting.

Looking at the offending function, "renderResponseBody" in StepKernel,
I notice the comment on line 172:
"// If an action returns Unit, it assumes responsibility for the
response",
which was exactly what I wanted.
Putting () at the bottom of my action works for this.

Maybe some ScalaDoc-type thing for these projects might be nice at
some point.
-Leif
Reply all
Reply to author
Forward
0 new messages