Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-38733

Sql service is leaky

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.x
    • Fix Version/s: 2.6.x
    • Component/s: Kernel
    • Labels:
      None
    • Previous Issue Keys:
      KNL-354

      Description

      Hi David,

      Thanks for doing this quickly. Find enclosed 5 resource leaks under
      Exceptional conditions. If you stop catching Exception in Finally then
      Eclipse can probably point to a few more SQLException locations. I suspect
      there are more issues, so will review again in M3. Please place under
      sak-17647

      Also thanks for pointing out the throws SQLException pattern

      – Alan Alan Berg Interim QA Director - The Sakai Foundation Senior Developer / Quality Assurance Group Education and Research Services Central Computer Services University of Amsterdam http://home.uva.nl/a.m.berg

      db.txt

      [1] BasicSqalService
      Line 591 (see http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html#close() )
      If result.close thorws an SQLException then pstmt.close is not called

      if (null != result) result.close();
      if (null != pstmt) pstmt.close();

      [2] Line 935

      if (null != result) result.close();
      if (null != pstmt) pstmt.close();
      if (null != conn)

      [3] Line 1589

      if (null != result) result.close();
      if (null != stmt) stmt.close();
      if (null != conn)

      [4] Please review I believe at the least os may not be closed properly under Exception Line 1558

      try

      { // Use reflection to remove compile time dependency on oracle driver Class[] paramsClasses = new Class[0]; Method getBinaryOutputStreamMethod = blob.getClass().getMethod("getBinaryOutputStream", paramsClasses); Object[] params = new Object[0]; os = (OutputStream) getBinaryOutputStreamMethod.invoke(blob, params); os.write(content); os.close(); }

      catch (NoSuchMethodException ex)

      { LOG.warn("Oracle driver error: " + ex); }

      catch (IllegalAccessException ex)

      { LOG.warn("Oracle driver error: " + ex); }

      catch (InvocationTargetException ex)

      { LOG.warn("Oracle driver error: " + ex); }

      [5] Please review 1687 at the least

      if (null != result) result.close();
      if (null != stmt) stmt.close();

      try
      {
      // close the result and statement
      if (null != result) result.close();
      if (null != stmt) stmt.close();

      // if we are failing, restore and release the connectoin
      if ((closeConn) && (conn != null))

      { // just in case we got a lock conn.rollback(); if (resetAutoCommit) conn.setAutoCommit(autoCommit); returnConnection(conn); conn = null; }

      }
      catch (Exception e)

      { LOG.warn("Sql.dbReadLock(): " + e); }

      }

        Gliffy Diagrams

          Zeplin

            Attachments

              Issue Links

                Activity

                  People

                  Assignee:
                  dhorwitz David Horwitz
                  Reporter:
                  dhorwitz David Horwitz
                  Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                    Dates

                    Created:
                    Updated:
                    Resolved:

                      Git Integration