A resource failed to call close

Viewed 4747

I'm getting the android logcat message "A resource failed to call close". I've tracked it down to where that message gets generated. Here's the code:

    Properties defaultProperties = new Properties();
    URL propURL = Util.class.getClassLoader().getResource(DEFAULT_PROPERTIES_FILE);
    if (propURL != null)
    {
        InputStream is = null;
        try
        {
            // Load properties from URL.
            is = propURL.openConnection().getInputStream();
            defaultProperties.load(is);
            is.close();
        }
        catch (Exception ex)
        {

The message is generated on the call to "defaultProperties.load(is)".

I put a breakpoint on that line, and when I step over that line, the warning message is generated. I'm not the author of the code but that line gets executed at least two times and its the second time when that line gets called when the warning gets generated. I just don't see how under any circumstances that a resource failed to close would be generated on that line. I'm at a lost to explain how or why that error message would be generated there. Any ideas?

1 Answers

After thinking about this, I've come to the conclusion that the problem doesn't have anything to do with the line "defaultProperties.load(is)" causing the warning. Although the message is always generated the second time that line is called, my current thought is that the problem is happening elsewhere but when this line gets called it's probably yielding to some other VM related thread time to process, and that process is detecting that some resource failed to close. I'm concluding that the problem is related to something altogether different and calling that line is the time when the problem surfaces, but it's not what's causing the problem.

Related