From e9da7b9323b8713969062cc021d6455f1325c95b Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 24 Oct 2023 19:14:24 -0400 Subject: [PATCH 1/2] Avoid capturing `Request` in `LogRecord` parameters --- src/main/java/hudson/remoting/Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/hudson/remoting/Request.java b/src/main/java/hudson/remoting/Request.java index e2be7092f..d7e421076 100644 --- a/src/main/java/hudson/remoting/Request.java +++ b/src/main/java/hudson/remoting/Request.java @@ -393,7 +393,7 @@ public void run() { // this means the caller will block forever if (e instanceof ChannelClosedException && !logger.isLoggable(Level.FINE)) { // TODO if this is from CloseCommand reduce level to FINE - logger.log(Level.INFO, "Failed to send back a reply to the request {0}: {1}", new Object[] {Request.this, e}); + logger.info("Failed to send back a reply to the request " + Request.this + ": " + e); } else { logger.log(Level.WARNING, e, () -> "Failed to send back a reply to the request " + Request.this); } From d3e7ac53a26491dc0b30eb4e5ac7a8250ff7ffef Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 24 Oct 2023 19:18:03 -0400 Subject: [PATCH 2/2] Can also use `Supplier` overload though it is almost purely stylistic for `INFO` and above --- src/main/java/hudson/remoting/Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/hudson/remoting/Request.java b/src/main/java/hudson/remoting/Request.java index d7e421076..aac12fb01 100644 --- a/src/main/java/hudson/remoting/Request.java +++ b/src/main/java/hudson/remoting/Request.java @@ -393,7 +393,7 @@ public void run() { // this means the caller will block forever if (e instanceof ChannelClosedException && !logger.isLoggable(Level.FINE)) { // TODO if this is from CloseCommand reduce level to FINE - logger.info("Failed to send back a reply to the request " + Request.this + ": " + e); + logger.info(() -> "Failed to send back a reply to the request " + Request.this + ": " + e); } else { logger.log(Level.WARNING, e, () -> "Failed to send back a reply to the request " + Request.this); }