mirror of https://github.com/apache/jclouds.git
Removed dependence on Java 6 when copying S3Object MD5 data -- and tested
git-svn-id: http://jclouds.googlecode.com/svn/trunk@817 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
0ad7ca2138
commit
d667c6e562
|
@ -216,14 +216,21 @@ public class S3Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMd5(byte[] md5) {
|
public void setMd5(byte[] md5) {
|
||||||
this.md5 = Arrays.copyOf(md5, md5.length);
|
this.md5 = new byte[md5.length];
|
||||||
|
System.arraycopy(md5, 0, this.md5, 0, md5.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the md5 value stored in the Etag header returned by S3.
|
* @return the md5 value stored in the Etag header returned by S3.
|
||||||
*/
|
*/
|
||||||
public byte[] getMd5() {
|
public byte[] getMd5() {
|
||||||
return (md5 == null) ? null : Arrays.copyOf(md5, md5.length);
|
if (md5 != null) {
|
||||||
|
byte[] retval = new byte[md5.length];
|
||||||
|
System.arraycopy(this.md5, 0, retval, 0, md5.length);
|
||||||
|
return retval;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserMetadata(Multimap<String, String> userMetadata) {
|
public void setUserMetadata(Multimap<String, String> userMetadata) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ package org.jclouds.aws.s3.domain;
|
||||||
|
|
||||||
import org.jclouds.http.ContentTypes;
|
import org.jclouds.http.ContentTypes;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotSame;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -40,4 +41,14 @@ public class S3ObjectTest {
|
||||||
assertEquals(object.getMetadata().getContentType(),
|
assertEquals(object.getMetadata().getContentType(),
|
||||||
ContentTypes.BINARY);
|
ContentTypes.BINARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMd5CopyingNotReference() {
|
||||||
|
byte[] md5 = new byte[12];
|
||||||
|
S3Object object = new S3Object("test");
|
||||||
|
object.getMetadata().setMd5(md5);
|
||||||
|
byte[] returnedMd5 = object.getMetadata().getMd5();
|
||||||
|
assertNotSame(md5, returnedMd5);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue