Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340692 - IllegalArgumentException on using NIO channels.
Summary: IllegalArgumentException on using NIO channels.
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.3.1   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 7.2.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-22 13:28 EDT by Nikolas Falco CLA
Modified: 2011-08-29 00:52 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolas Falco CLA 2011-03-22 13:28:11 EDT
Build Identifier: 7.3.1.v20110307

I have a jetty server that serve as FileServer for an update site.

This is the content.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/updates</Set>
  <Set name="resourceBase"><SystemProperty name="user.home" default="."/>/repository/p2repository</Set>
  <Set name="extractWAR">true</Set>
</Configure>

I have a lot of this exception:

Listening on port 8022 ... 
2011-03-14 09:52:06.703:INFO::Started SelectChannelConnector@0.0.0.0:8081
2011-03-14 09:58:50.407:WARN::EXCEPTION 
java.lang.IllegalArgumentException
	at java.nio.Buffer.<init>(Buffer.java:174)
	at java.nio.ByteBuffer.<init>(ByteBuffer.java:259)
	at java.nio.ByteBuffer.<init>(ByteBuffer.java:267)
	at java.nio.MappedByteBuffer.<init>(MappedByteBuffer.java:64)
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:94)
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
	at org.eclipse.jetty.io.nio.DirectNIOBuffer.<init>(DirectNIOBuffer.java:46)
	at org.eclipse.jetty.server.ResourceCache.getDirectBuffer(ResourceCache.java:313)
	at org.eclipse.jetty.server.ResourceCache$Content.getDirectBuffer(ResourceCache.java:463)
	at org.eclipse.jetty.server.HttpConnection$Output.sendContent(HttpConnection.java:1207)
	at org.eclipse.jetty.servlet.DefaultServlet.sendData(DefaultServlet.java:789)
	at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:479)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:534)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:476)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:468)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:934)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:404)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:869)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:151)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:346)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:581)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1040)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:592)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:526)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:41)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:528)
	at java.lang.Thread.run(Thread.java:619)



Linux is a Centos 4.5 (32 bit)
Java 1.6.0_18 (32 bit)

Reproducible: Didn't try
Comment 1 Nikolas Falco CLA 2011-03-22 20:21:17 EDT
Following stacktrace this error seems occur when in the call:
class ResourceCache
...
if (_useFileMappedBuffer && resource.getFile()!=null)
   return ...

int len=(int)resource.length();
new DirectNIOBuffer(len); // line 313
...

len parameter is < 0 when:
- is an instance of ResourceColletion (and is empty)
- is an instance of BadResource
- is an instance of JarFileResource (and is a Directory)
never if is an instance of FileResource (if return java.io.File.length() < 0 JVM bug?)

With my configuration should be always last case, webdefault.xml is standard from a jetty distribution so I don't understand the wrong case.
Comment 2 Greg Wilkins CLA 2011-06-22 00:24:47 EDT
sorry we have not looked at this sooner.

Can you try to reproduce on 7.4.2 and if it is still a problem we will get right onto it.
Comment 3 Greg Wilkins CLA 2011-08-29 00:52:06 EDT
This has been resolved in the current release as the length is checked to be >=0