When I try to receive POST data on Jetty, it looks strange. Let's check.
Jetty embedded
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.6.v20170531</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.aggregate/jetty-all-server -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>8.2.0.v20160908</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
</dependency>
Request baseRequest, HttpServletRequest request, HttpServletResponse response
p1p2p3p4[Thu Jun 14 00:29:21 JST 2018][LowerLobby]:null
p6p1p2p3java.lang.IllegalStateException: STREAMED
at org.eclipse.jetty.server.Request.getReader(Request.java:1149)
at com.haniokasai.mc.SteadyMistress.web.handlers.srvtools.pluginmanager_handler.pluginmanager_handler(pluginmanager_handler.java:59)
at com.haniokasai.mc.SteadyMistress.web.WebHandler.handle(WebHandler.java:63)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
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)
What is this guy?
The description was found fairly quickly. ==>>http://apache-wicket.1842946.n4.nabble.com/java-lang-IllegalStateException-STREAMED-Consuming-JSON-fails-td3850442.html
This exception says "Don't use the reader but use the input stream because something (maybe header) has been already read from the stream".
This exception says "use the input stream without the reader, because something (probably the header) is already using the stream."
Cheeks, that's right.
In other words, you don't have to use the buffer reader that is already prepared.
BufferedReader in = baseRequest.getReader();
From
BufferedReader in = new BufferedReader( new InputStreamReader(request.getInputStream()));
Just do it! The questioner says!
that's all!
Recommended Posts