This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant-ivy.git


The following commit(s) were added to refs/heads/master by this push:
     new 309dba8  Include the content length header value and the downloaded 
file size, in the exception that gets thrown if they don't match
309dba8 is described below

commit 309dba82b59db8d6e8522db69fa20b64235a91e1
Author: Jaikiran Pai <jaiki...@apache.org>
AuthorDate: Tue May 28 12:09:04 2019 +0530

    Include the content length header value and the downloaded file size, in 
the exception that gets thrown if they don't match
---
 src/java/org/apache/ivy/util/url/BasicURLHandler.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/java/org/apache/ivy/util/url/BasicURLHandler.java 
b/src/java/org/apache/ivy/util/url/BasicURLHandler.java
index e303dd7..10e66c6 100644
--- a/src/java/org/apache/ivy/util/url/BasicURLHandler.java
+++ b/src/java/org/apache/ivy/util/url/BasicURLHandler.java
@@ -261,12 +261,13 @@ public class BasicURLHandler extends AbstractURLHandler 
implements TimeoutConstr
 
             // check content length only if content was not encoded
             if (srcConn.getContentEncoding() == null) {
-                int contentLength = srcConn.getContentLength();
-                if (contentLength != -1 && dest.length() != contentLength) {
+                final int contentLength = srcConn.getContentLength();
+                final long destFileSize = dest.length();
+                if (contentLength != -1 && destFileSize != contentLength) {
                     dest.delete();
                     throw new IOException(
-                            "Downloaded file size doesn't match expected 
Content Length for " + normalizedURL
-                                    + ". Please retry.");
+                            "Downloaded file size (" + destFileSize + ") 
doesn't match expected " +
+                                    "Content Length (" + contentLength + ") 
for " + normalizedURL + ". Please retry.");
                 }
             }
 

Reply via email to