tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 48643] New: catalina.session.FileStore.save() and load() - close() bugs
Date Sun, 31 Jan 2010 00:53:05 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=48643

           Summary: catalina.session.FileStore.save() and load() - close()
                    bugs
           Product: Tomcat 7
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: sebb@apache.org


The code for the save() method reads:

try {
    fos = new FileOutputStream(file.getAbsolutePath());
    oos = new ObjectOutputStream(new BufferedOutputStream(fos));
} catch (IOException e) {
    if (oos != null) { <== oos can only be null here
        try {
            oos.close();
        } catch (IOException f) {
            // Ignore
        }
    }
    throw e;
}

Presumably the catch statement should try to close fos instead?

Similarly for the load() method; at line 280/281 there is the code:

        } catch (IOException e) {
            if (ois != null) {

However, ois is the last object created by the try clause, so must be null.
Probably the code should check and close bis and/or fis.

At the end of the load() method, the code says:

            // Close the input stream
            if (ois != null) {

However, ois cannot be null at that point.

Note: these bugs were detected by the Eclipse compiler.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message