Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Resource leak with URLResource?

Hello Jan,

thanks for looking into this.

However I am not talking about JVM or Jetty caches. The Resource base
class does provide a few methods, like the "exists" check. For Resource
there are a few implementations, such as URLResource, which does perform
the "exists" check by opening the stream. Now if the URL is backed by a
file, due to some URL handler implementing the stream based on a file
resource, then the InputStream might be a FileInputStream, with a file
handle.

Now in this case the method checks for existence of the Resource, (which
creates a stream), but never calls close. So the stream will not get
closed. This might be ok for some stream types, although I doubt that,
but for a file stream, this will keep the file handle open.

So I think that either each resource must be closed properly, or the
check should not be allowed to cache the InputStream.

Thanks for creating the bug in bugzilla.

Jens

On 04/30/2015 12:33 AM, Jan Bartel wrote:
> Hi Jens,
>
> The jvm can cache URL connections, such as JarUrlConnections and also
> JarFile entries. By default, caching is enabled.  So, even if the
> Resource was closed, because caching is enabled, the jvm will still
> hold onto a reference to your url connection. You can try calling
> Resource.setDefaultUseCaches(false) to disable caching, and you should
> see that even without an explicit close, garbage collection should
> eventually get rid of the URL connection/JarFile entries etc.
>
> That said, I've opened an issue to look at any places in the code such
> as this that we could call Resource.close():
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=465864
>
> Jan
> _______________________________________________
> jetty-dev mailing list
> jetty-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-dev


-- 
IBH SYSTEMS GmbH
D-85235 Pfaffenhofen an der Glonn
Läutenring 43
Geschäftsführer / CEO: Dr. Thomas Heitzig

Amtsgericht München
Handelsregister Nummer  HRB 197959
USt ID: DE267945175

Office Munich
D 80992 München
Agnes-Pockels-Bogen 1
T +49 89 18 9 17 49 0

The information transmitted is intended only for the person or entity
to which it is addressed and may contain confidential and/or pivileged
material. Any review, retransmission, dissemination or other use of,
or taking of any action in reliance upon, this information by persons
or entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete the
material from any computer.



Back to the top