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.

Error: An exception occurred while logging debug-info - source: ContextUtil.splitKeyValueStringAndGroupByKey

See original GitHub issue

Hi Javalin team,

First of all thanks for this wonderful framework, I’ve been a big fan since the Spark times (https://sparkjava.com/) 🙂 ! Now I think I’ve found a bug in the debugger ^^. I’ve tried to minimize the number of potential error sources on my side, but there is maybe some chance left that its related to my HTTP calls. Here we go:

Actual behavior (the bug)

  • Data is sent to the server via HTTP POST (Content-Type=application/json) with a request body that is a JSON string containing the object: {"name": "Test %"}.
  • When request debugging is OFF everything works without problem!
  • When request debugging is ON (Javalin -> config.enableDevLogging()) the debugger crashes with the following exception:
[qtp1169794610-15] INFO io.javalin.Javalin - An exception occurred while logging debug-info
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: ""}"
	at java.base/java.net.URLDecoder.decode(URLDecoder.java:232)
	at java.base/java.net.URLDecoder.decode(URLDecoder.java:142)
	at io.javalin.http.util.ContextUtil.splitKeyValueStringAndGroupByKey(ContextUtil.kt:37)
	at io.javalin.http.Context.formParamMap(Context.kt:186)
	at io.javalin.core.util.LogUtil.requestDevLogger(LogUtil.kt:35)
	at io.javalin.http.JavalinServlet.service(JavalinServlet.kt:83)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at io.javalin.websocket.JavalinWsServlet.service(JavalinWsServlet.kt:51)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:551)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at io.javalin.core.JavalinServer$start$wsAndHttpHandler$1.doHandle(JavalinServer.kt:49)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:501)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:272)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
	at java.base/java.lang.Thread.run(Thread.java:834)

Expected behavior

The URLDecoder: Illegal hex characters in escape (%) pattern is not happening because the string is already decoded.

To Reproduce

Enable request debugging and send a simple JSON Object as described above.

Additional context

A successful request with {"name": "Test"} creates this log entry for me:

----------------------------------------------------------------------------------
[qtp1169794610-15] INFO io.javalin.Javalin - JAVALIN REQUEST DEBUG LOG:
Request: POST [/dynamicObject/search]
    Matching endpoint-handlers: [BEFORE=*, POST=/dynamicObject/search]
    Headers: {Origin=http://localhost:20080, Accept=*/*, Connection=keep-alive, User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36, Referer=http://localhost:20080/, Sec-Fetch-Site=same-site, Sec-Fetch-Dest=empty, Host=localhost:19021, Pragma=no-cache, Accept-Encoding=gzip, deflate, br, Sec-Fetch-Mode=cors, sec-ch-ua="Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99", sec-ch-ua-mobile=?0, Cache-Control=no-cache, Accept-Language=de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7, Content-Length=15, Content-Type=application/json}
    Cookies: {}
    Body: {"name":"Test"}
    QueryString: null
    QueryParams: {}
    FormParams: {{"name":"Test"}=[]}
Response: [200], execution took 8.57 ms
    Headers: {Server=Javalin, Access-Control-Allow-Origin=http://localhost:20080, Access-Control-Allow-Credentials=true, Date=Tue, 16 Feb 2021 16:46:02 GMT, Content-Type=application/json}
    Body is 59 bytes (starts on next line):
    {"result":"fail","error":"Missing or wrong 'definitionId'"}
----------------------------------------------------------------------------------

Related changes in Javalin Code (June 2020): https://github.com/tipsy/javalin/commit/4c2a6c542756a9e409874367af03f348ffbb7f14#diff-536fe1f7d4b493b93d1327273bba4aebfc79f75efbf48352044deae9bfc48586

My Javalin version: 3.9.1

Issue Analytics

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

github_iconTop GitHub Comments

0reactions
tipsycommented, Apr 12, 2021

Great, thank you !

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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