From c5a1c53e5ccbe93d2f20adc160502a19014d179f Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 24 Oct 2024 14:02:04 +0200 Subject: [PATCH] [MNG-8339] An error during transfer output seems to freeze the output (#1842) --- .../maven/cli/transfer/ConsoleMavenTransferListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java index 52635772f7..0331d27e86 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java @@ -80,8 +80,9 @@ public class ConsoleMavenTransferListener extends AbstractMavenTransferListener Iterator entries = transfers.values().iterator(); while (entries.hasNext()) { TransferResourceAndSize entry = entries.next(); - long total = entry.resource.getContentLength(); - Long complete = entry.transferredBytes; + // just in case, make sure 0 <= complete <= total + long complete = Math.max(0, entry.transferredBytes); + long total = Math.max(complete, entry.resource.getContentLength()); String resourceName = entry.resource.getResourceName();