BlobContainer::setContainerMetadata() sets keys to lowercase
Brought to you by:
yvesyang
BlobContainer::setContainerMetadata() sets keys within NameValueCollection objMetadata when stored in cloud.
For example, "createBy" becomes "createby", when returned after getting Blob Container and reading NameValueCollection metadata from ContainerProperties.
According to document at
http://msdn.microsoft.com/en-us/library/dd179404.aspx,
Names are case-insensitive. If two or more headers with the same name are
submitted for a resource, the headers will be combined into a single header
with a comma delimiting each value.
The total size of the metadata, including both the name and value
together, may not exceed 8 KB in size.
Metadata name/value pairs are valid HTTP headers, and so they adhere to
all restrictions governing HTTP headers.
Thereby,
MetadataContainer.get( "createBy" ) will return null, because it does not exist. That is because key was renamed to "createby".
I have add a JUnit pertaining to this issue.
If Names are case-insensitive, then should not all of the following return the same value?:
NameValueCollection::get( "createBy" )
NameValueCollection::get( "createby" )
NameValueCollection::get( "CREATEDBY" )
If this is the case, then there is still a bug, because only lowercase is returning a value.
NameValueCollection::get( "createby" );
The fix would be for NameValueCollection::get( String strName ) to treat strName as case-insensitive, and not expect the SDK user to change strName to lowercase.
I think there is some misunderstanding. You should verify
assertEquals( "Window Azure SDK for Java",objMetadataPost.getSingleValue("createdBy") );
assertEquals( "Window Azure SDK for Java",objMetadataPost.getSingleValue("createdby") );
assertEquals( "Window Azure SDK for Java",objMetadataPost.getSingleValue("CREATEDBY") );
Instead of verifying
assertTrue(objMetadataPost.containsKey("createdBy"));
Updated JUnit test
Problem varified with new test:
String strValue = null;
strValue = objMetadataPost.getSingleValue("createdBy");
assertNotNull(strValue);
assertEquals( "Window Azure SDK for Java",strValue );
strValue = objMetadataPost.getSingleValue("CREATEDBY");
assertNotNull(strValue);
assertEquals( "Window Azure SDK for Java",strValue );
strValue = objMetadataPost.getSingleValue("createdby");
assertNotNull(strValue);
assertEquals( "Window Azure SDK for Java",strValue );
already fixed
The issue is not fixed in the latest version available in the SVN.