The story of an Illegal State Exception in Jetty.

Introduction

When I try to receive POST data on Jetty, it looks strange. Let's check.

environment

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>

Variables that are already available

Request baseRequest, HttpServletRequest request, HttpServletResponse response

log

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)

solution

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

The story of an Illegal State Exception in Jetty.
The story of AppClip support in Anyca
The story of writing Java in Emacs
The story of making ordinary Othello in Java
The story of throwing BLOB data from EXCEL in DBUnit
[Docker] The story that an error occurred in docker-compose up
Explain DI in an obese story
[Java version] The story of serialization
The story of @ViewScoped consuming memory
The story of toString () starting with passing an array to System.out.println
Order of processing in the program
How to get the length of an audio file in java
The story of forgetting to close a file in Java and failing
The story of acquiring Java Silver in two months from completely inexperienced.
[Git] The horrifying story of deleting the master branch ~ The answer is in English ~
The story of encountering Spring custom annotation
Get the result of POST in Java
The identity of params [: id] in rails
The story of updating SonarQube's Docker Container
Rails refactoring story learned in the field
Compare the elements of an array (Java)
The story of RxJava suffering from NoSuchElementException
Find an approximation of cosx in Swift
Write the movement of Rakefile in the runbook
Use hashes well in Ruby to calculate the total amount of an order
The story of making an electronic New Year's card app with Vue.js + Rails
The story of making an Android application that can adjust the sampling frequency of the accelerometer
[Order method] Set the order of data in Rails
[Java] Handling of JavaBeans in the method chain
[Android] [Java] Manage the state of CheckBox of ListView
Stuck in an enum in front of a blacksmith
About the idea of anonymous classes in Java
A story about the JDK in the Java 11 era
The story of making the existing Dockerfile GPU compatible
Measure the size of a folder in Java
The story of introducing Ajax communication to ruby
Story of implementing update function in form object
The story of raising Spring Boot 1.5 series to 2.1 series
Feel the passage of time even in Java
The story of tuning android apps with libGDX
The story of adding the latest Node.js to DockerFile
The story of initializing Money :: Currency when testing
Import files of the same hierarchy in Java
What to do if you can't get the text of an element in Selenium
How to use git with the power of jgit in an environment without git commands
Write a test by implementing the story of Mr. Nabeats in the world with ruby