org eclipse jetty io EofException early EOF

org eclipse jetty io EofException early EOF

If you are using Jetty and integrated with your project actively using it then it’s possible you could get below exception:

org.eclipse.jetty.io.EofException: early EOF
at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:65) ~[jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]

org.eclipse.jetty.io.EofException: early EOF
	at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:65) ~[jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[?:1.8.0_51]
	at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[?:1.8.0_51]
	at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[?:1.8.0_51]
	at java.io.InputStreamReader.read(Unknown Source) ~[?:1.8.0_51]
	at java.io.BufferedReader.fill(Unknown Source) ~[?:1.8.0_51]
	at java.io.BufferedReader.read1(Unknown Source) ~[?:1.8.0_51]
	at java.io.BufferedReader.read(Unknown Source) ~[?:1.8.0_51]
	at java.io.Reader.read(Unknown Source) ~[?:1.8.0_51]
	at com.wfs.otc.message.adaptor.GoogleProtoBuffMessageAdaptor.getMessageFromRequest(GoogleProtoBuffMessageAdaptor.java:57) ~[classes/:?]
	at com.wfs.otc.message.adaptor.GoogleProtoBuffMessageAdaptor.processMessage(GoogleProtoBuffMessageAdaptor.java:26) ~[classes/:?]
	at com.wfs.otc.service.MessageHandler.handle(MessageHandler.java:45) [classes/:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.server.Server.handle(Server.java:370) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651) [jetty-http-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [jetty-server-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668) [jetty-io-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) [jetty-io-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-8.1.12.v20130726.jar:8.1.12.v20130726]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-8.1.12.v20130726.jar:8.1.12.v20130726]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]

Solution: This exception occures on some version of Jetty and I believe this is bug and JIRA is already there. In the meantime if you want to fix just change the version from older to newest version. As of writing this I was using below version and getting error:

<dependency>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-server</artifactId>
	<version>8.1.12.v20130726</version>
</dependency>

<dependency>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-servlet</artifactId>
	<version>8.1.12.v20130726</version>
</dependency>

And to fix this I moved up from 8.1.12.v20130726 to 9.2.9.v20150224 as below:

<dependency>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-server</artifactId>
	<version>9.2.9.v20150224</version>			
</dependency>

<dependency>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-servlet</artifactId>
	<version>9.2.9.v20150224</version>
</dependency>

If you are not using maven please download above version or latest version of jars and include in your project. This should fix the issue.

Leave a Reply

Your email address will not be published. Required fields are marked *