When I put my Jetty server under high load, I sometimes get
IllegalStateException being thrown mentioning "ReadListener already set". These
exceptions are thrown when a ReadListener is set more than once to the
inputstream of an incoming request. However, I never do that. I can only
explain this if the same request is sent to my handler multiple times, which I
don't really understand. Can somebody explain how this can happen so that I can
avoid these exceptions? Note that I don't get these exception under light load.
Here's some more background:
(1) I'm using jetty 9.3.6.v20151106
(2) I'm running an embedded Jetty
(3) I only have a single request handler. It extends AbstractHandler
and does the following:
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
String id = request.getRequestURI().substring(1);
baseRequest.setHandled(true);
long count = requests.decrementAndGet();
if (count < 0) {
requests.incrementAndGet();
response.setStatus(HttpStatus.SERVICE_UNAVAILABLE_503);
return;
}
AsyncContext context = request.startAsync();
ServletInputStream inputStream = request.getInputStream();
inputStream.setReadListener(new ReadListener() { ... });
}
So as you can see, all requests are handled asynchronously unless my server is
overloaded (which is not the case when the exceptions occur).
Thanks,
Bert
PS: Here's the complete stacktrace
java.lang.IllegalStateException: ReadListener already set
at
org.eclipse.jetty.server.HttpInput.setReadListener(HttpInput.java:528)
~[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at
com.clear2pay.opf.realtime.rest.HttpRequestHandler.handle(HttpRequestHandler.java:56)
~[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
~[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at org.eclipse.jetty.server.Server.handleAsync(Server.java:567)
~[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:393)
[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:262)
[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
[opf-0.0.1-SNAPSHOT-allinone.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
12:27:09.743 [qtp2027944996-257] WARN org.eclipse.jetty.server.HttpChannel -
ERROR_DISPATCH loop detected on Request[POST
//be-nft4-app-04:8080/590715314303067]@5928fccb
java.lang.IllegalStateException: ReadListener already set
12:27:09.743 [qtp2027944996-309] WARN org.eclipse.jetty.server.HttpChannel -
ERROR_DISPATCH loop detected on Request[POST
//be-nft4-app-04:8080/590715314304262]@7d407fdb
java.lang.IllegalStateException: ReadListener already set
_____________
The information contained in this message is proprietary and/or confidential.
If you are not the intended recipient, please: (i) delete the message and all
copies; (ii) do not disclose, distribute or use the message in any manner; and
(iii) notify the sender immediately. In addition, please be aware that any
message addressed to our domain is subject to archiving and review by persons
other than the intended recipient. Thank you.
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users