From d1a2bf2ffbf3aa9ee57cd8cb4022355b9b50dd0e Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 20 Aug 2020 15:14:35 -0400 Subject: [PATCH 1/2] =?UTF-8?q?RemoteInvocationHandler.reportStats=20LogRe?= =?UTF-8?q?cord=E2=80=99s=20could=20get=20mangled=20during=20serialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remoting/RemoteInvocationHandler.java | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/src/main/java/hudson/remoting/RemoteInvocationHandler.java b/src/main/java/hudson/remoting/RemoteInvocationHandler.java index a3db551a3..046a74ad4 100644 --- a/src/main/java/hudson/remoting/RemoteInvocationHandler.java +++ b/src/main/java/hudson/remoting/RemoteInvocationHandler.java @@ -703,13 +703,12 @@ private void reportStats() { double tStd = tCount <= 0 || tVarTimesCount < 0 ? 0 : Math.sqrt(tVarTimesCount / tCount); Level targetLevel = m15Avg > 100 ? Level.INFO : m15Avg > 50 ? Level.FINE : Level.FINER; if (logger.isLoggable(targetLevel)) { - logger.log(targetLevel, "rate(1min) = {0,number,0.0}±{1,number,0.0}/sec; " - + "rate(5min) = {2,number,0.0}±{3,number,0.0}/sec; " - + "rate(15min) = {4,number,0.0}±{5,number,0.0}/sec; " - + "rate(total) = {6,number,0.0}±{7,number,0.0}/sec; N = {8,number}", - new Object[]{ + logger.log(targetLevel, () -> String.format("rate(1min) = %.1f±%.1f/sec; " + + "rate(5min) = %.1f±%.1f/sec; " + + "rate(15min) = %.1f±%.1f/sec; " + + "rate(total) = %.1f±%.1f/sec; N = %d", m1Avg, m1Std, m5Avg, m5Std, m15Avg, m15Std, tAvg, tStd, tCount - }); + )); } if (tCount < 10L) { // less than 10 reports is too soon to start alerting the user @@ -719,63 +718,63 @@ private void reportStats() { if (m15Std > 1 && 100 < m15Avg - 2 * m15Std) { if (tStd > 1 && 100 < tAvg - 2 * tStd) { logger.log(Level.SEVERE, - retainOrigin ? - "The all time average rate is {0,number,0.0}±{1,number,0.0}/sec. " - + "The 15 minute average rate is {2,number,0.0}±{3,number,0.0}/sec. " + String.format(retainOrigin ? + "The all time average rate is %.1f±%.1f/sec. " + + "The 15 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level both are above 100.0/sec. " + "If this message is repeated often in the logs then PLEASE " - + "seriously consider setting system property ''hudson.remoting" - + ".RemoteInvocationHandler.Unexporter.retainOrigin'' to " - + "''false'' to trade debug diagnostics for reduced memory " + + "seriously consider setting system property 'hudson.remoting" + + ".RemoteInvocationHandler.Unexporter.retainOrigin' to " + + "'false' to trade debug diagnostics for reduced memory " + "pressure." - : "The all time average rate is {0,number,0.0}±{1,number,0.0}/sec. " - + "The 15 minute average rate is {2,number,0.0}±{3,number,0.0}/sec. " + : "The all time average rate is %.1f±%.1f/sec. " + + "The 15 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level both are above 100.0/sec. ", - new Object[]{tAvg, tStd, m15Avg, m15Std}); + tAvg, tStd, m15Avg, m15Std)); return; } logger.log(Level.WARNING, - retainOrigin ? - "The 15 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + String.format(retainOrigin ? + "The 15 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. " + "If this message is repeated often in the logs then very " - + "seriously consider setting system property ''hudson.remoting" - + ".RemoteInvocationHandler.Unexporter.retainOrigin'' to " - + "''false'' to trade debug diagnostics for reduced memory " + + "seriously consider setting system property 'hudson.remoting" + + ".RemoteInvocationHandler.Unexporter.retainOrigin' to " + + "'false' to trade debug diagnostics for reduced memory " + "pressure." - : "The 15 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + : "The 15 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. ", - new Object[]{m15Avg, m15Std}); + m15Avg, m15Std)); return; } if (m5Std > 1 && 100 < m5Avg - 2 * m5Std) { logger.log(Level.WARNING, - retainOrigin ? - "The 5 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + String.format(retainOrigin ? + "The 5 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. " + "If this message is repeated often in the logs then " - + "seriously consider setting system property ''hudson.remoting" - + ".RemoteInvocationHandler.Unexporter.retainOrigin'' to " - + "''false'' to trade debug diagnostics for reduced memory " + + "seriously consider setting system property 'hudson.remoting" + + ".RemoteInvocationHandler.Unexporter.retainOrigin' to " + + "'false' to trade debug diagnostics for reduced memory " + "pressure." - : "The 5 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + : "The 5 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. ", - new Object[]{m5Avg, m5Std}); + m5Avg, m5Std)); return; } if (m1Std > 1 && 100 < m1Avg - 2 * m1Std) { logger.log(Level.INFO, - retainOrigin ? - "The 1 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + String.format(retainOrigin ? + "The 1 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. " + "If this message is repeated often in the logs then " - + "consider setting system property ''hudson.remoting" - + ".RemoteInvocationHandler.Unexporter.retainOrigin'' to " - + "''false'' to trade debug diagnostics for reduced memory " + + "consider setting system property 'hudson.remoting" + + ".RemoteInvocationHandler.Unexporter.retainOrigin' to " + + "'false' to trade debug diagnostics for reduced memory " + "pressure." - : "The 1 minute average rate is {0,number,0.0}±{1,number,0.0}/sec. " + : "The 1 minute average rate is %.1f±%.1f/sec. " + "At the 95% confidence level this is above 100.0/sec. ", - new Object[]{m1Avg, m1Std}); + m1Avg, m1Std)); return; } } From fd3cd2b47fe2edd2441d04709fa765dfd1722567 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 20 Aug 2020 15:18:22 -0400 Subject: [PATCH 2/2] Forgotten escape of % --- .../java/hudson/remoting/RemoteInvocationHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/remoting/RemoteInvocationHandler.java b/src/main/java/hudson/remoting/RemoteInvocationHandler.java index 046a74ad4..e1176136d 100644 --- a/src/main/java/hudson/remoting/RemoteInvocationHandler.java +++ b/src/main/java/hudson/remoting/RemoteInvocationHandler.java @@ -729,7 +729,7 @@ private void reportStats() { + "pressure." : "The all time average rate is %.1f±%.1f/sec. " + "The 15 minute average rate is %.1f±%.1f/sec. " - + "At the 95% confidence level both are above 100.0/sec. ", + + "At the 95%% confidence level both are above 100.0/sec. ", tAvg, tStd, m15Avg, m15Std)); return; } @@ -743,7 +743,7 @@ private void reportStats() { + "'false' to trade debug diagnostics for reduced memory " + "pressure." : "The 15 minute average rate is %.1f±%.1f/sec. " - + "At the 95% confidence level this is above 100.0/sec. ", + + "At the 95%% confidence level this is above 100.0/sec. ", m15Avg, m15Std)); return; } @@ -758,7 +758,7 @@ private void reportStats() { + "'false' to trade debug diagnostics for reduced memory " + "pressure." : "The 5 minute average rate is %.1f±%.1f/sec. " - + "At the 95% confidence level this is above 100.0/sec. ", + + "At the 95%% confidence level this is above 100.0/sec. ", m5Avg, m5Std)); return; } @@ -773,7 +773,7 @@ private void reportStats() { + "'false' to trade debug diagnostics for reduced memory " + "pressure." : "The 1 minute average rate is %.1f±%.1f/sec. " - + "At the 95% confidence level this is above 100.0/sec. ", + + "At the 95%% confidence level this is above 100.0/sec. ", m1Avg, m1Std)); return; }