Uploaded image for project: 'ManifoldCF'
  1. ManifoldCF
  2. CONNECTORS-1590

Resources should be closed in a finally block

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • ManifoldCF 2.12
    • ManifoldCF 2.13
    • Framework core
    • None

    Description

      public class DBInterfaceHSQLDB extends Database implements IDBInterface {
        ...
        try
            {
              Connection c = DriverManager.getConnection(_localUrl+databaseName,userName,password);
              Statement s = c.createStatement();
              s.execute("SHUTDOWN");
              c.close();
            }
            catch (Exception e)
            {
              // Never any exception!
              e.printStackTrace();
            }
      

      Connections that implement the Closeable interface or its super-interface, AutoCloseable, needs to be closed after use. That close call must be made in a finally block otherwise an exception could keep the call from being made.

      Attachments

        Activity

          People

            kwright@metacarta.com Karl Wright
            cguzel Cihad Guzel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: