LogUtil requests response body in dev (debug) mode and fails for every InputStream based response
See original GitHub issueUsing 4.0.0.RC0
and serving just a regular InputStream as a response:
ctx.result(App::class.java.getResourceAsStream("/test.file"))
.encoding(Charsets.UTF_8)
.contentType(MimeTypes.getDefaultMimeByExtension(uri))
Results in IOException with config.enableDevLogging()
enabled:
18:35:31.983 INFO | An exception occurred while logging debug-info: java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:170)
at java.io.BufferedInputStream.reset(BufferedInputStream.java:446)
at io.javalin.http.Context.resultString(Context.kt:332)
at io.javalin.core.util.LogUtil.resBody(LogUtil.kt:59)
at io.javalin.core.util.LogUtil.requestDevLogger(LogUtil.kt:37)
at io.javalin.http.JavalinServlet.service$finishUpResponse(JavalinServlet.kt:76)
at io.javalin.http.JavalinServlet.service(JavalinServlet.kt:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.javalin.jetty.JavalinJettyServlet.service(JavalinJettyServlet.kt:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at io.javalin.jetty.JettyServer$start$wsAndHttpHandler$1.doHandle(JettyServer.kt:52)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:386)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.lang.Thread.run(Thread.java:748)
It looks like this method tries to read again a closed stream:
Despite of this exception, server properly serves this result file.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Log requests and responses using Spring resttemplate
Getting below error: aused by: java.lang.IllegalArgumentException: No InputStream specified at org.springframework.util.Assert.
Read more >How to debug http request & responses with body in a human ...
Currently if we try to log the request & response, the libray logs the request & response bodies in a machine readable way...
Read more >How to log the request body in a Spring Boot application
When your application sends a response, the data of the response is ... the input stream we see a failure that the request...
Read more >Log Incoming Requests In Spring - Java Development Journal
In this post, we will explore as of how to Log Incoming Requests In Spring. We will explore different options to accomplish it...
Read more >Troubleshooting requests - Postman Learning Center
Troubleshooting requests · Sending requests · Debugging with the Console | Postman Level Up · Powerful Debugging with the Postman Console · Using ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After the regex routing is disabled by default.
You’ll get
Body is an InputStream which can't be reset, so it can't be logged
in case yourresultStream
can’t be reset now.