Lorsque j'essaie de recevoir des données POST avec Jetty, cela semble étrange. Allons vérifier.
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)
Quel est ce gars?
La description a été trouvée assez rapidement. ==>>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".
Cette exception dit "utiliser le flux d'entrée sans le lecteur, car quelque chose (probablement l'en-tête) utilise déjà le flux."
Hoho, c'est vrai.
En d'autres termes, vous n'avez pas besoin d'utiliser le lecteur de tampon déjà préparé.
BufferedReader in = baseRequest.getReader();
De
BufferedReader in = new BufferedReader( new InputStreamReader(request.getInputStream()));
Simplement fais-le! Le questionneur dit!
c'est tout!
Recommended Posts