From e1e9251867b2e308fe6eb20334b5f33f95323bed Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 9 May 2022 17:22:03 -0400 Subject: [PATCH] Suppress some uninteresting stack traces when channel is closed --- .../java/hudson/remoting/JarCacheSupport.java | 15 +++++++++------ src/main/java/hudson/remoting/UserRequest.java | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/hudson/remoting/JarCacheSupport.java b/src/main/java/hudson/remoting/JarCacheSupport.java index 974a2f6d3..5e6de7e26 100644 --- a/src/main/java/hudson/remoting/JarCacheSupport.java +++ b/src/main/java/hudson/remoting/JarCacheSupport.java @@ -123,18 +123,21 @@ public void run() { LOGGER.log(Level.WARNING, String.format("Interrupted while resolving a jar %016x%016x", sum1, sum2), e); Thread.currentThread().interrupt(); } catch (Throwable e) { - // in other general failures, we aren't retrying - // TODO: or should we? - promise.set(e); - - LOGGER.log(Level.WARNING, String.format("Failed to resolve a jar %016x%016x", sum1, sum2), e); + if (channel.isClosingOrClosed()) { + bailout(e); + } else { + // in other general failures, we aren't retrying + // TODO: or should we? + promise.set(e); + LOGGER.log(Level.WARNING, String.format("Failed to resolve a jar %016x%016x", sum1, sum2), e); + } } } /** * Report a failure of the retrieval and allows another thread to retry. */ - private void bailout(Exception e) { + private void bailout(Throwable e) { inprogress.remove(key); // this lets another thread to retry later promise.set(e); // then tell those who are waiting that we aborted } diff --git a/src/main/java/hudson/remoting/UserRequest.java b/src/main/java/hudson/remoting/UserRequest.java index 31eba5461..a981cc412 100644 --- a/src/main/java/hudson/remoting/UserRequest.java +++ b/src/main/java/hudson/remoting/UserRequest.java @@ -213,7 +213,7 @@ protected ResponseToUserRequest perform(Channel channel) throws EXC { Thread.currentThread().setContextClassLoader(old); } } catch (LinkageError e) { - LOGGER.log(Level.WARNING, "LinkageError while performing " + toString(), e); + LOGGER.log(channel.isClosingOrClosed() ? Level.FINE : Level.WARNING, "LinkageError while performing " + toString(), e); throw e; } finally { Channel.setCurrent(oldc);