question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Context.formParamMap() is not safe for repeated calls

See original GitHub issue

Actual behavior (the bug) When a non-multipart form is submitted, and form parameters extracted, form parameters subsequent to parameter 1 are empty.

Expected behavior The form parameters not to be empty

To Reproduce Post a non-multipart form, such that Context.formParamMap calls ContextUtil.splitKeyValueStringAndGroupByKey(body()).

Additional context The current implementation of Context.body() calls bodyAsBytes(), which is a mutative operation, consuming the entire stream. Subsequent calls to bodyAsBytes() will reach EOF on the stream, yielding an empty body, which in turn presents itself as an empty formParamMap().

Given that bodyAsBytes() summons a new buffer in any event, it probably makes sense to make this a lazily initialized property of Context.

I still owe you a PR from my prior raised issue, happy to send this one over alongside it.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stevebarhamcommented, Feb 12, 2019

Happy to close!

0reactions
tipsycommented, Feb 11, 2019

@stevebarham do you want to discuss this more, or should the issue be closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context.formParamMap() is not safe for repeated calls #477
Actual behavior (the bug) When a non-multipart form is submitted, and form parameters extracted, form parameters subsequent to parameter 1 ...
Read more >
How do you read multiple body parameters from Javalin?
The basic ctx.body() method will give you access to the form data as a string: fieldOne=valueOne&fieldTwo=valueTwo&.
Read more >
Documentation - A lightweight Java and Kotlin web framework
The Context object provides you with everything you need to handle a ... The CrudHandler is an interface that can be used within...
Read more >
Read Web Applications with Javalin | Leanpub
The ctx represents an instance of the Context object, which contains everything you need to handle an http request. It contains the underlying...
Read more >
jmeter
Multiple implementations of pre- and post-processors around sampler. ... Jmeter would not record the website http calls.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found