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

Prevent zero padding at servlet input chunk #1835

Merged
merged 2 commits into from May 9, 2018

Conversation

Projects
None yet
4 participants
@takezoe
Contributor

takezoe commented May 8, 2018

In the servlet backend, rest of request body chunk is padded with zero, and it causes a following exception in decoding JSON request:

org.http4s.MalformedMessageBodyFailure: Malformed message body: Invalid JSON
	at org.http4s.circe.CirceInstances.$anonfun$jsonDecoderByteBufferImpl$1(CirceInstances.scala:30)
	at cats.data.EitherT.$anonfun$flatMap$1(EitherT.scala:87)
	at cats.effect.internals.IORunLoop$.cats$effect$internals$IORunLoop$$loop(IORunLoop.scala:128)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:310)
	at cats.effect.internals.IORunLoop$RestartCallback.apply(IORunLoop.scala:292)
	at cats.effect.internals.Callback$AsyncIdempotentCallback$$anon$3.run(Callback.scala:142)
	at cats.effect.internals.TrampolineEC.cats$effect$internals$TrampolineEC$$localRunLoop(TrampolineEC.scala:62)
	at cats.effect.internals.TrampolineEC.$anonfun$execute$1(TrampolineEC.scala:54)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
	at cats.effect.internals.TrampolineEC.execute(TrampolineEC.scala:54)
	at cats.effect.internals.Callback$AsyncIdempotentCallback.apply(Callback.scala:139)
	at cats.effect.internals.Callback$AsyncIdempotentCallback.apply(Callback.scala:130)
	at org.http4s.servlet.NonBlockingServletIo.org$http4s$servlet$NonBlockingServletIo$$read$1(ServletIo.scala:92)
	at org.http4s.servlet.NonBlockingServletIo$$anon$1.onDataAvailable(ServletIo.scala:109)
	at org.eclipse.jetty.server.HttpInput.run(HttpInput.java:871)
	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1339)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:398)
	at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:264)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
	at java.lang.Thread.run(Thread.java:748)
Caused by: jawn.ParseException: expected whitespace or eof got  (line 1, column 212)
	at jawn.Parser.die(Parser.scala:107)
	at jawn.SyncParser.parse(SyncParser.scala:30)
	at jawn.SupportParser.$anonfun$parseFromByteBuffer$1(SupportParser.scala:27)
	at jawn.SupportParser.parseFromByteBuffer(SupportParser.scala:27)
	at jawn.SupportParser.parseFromByteBuffer$(SupportParser.scala:26)
	at io.circe.jawn.CirceSupportParser$.parseFromByteBuffer(CirceSupportParser.scala:7)
	at io.circe.jawn.JawnParser.parseByteBuffer(JawnParser.scala:22)
	at org.http4s.circe.CirceInstances.$anonfun$jsonDecoderByteBufferImpl$1(CirceInstances.scala:25)
	... 21 common frames omitted
@rossabaker

Thanks. LGTM.

@ChristopherDavenport

👍 on green

@jmcardon

This comment has been minimized.

Member

jmcardon commented May 8, 2018

The travis failure is unrelated. I'm restarting the build.

@jmcardon

This comment has been minimized.

Member

jmcardon commented May 8, 2018

alright this is a bit less intermittent than I thought. Pinging @bryce-anderson

@rossabaker

This comment has been minimized.

Member

rossabaker commented May 9, 2018

Test failure is unrelated, fixed by #1836.

@rossabaker rossabaker merged commit b2576a9 into http4s:release-0.18.x May 9, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment