Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364458

Summary: IllegalArgumentException thrown in DirectNIOBuffer.poke()
Product: [RT] Jetty Reporter: Missing name <bubbleguuum>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox
Version: unspecified   
Target Milestone: 7.5.x   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Missing name CLA 2011-11-22 07:40:07 EST
Build Identifier: 

I'm using a ProxyServlet to proxy requests. This servlet handles many requests concurrently and these requests are often aborted mid-processing by the client from which the requests originate.
Sometimes exception below is thrown and caught by ProxyServlet.
ProxyServlet uses continuations. Could that be the problem ?
Note that I do not see such problem if I switch from SelectChannelConnector to a regular SocketConnector.



java.lang.IllegalArgumentException
	at java.nio.Buffer.position(Unknown Source)
	at java.nio.DirectByteBuffer.put(Unknown Source)
	at org.eclipse.jetty.io.nio.DirectNIOBuffer.poke(DirectNIOBuffer.java:201)
	at org.eclipse.jetty.io.nio.DirectNIOBuffer.poke(DirectNIOBuffer.java:141)
	at org.eclipse.jetty.io.AbstractBuffer.put(AbstractBuffer.java:457)
	at org.eclipse.jetty.http.HttpGenerator.addContent(HttpGenerator.java:216)
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:167)
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:101)
	at org.eclipse.jetty.io.AbstractBuffer.writeTo(AbstractBuffer.java:672)
	at org.eclipse.jetty.servlets.ProxyServlet$1.onResponseContent(ProxyServlet.java:455)
	at org.eclipse.jetty.client.HttpExchange$Listener.onResponseContent(HttpExchange.java:1172)
	at org.eclipse.jetty.client.AbstractHttpConnection$Handler.content(AbstractHttpConnection.java:332)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:872)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:129)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:585)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$1.run(QueuedThreadPool.java:533)

Reproducible: Always

Steps to Reproduce:
- Instantiate jetty with a SelectChannelConnector and a ProxyServlet
- have a client make many requests to the ProxyServlet while aborting some of them before they complete (unsure if the aborting is needed to trigger the problem).
Comment 1 Greg Wilkins CLA 2011-11-27 16:50:52 EST
I believe this issue has been fixed, although I'm not 100% sure as we don't have a reproduction of it.   However, we did find some poor synchronisation of the pooled NIO buffers.

Could you try a recent snapshot build from 
https://oss.sonatype.org/content/groups/jetty-with-staging/org/eclipse/jetty/jetty-distribution/7.6.0-SNAPSHOT/