From 5869a7482bdb8293002f3d599a45b89182502c89 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 1 Oct 2017 09:45:36 -0400 Subject: [PATCH] Maybe die before trying to log cause This commit reorders a maybe die check and a logging statement for the following reasons: - we should die as quickly as possible if the cause is fatal - we do not want the JVM to be so broken that when we try to log another exception is thrown (maybe another out of memory exception) and then the maybe die is never invoked - maybe die will log the cause anyway if the cause is fatal so we only need to log if the cause is not fatal --- .../org/elasticsearch/transport/netty4/Netty4Transport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java index f85330ef759..3b011ff4e40 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java @@ -321,8 +321,8 @@ public class Netty4Transport extends TcpTransport { listener.onResponse(channel); } else { final Throwable cause = f.cause(); - logger.error("write and flush on the network layer failed", cause); Netty4Utils.maybeDie(cause); + logger.error("write and flush on the network layer failed", cause); assert cause instanceof Exception; listener.onFailure((Exception) cause); }