Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8296273

try-with-resources not close AutoCloseable in finally block, but end of try

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      try(Connection conn = this.ds.getConnection()){
      }
      is translated to below code after decompiling class
      try {
                  Connection conn = ds.getConnection();
      ......
                  if (conn != null) {
                      conn.close();
                  }
      }


      A DESCRIPTION OF THE PROBLEM :
      I found the Apache JDBC pool exhausted quickly when there were lots of JDBC query/update exceptions, then I decompiled the code and found above problem. The "conn.close() is in try but not in finally block of the auto generated code.
      Even the AutoCloseable would be closed after scope end in exception, but not guaranteed immediately, which is a bug when lots of exceptions happen continuously, and caused my problem above.


      FREQUENCY : always


            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: