You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by "Andrew Gaul (JIRA)" <ji...@apache.org> on 2015/03/31 00:27:53 UTC
[jira] [Resolved] (JCLOUDS-874) IllegalArgumentException while
setting incorrect MD5
[ https://issues.apache.org/jira/browse/JCLOUDS-874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrew Gaul resolved JCLOUDS-874.
---------------------------------
Resolution: Invalid
Assignee: Andrew Gaul
You should expect this behavior since UTF_16 includes a byte-order mark to distinguish between big and little endian:
{code}
String fakeHash = "fakehash";
byte[] blobHash = fakeHash.getBytes(StandardCharsets.UTF_16);
System.out.println("array: " + Arrays.toString(blobHash));
array: [-2, -1, 0, 102, 0, 97, 0, 107, 0, 101, 0, 104, 0, 97, 0, 115, 0, 104]
{code}
> IllegalArgumentException while setting incorrect MD5
> ----------------------------------------------------
>
> Key: JCLOUDS-874
> URL: https://issues.apache.org/jira/browse/JCLOUDS-874
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-blobstore
> Affects Versions: 1.9.0
> Reporter: Shri Javadekar
> Assignee: Andrew Gaul
> Priority: Minor
>
> I had a negative test case that would set the incorrect md5 checksum of a blob. After upgrade to jclouds-1.9.0, this test fails with an IllegalArgumentException with a message that the md5 checksum should be 128 bytes long but is 144 bytes.
> Here's the code for the test:
> {code:title=TestIncorrectMD5.java|borderStyle=solid}
> // Create a blob and set the incorrect md5 checksum
> public void testIncorrectMd5() throws Exception {
> {
> String blobName = "test";
> ByteSource input = ByteSource.wrap("testdata".getBytes(
> StandardCharsets.UTF_8));
> String fakeHash = "fakehash";
> byte[] blobHash = fakeHash.getBytes(Charsets.UTF_16);
> blobStore.blobBuilder(blobName)
> .payload(input)
> .contentLength(input.size())
> .contentMD5(HashCode.fromBytes(blobHash))
> .build();
> }
> {code}
> I wonder if computing of the HashCode has changed. If changed the fakeHash String from "fakehash" to "fakehas", the test worked fine.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)