@@ -536,36 +536,33 @@ protected boolean pingConnection(PooledConnection conn) {
536
536
result = false ;
537
537
}
538
538
539
- if (result ) {
540
- if (poolPingEnabled ) {
541
- if (poolPingConnectionsNotUsedFor >= 0 && conn .getTimeElapsedSinceLastUse () > poolPingConnectionsNotUsedFor ) {
542
- try {
543
- if (log .isDebugEnabled ()) {
544
- log .debug ("Testing connection " + conn .getRealHashCode () + " ..." );
545
- }
546
- Connection realConn = conn .getRealConnection ();
547
- try (Statement statement = realConn .createStatement ()) {
548
- statement .executeQuery (poolPingQuery ).close ();
549
- }
550
- if (!realConn .getAutoCommit ()) {
551
- realConn .rollback ();
552
- }
553
- result = true ;
554
- if (log .isDebugEnabled ()) {
555
- log .debug ("Connection " + conn .getRealHashCode () + " is GOOD!" );
556
- }
557
- } catch (Exception e ) {
558
- log .warn ("Execution of ping query '" + poolPingQuery + "' failed: " + e .getMessage ());
559
- try {
560
- conn .getRealConnection ().close ();
561
- } catch (Exception e2 ) {
562
- //ignore
563
- }
564
- result = false ;
565
- if (log .isDebugEnabled ()) {
566
- log .debug ("Connection " + conn .getRealHashCode () + " is BAD: " + e .getMessage ());
567
- }
568
- }
539
+ if (result && poolPingEnabled && poolPingConnectionsNotUsedFor >= 0
540
+ && conn .getTimeElapsedSinceLastUse () > poolPingConnectionsNotUsedFor ) {
541
+ try {
542
+ if (log .isDebugEnabled ()) {
543
+ log .debug ("Testing connection " + conn .getRealHashCode () + " ..." );
544
+ }
545
+ Connection realConn = conn .getRealConnection ();
546
+ try (Statement statement = realConn .createStatement ()) {
547
+ statement .executeQuery (poolPingQuery ).close ();
548
+ }
549
+ if (!realConn .getAutoCommit ()) {
550
+ realConn .rollback ();
551
+ }
552
+ result = true ;
553
+ if (log .isDebugEnabled ()) {
554
+ log .debug ("Connection " + conn .getRealHashCode () + " is GOOD!" );
555
+ }
556
+ } catch (Exception e ) {
557
+ log .warn ("Execution of ping query '" + poolPingQuery + "' failed: " + e .getMessage ());
558
+ try {
559
+ conn .getRealConnection ().close ();
560
+ } catch (Exception e2 ) {
561
+ //ignore
562
+ }
563
+ result = false ;
564
+ if (log .isDebugEnabled ()) {
565
+ log .debug ("Connection " + conn .getRealHashCode () + " is BAD: " + e .getMessage ());
569
566
}
570
567
}
571
568
}
0 commit comments