Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.System: java.lang.Throwable: Explicit termination method 'close' not called #466

Open
priand opened this issue Aug 31, 2014 · 4 comments

Comments

@priand
Copy link

priand commented Aug 31, 2014

I saw that a similar exception has been seen previously by libgdx users.
Basically, I have a robovm app that depends on a library that tries to find resources using ClassLoader.getResources(). It fails with the exception bellow.
Note that the same code works perfectly well on a regular JRE and on Android.

[WARN] android.System: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
[WARN] android.System: java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java)
at java.io.RandomAccessFile.(RandomAccessFile.java)
at java.io.RandomAccessFile.(RandomAccessFile.java)
at java.util.zip.ZipFile.(ZipFile.java)
at java.util.zip.ZipFile.(ZipFile.java)
at java.lang.PathClassLoader.init(PathClassLoader.java)
at java.lang.PathClassLoader.findResources(PathClassLoader.java)
at java.lang.ClassLoader.getResources(ClassLoader.java)

@priand
Copy link
Author

priand commented Sep 6, 2014

Do you guys have any news/advice on this one? It actually fails when I try to load a resource file from the jar (META-INF/...). I understand that resources can be externalized outside of the jar, but I'm working on a library and I want one single copy for it, regardless of the platform.

@rexguo
Copy link

rexguo commented Sep 7, 2014

I also have this exception on iOS and I'm not using libgdx:

[WARN] android.System: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
[WARN] android.System: java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java)
at java.io.RandomAccessFile.(RandomAccessFile.java)
at java.io.RandomAccessFile.(RandomAccessFile.java)
at java.util.zip.ZipFile.(ZipFile.java)
at java.util.zip.ZipFile.(ZipFile.java)
at java.lang.PathClassLoader.init(PathClassLoader.java)
at java.lang.PathClassLoader.findResource(PathClassLoader.java)
at java.lang.ClassLoader.getResource(ClassLoader.java)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java)

Note that this is due to the internal instance RandomAccessFile and doing the standard try-finally block to close the InputStream (returned to the user) does not fix the problem.

@ntherning
Copy link
Contributor

Hi. This is not an error. It's a warning that a resource wasn't closed before being finalized. I've seen it myself when loading resources from the classpath. The resource loads just fine and loading resoucres from the classpath is known to work as expected. If you use e.g. Class.getResourceAsStream() and you get null back there's something else wrong.

I'll leave this open and we'll investigate if there's something in the runtime libraries which doesn't properly close a resource.

@priand
Copy link
Author

priand commented Sep 8, 2014

You're right it actually works properly. I did a test with a simple project and a library, and I'm able to find the resources in both places. This is even better than Android, as they are located in different jar files and they do not collide. Plus, it packages the ones in META-INF... There is only the CloseGuard exception that is generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants