Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running Rapidoid from JUnit - exception when handling async response #193

Open
mzheravin opened this issue Aug 13, 2019 · 0 comments
Open

Comments

@mzheravin
Copy link

Hi!

When running rapidoid from JUnit (4 or 5) I'm getting following error for async requests. Sync handling works fine. Exception happens when calling done() method:

2019-08-13/21:07:49.230/EEST [Thread-9] ERROR o.r.h.impl.lowlevel.LowLevelHttpIO - Error occurred when handling request! | error = java.lang.IllegalArgumentException: The customization request (POST /syncAdminApi/v1/users) doesn't match the context request (null)!
java.lang.IllegalArgumentException: The customization request (POST /syncAdminApi/v1/users) doesn't match the context request (null)!
    at org.rapidoid.u.U.illegal(U.java:443)
    at org.rapidoid.u.U.must(U.java:476)
    at org.rapidoid.http.customize.Customization.inValidContext(Customization.java:130)
    at org.rapidoid.http.customize.Customization.of(Customization.java:121)
    at org.rapidoid.http.impl.BodyRenderer.mediaResponseRenderer(BodyRenderer.java:91)
    at org.rapidoid.http.impl.BodyRenderer.resultToRespBody(BodyRenderer.java:85)
    at org.rapidoid.http.impl.BodyRenderer.createRespBodyFromResult(BodyRenderer.java:75)
    at org.rapidoid.http.impl.BodyRenderer.toRespBody(BodyRenderer.java:41)
    at org.rapidoid.http.impl.ReqImpl.renderResponse(ReqImpl.java:569)
    at org.rapidoid.http.impl.ReqImpl.renderResponseOrError(ReqImpl.java:549)
    at org.rapidoid.http.impl.ReqImpl.onDone(ReqImpl.java:524)
    at org.rapidoid.http.impl.ReqImpl.done(ReqImpl.java:510)
    at org.rapidoid.http.impl.RespImpl.done(RespImpl.java:294)
    ...

How I do async processing in the code:

in rapidoid handler thread:

  1. Resp resp = req.async()
  2. ... publish resp to processing pipeline...
  3. return resp

later from another thread:

  1. resp.code(..)
  2. resp.json(..)
  3. resp.done()

When running as standalone application, above approach works fine.

I have noticed that startup log is different when starting rapidoid from the junit, for some reason main=null:

INFO  org.rapidoid.setup.App - Inferred application root | main = null | package = com.package.my

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant