Hi,
I have a Java program where Jetty is embedded. Using lsof -p PID while
running on linux I can see that I leak file handles to
all static files that are served using
org.eclipse.jetty.servlet.DefaultServlet.
Inspecting the source I believe I have found the problem:
In org.eclipse.jetty.servlet.DefaultServlet.sendData(...)
There are a few occurrences of this construct:
Buffer buffer = (content==null)?null:content.getIndirectBuffer();
The core of the implementation of
HttpContent.ResourceAsHttpContent.getIndirectBuffer() is:
ByteArrayBuffer buffer = new ByteArrayBuffer((int)_resource.length());
buffer.readFrom(*_resource.getInputStream()*,(int)_resource.length());
return buffer;
The InputStream returned by _resource.getInputStream() is not closed in
getIndirectBuffer() and when the FileResource.getInputStream() is
nothing more than:
return new FileInputStream(_file);
Then the InputStream is *never* closed and the file handle is leaked -
or am I missing something ?
I have checked the sources of Jetty 7.6 and 8.1 and the implementations
of HttpContent.ResourceAsHttpContent.getIndirectBuffer()
and FileResource.getInputStream() have not changed.
Best regards
Christoffer Bruun
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users