Skip to content

Commit 44c1879

Browse files
committed
Use info log level for AlreadyClosedException
We're better off making these exceptions less noisy than avoiding them, as there are happen usually during transitions (shutdown, connection recovery). References #207 (cherry picked from commit de0c1ea)
1 parent 7021702 commit 44c1879

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/rabbitmq/perf/RelaxedExceptionHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018 Pivotal Software, Inc. All rights reserved.
1+
// Copyright (c) 2018-2019 Pivotal Software, Inc. All rights reserved.
22
//
33
// This software, the RabbitMQ Java client library, is triple-licensed under the
44
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2
@@ -15,6 +15,7 @@
1515

1616
package com.rabbitmq.perf;
1717

18+
import com.rabbitmq.client.AlreadyClosedException;
1819
import com.rabbitmq.client.impl.DefaultExceptionHandler;
1920
import org.slf4j.Logger;
2021
import org.slf4j.LoggerFactory;
@@ -30,6 +31,9 @@
3031
* closes the connection with a timeout. This can result in noisy logs,
3132
* which are not useful here, so this exception handler is a bit more
3233
* relaxed for those logs.
34+
* <p>
35+
* This exception handler is also less noisy with {@link AlreadyClosedException},
36+
* which can typically happen on shutdown or during connection recovery.
3337
*
3438
* @since 2.5.0
3539
*/
@@ -38,9 +42,13 @@ public class RelaxedExceptionHandler extends DefaultExceptionHandler {
3842
private static final Logger LOGGER = LoggerFactory.getLogger(RelaxedExceptionHandler.class);
3943

4044
private static boolean isSocketClosedOrConnectionReset(Throwable e) {
41-
return e instanceof IOException &&
45+
return (e instanceof IOException &&
4246
("Connection reset".equals(e.getMessage()) || "Socket closed".equals(e.getMessage()) ||
4347
"Connection reset by peer".equals(e.getMessage())
48+
)) ||
49+
(e instanceof AlreadyClosedException &&
50+
e.getMessage() != null &&
51+
e.getMessage().contains("connection is already closed due to clean connection shutdown")
4452
);
4553
}
4654

0 commit comments

Comments
 (0)