[undertow-dev] leaking file descriptors when using classpath resource

Sascha Sadat-Guscheh kid at bitkid.com
Tue May 23 06:14:46 EDT 2017


Hello!

We pack our undertow application into a fatJar and we want to serve some resources out of that jar file. Currently we initialise our handler like this:

Handlers.resource(ClassPathResourceManager(ClassLoader.getSystemClassLoader(), "public/“))

It works, but for each call we do it opens a file descriptor to the jar and it never closes it so we end up pretty soon with a TooManyOpenFiles exception. 

2017-05-22 14:20:24,542 Exception accepting request, closing server channel TCP server (NIO) <33364501> java.io.IOException: Too many open files
    at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
    at org.xnio.nio.QueuedNioTcpServer.handleReady(QueuedNioTcpServer.java:477)
    at org.xnio.nio.QueuedNioTcpServerHandle.handleReady(QueuedNioTcpServerHandle.java:38)
    at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)

Are we using it wrong?

Best, Sascha


More information about the undertow-dev mailing list