@@ -478,25 +478,30 @@ public UsageTrackingInternalConnection create() {
478
478
479
479
@ Override
480
480
public void close (final UsageTrackingInternalConnection connection ) {
481
+ if (!closed ) {
482
+ connectionPoolListener .connectionRemoved (new ConnectionEvent (getId (connection )));
483
+ }
484
+ if (LOGGER .isInfoEnabled ()) {
485
+ LOGGER .info (format ("Closed connection [%s] to %s because %s." , getId (connection ), serverId .getAddress (),
486
+ getReasonForClosing (connection )));
487
+ }
488
+ connection .close ();
489
+ }
490
+
491
+ private String getReasonForClosing (final UsageTrackingInternalConnection connection ) {
481
492
String reason ;
482
- if (fromPreviousGeneration (connection )) {
493
+ if (connection .isClosed ()) {
494
+ reason = "there was a socket exception raised by this connection" ;
495
+ } else if (fromPreviousGeneration (connection )) {
483
496
reason = "there was a socket exception raised on another connection from this pool" ;
484
497
} else if (pastMaxLifeTime (connection )) {
485
498
reason = "it is past its maximum allowed life time" ;
486
499
} else if (pastMaxIdleTime (connection )) {
487
500
reason = "it is past its maximum allowed idle time" ;
488
- } else if (connection .isClosed ()) {
489
- reason = "the underlying connection was closed" ;
490
501
} else {
491
502
reason = "the pool has been closed" ;
492
503
}
493
- if (!closed ) {
494
- connectionPoolListener .connectionRemoved (new ConnectionEvent (getId (connection )));
495
- }
496
- if (LOGGER .isInfoEnabled ()) {
497
- LOGGER .info (format ("Closed connection [%s] to %s because %s." , getId (connection ), serverId .getAddress (), reason ));
498
- }
499
- connection .close ();
504
+ return reason ;
500
505
}
501
506
502
507
@ Override
0 commit comments