You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@manifoldcf.apache.org by "Cihad Guzel (JIRA)" <ji...@apache.org> on 2019/03/03 11:24:00 UTC

[jira] [Created] (CONNECTORS-1590) Resources should be closed in a finally block

Cihad Guzel created CONNECTORS-1590:
---------------------------------------

             Summary: Resources should be closed in a finally block
                 Key: CONNECTORS-1590
                 URL: https://issues.apache.org/jira/browse/CONNECTORS-1590
             Project: ManifoldCF
          Issue Type: Bug
          Components: Framework core
    Affects Versions: ManifoldCF 2.12
            Reporter: Cihad Guzel
             Fix For: ManifoldCF 2.13


{code:java}
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();
      }
{code}
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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)