HikariCP icon indicating copy to clipboard operation
HikariCP copied to clipboard

Why use conn twice?

Open reallinxu opened this issue 1 year ago • 0 comments

void quietlyCloseConnection(final Connection connection, final String closureReason)
   {
      if (connection != null) {
         try {
            logger.debug("{} - Closing connection {}: {}", poolName, connection, closureReason);

            // continue with the close even if setNetworkTimeout() throws
            try (connection; connection) {
               if (!connection.isClosed())
                  setNetworkTimeout(connection, SECONDS.toMillis(15));
               } catch (SQLException e) {
                  // ignore
            }
         }
         catch (Exception e) {
            logger.debug("{} - Closing connection {} failed", poolName, connection, e);
         }
      }
   }

try (connection; connection)
Why use conn twice?

reallinxu avatar Aug 09 '22 09:08 reallinxu