[jira] [Commented] (JCLOUDS-1580) BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud provider returns lowercase metadata headers

2021-06-22 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/JCLOUDS-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17367793#comment-17367793
 ] 

ASF subversion and git services commented on JCLOUDS-1580:
--

Commit 2791f470466493a3f10ce0d4fb53416056d407cc in jclouds's branch 
refs/heads/master from i831992
[ https://gitbox.apache.org/repos/asf?p=jclouds.git;h=2791f47 ]

JCLOUDS-1580 - Add support for lowercase metadata headers

The issue happens if a cloud provider returns lowercase metadata headers, for 
example: "x-object-meta-apiversion" instead of "X-Object-Meta-ApiVersion"

In that case, BlobStore.blobMetadata(CONTAINER, PATH).getUserMetadata()
incorrectly returns an empty map.

This happens because the code is looking for the exact String "-Meta-" 
(case-sensitive).

This checkin allows to handle metadata headers of any case, and also adds a 
unit test for that situation.


> BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud 
> provider returns lowercase metadata headers
> ---
>
> Key: JCLOUDS-1580
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1580
> Project: jclouds
>  Issue Type: Bug
>  Components: jclouds-blobstore
>Affects Versions: 2.3.0
>Reporter: Erik Ebert
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> I believe this is happening because jclouds/swift is specifically looking for 
> user metadata with the prefix "X-Object-Meta-", case SENSITIVE:
> X-Object-Meta-foo
>  
> But since header names are case-INSENSITIVE. per RFC 2616, this fails if the 
> cloud provider returns header names in lower case: 
> x-object-meta-foo
>  
> I discovered this while using "openstack-swift" to access SAP's Converged 
> Cloud, but it would affect any cloud provider that returns lower-case header 
> names.   
>  
> In my case, this is an example of what is returned by Converged Cloud:
> curl  --head -H "X-Auth-Token:"
> HTTP/1.1 200 OK
>  content-type: application/octet-stream
>  *x-object-meta-original-created-time*: 1623984822180
>  *x-object-meta-content-md5*: rREHajOaHzUiU8DQoap9NA==
>  etag: x
>  last-modified: Fri, 18 Jun 2021 02:53:53 GMT
>  x-timestamp: 1623984832.86825
>  accept-ranges: bytes
>  content-length: 12
>  x-trans-id: 
>  x-openstack-request-id: x
>  date: Fri, 18 Jun 2021 03:16:46 GMT
>  
> Sample jclouds code:
>  
> {code:java}
> BlobStoreContext blobStoreContext =
>  ContextBuilder.newBuilder("openstack-swift")
>  .endpoint(ENDPOINT)
>  .credentials(INDENTITY, CREDENTIAL)
>  .overrides(overrides)
>  .buildApi(BlobStoreContext.class);
> BlobStore blobStore = blobStoreContext.getBlobStore();
> BlobMetadata blobMetadata = blobStore.blobMetadata(CONTAINER, PATH);
> Map userMetadata = blobMetadata.getUserMetadata()
> System.out.println(userMetadata.toString())
>  
> {code}
>  
> blobMetadata.getUserMetadata() SHOULD return something like:
> *original-created-time*: 1623984822180
>  *content-md5*: rREHajOaHzUiU8DQoap9NA==
> (or similar), but instead it returns an empty Map object.
>  
> Stepping through the code, I believe the source of the problem is line 41 of  
> EntriesWithoutMetaPrefix.java:
> [https://github.com/apache/jclouds/blob/0b89ee0825d45de1193090cdd5efc5f1135fa200/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java]
>  
> Partial stack trace from the code example above:
> {code:java}
>     at 
> org.jclouds.openstack.swift.v1.functions.EntriesWithoutMetaPrefix.apply(EntriesWithoutMetaPrefix.java:41)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:81)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:41)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
>    at 
> org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
>    at 
> com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:86)
>    at com.sun.proxy.$Proxy199.getWithoutBody(Unknown Source:-1)
> {code}
>  
> I believe the fix would be to change line 41 of EntriesWithoutMetaPrefix.java 
> from
> int index = header.getKey().indexOf("\-Meta\-");
> to something like:
> int index = header.getKey()*.toLowerCase()*.indexOf("*\-meta\-*");
>  
> {code:java}
>  41c41
> <       int index = header.getKey().indexOf("-Meta-");
> ---
> >       int index = header.getKey().toLowerCase().indexOf("-meta-");
> {code}



--
This message 

[jira] [Commented] (JCLOUDS-1580) BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud provider returns lowercase metadata headers

2021-06-22 Thread Erik Ebert (Jira)


[ 
https://issues.apache.org/jira/browse/JCLOUDS-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17367783#comment-17367783
 ] 

Erik Ebert commented on JCLOUDS-1580:
-

[~gaul]   I've created this pull request: 
[https://github.com/apache/jclouds/pull/106]

I did my best to read the documentation, but this is my first time contributing 
to jclouds, so I'm not too familiar with the proper procedure.   I tried to err 
on the side of being verbose.   Please be kind.  :)

> BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud 
> provider returns lowercase metadata headers
> ---
>
> Key: JCLOUDS-1580
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1580
> Project: jclouds
>  Issue Type: Bug
>  Components: jclouds-blobstore
>Affects Versions: 2.3.0
>Reporter: Erik Ebert
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> I believe this is happening because jclouds/swift is specifically looking for 
> user metadata with the prefix "X-Object-Meta-", case SENSITIVE:
> X-Object-Meta-foo
>  
> But since header names are case-INSENSITIVE. per RFC 2616, this fails if the 
> cloud provider returns header names in lower case: 
> x-object-meta-foo
>  
> I discovered this while using "openstack-swift" to access SAP's Converged 
> Cloud, but it would affect any cloud provider that returns lower-case header 
> names.   
>  
> In my case, this is an example of what is returned by Converged Cloud:
> curl  --head -H "X-Auth-Token:"
> HTTP/1.1 200 OK
>  content-type: application/octet-stream
>  *x-object-meta-original-created-time*: 1623984822180
>  *x-object-meta-content-md5*: rREHajOaHzUiU8DQoap9NA==
>  etag: x
>  last-modified: Fri, 18 Jun 2021 02:53:53 GMT
>  x-timestamp: 1623984832.86825
>  accept-ranges: bytes
>  content-length: 12
>  x-trans-id: 
>  x-openstack-request-id: x
>  date: Fri, 18 Jun 2021 03:16:46 GMT
>  
> Sample jclouds code:
>  
> {code:java}
> BlobStoreContext blobStoreContext =
>  ContextBuilder.newBuilder("openstack-swift")
>  .endpoint(ENDPOINT)
>  .credentials(INDENTITY, CREDENTIAL)
>  .overrides(overrides)
>  .buildApi(BlobStoreContext.class);
> BlobStore blobStore = blobStoreContext.getBlobStore();
> BlobMetadata blobMetadata = blobStore.blobMetadata(CONTAINER, PATH);
> Map userMetadata = blobMetadata.getUserMetadata()
> System.out.println(userMetadata.toString())
>  
> {code}
>  
> blobMetadata.getUserMetadata() SHOULD return something like:
> *original-created-time*: 1623984822180
>  *content-md5*: rREHajOaHzUiU8DQoap9NA==
> (or similar), but instead it returns an empty Map object.
>  
> Stepping through the code, I believe the source of the problem is line 41 of  
> EntriesWithoutMetaPrefix.java:
> [https://github.com/apache/jclouds/blob/0b89ee0825d45de1193090cdd5efc5f1135fa200/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java]
>  
> Partial stack trace from the code example above:
> {code:java}
>     at 
> org.jclouds.openstack.swift.v1.functions.EntriesWithoutMetaPrefix.apply(EntriesWithoutMetaPrefix.java:41)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:81)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:41)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
>    at 
> org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
>    at 
> com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:86)
>    at com.sun.proxy.$Proxy199.getWithoutBody(Unknown Source:-1)
> {code}
>  
> I believe the fix would be to change line 41 of EntriesWithoutMetaPrefix.java 
> from
> int index = header.getKey().indexOf("\-Meta\-");
> to something like:
> int index = header.getKey()*.toLowerCase()*.indexOf("*\-meta\-*");
>  
> {code:java}
>  41c41
> <       int index = header.getKey().indexOf("-Meta-");
> ---
> >       int index = header.getKey().toLowerCase().indexOf("-meta-");
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (JCLOUDS-1580) BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud provider returns lowercase metadata headers

2021-06-19 Thread Andrew Gaul (Jira)


[ 
https://issues.apache.org/jira/browse/JCLOUDS-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17365931#comment-17365931
 ] 

Andrew Gaul commented on JCLOUDS-1580:
--

This sounds plausible.  Could you change the code and add a unit test to 
{{apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiMockTest.java}}
 and submit a pull request?

> BlobStore.blobMetadata().getUserMetadata() returns empty Map when cloud 
> provider returns lowercase metadata headers
> ---
>
> Key: JCLOUDS-1580
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1580
> Project: jclouds
>  Issue Type: Bug
>  Components: jclouds-blobstore
>Affects Versions: 2.3.0
>Reporter: Erik Ebert
>Priority: Major
>
> I believe this is happening because jclouds/swift is specifically looking for 
> user metadata with the prefix "X-Object-Meta-", case SENSITIVE:
> X-Object-Meta-foo
>  
> But since header names are case-INSENSITIVE. per RFC 2616, this fails if the 
> cloud provider returns header names in lower case: 
> x-object-meta-foo
>  
> I discovered this while using "openstack-swift" to access SAP's Converged 
> Cloud, but it would affect any cloud provider that returns lower-case header 
> names.   
>  
> In my case, this is an example of what is returned by Converged Cloud:
> curl  --head -H "X-Auth-Token:"
> HTTP/1.1 200 OK
>  content-type: application/octet-stream
>  *x-object-meta-original-created-time*: 1623984822180
>  *x-object-meta-content-md5*: rREHajOaHzUiU8DQoap9NA==
>  etag: x
>  last-modified: Fri, 18 Jun 2021 02:53:53 GMT
>  x-timestamp: 1623984832.86825
>  accept-ranges: bytes
>  content-length: 12
>  x-trans-id: 
>  x-openstack-request-id: x
>  date: Fri, 18 Jun 2021 03:16:46 GMT
>  
> Sample jclouds code:
>  
> {code:java}
> BlobStoreContext blobStoreContext =
>  ContextBuilder.newBuilder("openstack-swift")
>  .endpoint(ENDPOINT)
>  .credentials(INDENTITY, CREDENTIAL)
>  .overrides(overrides)
>  .buildApi(BlobStoreContext.class);
> BlobStore blobStore = blobStoreContext.getBlobStore();
> BlobMetadata blobMetadata = blobStore.blobMetadata(CONTAINER, PATH);
> Map userMetadata = blobMetadata.getUserMetadata()
> System.out.println(userMetadata.toString())
>  
> {code}
>  
> blobMetadata.getUserMetadata() SHOULD return something like:
> *original-created-time*: 1623984822180
>  *content-md5*: rREHajOaHzUiU8DQoap9NA==
> (or similar), but instead it returns an empty Map object.
>  
> Stepping through the code, I believe the source of the problem is line 41 of  
> EntriesWithoutMetaPrefix.java:
> [https://github.com/apache/jclouds/blob/0b89ee0825d45de1193090cdd5efc5f1135fa200/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/functions/EntriesWithoutMetaPrefix.java]
>  
> Partial stack trace from the code example above:
> {code:java}
>     at 
> org.jclouds.openstack.swift.v1.functions.EntriesWithoutMetaPrefix.apply(EntriesWithoutMetaPrefix.java:41)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:81)
>    at 
> org.jclouds.openstack.swift.v1.functions.ParseObjectFromResponse.apply(ParseObjectFromResponse.java:41)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
>    at 
> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
>    at 
> org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
>    at 
> com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:86)
>    at com.sun.proxy.$Proxy199.getWithoutBody(Unknown Source:-1)
> {code}
>  
> I believe the fix would be to change line 41 of EntriesWithoutMetaPrefix.java 
> from
> int index = header.getKey().indexOf("\-Meta\-");
> to something like:
> int index = header.getKey()*.toLowerCase()*.indexOf("*\-meta\-*");
>  
> {code:java}
>  41c41
> <       int index = header.getKey().indexOf("-Meta-");
> ---
> >       int index = header.getKey().toLowerCase().indexOf("-meta-");
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)