> @@ -202,9 +203,18 @@ public String putBlob(final String containerName, final 
> Blob blob) throws IOExce
>           Files.createParentDirs(outputFile);
>           his = new HashingInputStream(Hashing.md5(), payload.openStream());
>           Files.asByteSink(outputFile).writeFrom(his);
> -         payload.getContentMetadata().setContentMD5(his.hash().asBytes());
> -         String eTag = 
> base16().lowerCase().encode(payload.getContentMetadata().getContentMD5());
> -         return eTag;
> +         HashCode actualHashCode = his.hash();
> +         byte[] expectedHashCodeBytes = 
> payload.getContentMetadata().getContentMD5();
> +         if (expectedHashCodeBytes != null) {
> +            HashCode expectedHashCode = 
> HashCode.fromBytes(expectedHashCodeBytes);
> +            if (!actualHashCode.equals(expectedHashCode)) {
> +               throw new IOException("MD5 hash code mismatch, actual: " + 
> actualHashCode +
> +                     " expected: " + expectedHashCode);
> +            }
> +         }
> +         byte[] actualHashCodeBytes = actualHashCode.asBytes();
> +         payload.getContentMetadata().setContentMD5(actualHashCodeBytes);

> Agree that we should not need to call setContentMD5 at all.

What happens if we take it out. Test failures?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/382/files#r13116608

Reply via email to