You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Erik Paulsson <ep...@fedora-commons.org> on 2013/09/10 18:37:51 UTC

SwiftClient parse exception on '%' symbols

Hi all!

I'm new to the group and looking for a little help.  I'm using
*org.jclouds:jclouds-allblobstore
v1.5.5* and running into a parse exception using the SwiftClient when
object names contain a '%' symbol.
For example an object whose name is 'AND_-_100%_TVX/test.txt' will get
stored fine, but when I attempt to list the contents of the container that
the object is in I get the following exception:

Sep 10, 2013 10:26:40 AM org.jclouds.logging.jdk.JDKLogger logError
SEVERE: Error parsing input
java.lang.IllegalArgumentException: *URLDecoder: Illegal hex characters in
escape (%) pattern - For input string: "_T"*
    at java.net.URLDecoder.decode(URLDecoder.java:192)
    at org.jclouds.util.Strings2.urlDecode(Strings2.java:97)
    at org.jclouds.http.Uris$UriBuilder.appendPath(Uris.java:157)
    at
org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:82)
    at
org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:80)
    at com.google.common.collect.Iterators$9.transform(Iterators.java:893)
    at
com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
    at com.google.common.collect.Sets.newTreeSet(Sets.java:345)
    at
org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:79)
    at
org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:54)
    at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:66)
    at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:46)
    at com.google.common.util.concurrent.Futures$3.apply(Futures.java:376)
    at
com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:518)
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

Here is an example of a simple method that generates the exception:

private PageSet<ObjectInfo> listObjects(String containerName,
                                        String prefix,
                                        int maxResults,
                                        String marker) {
    ListContainerOptions containerOptions =
ListContainerOptions.Builder.maxResults(maxResults);
    if(marker != null) containerOptions.afterMarker(marker);
    if(prefix != null) containerOptions.withPrefix(prefix);
    return swiftClient.listObjects(containerName, containerOptions);
}

Calling this method with the container name of the container containing the
object whose name contains a '%' symbol and a maxResults of 1000 and null
for both prefix and marker will result in the above exception.
Let's just say my container name is "percent-container" and I have an
object in this container with the name "AND_-_100%_TVX/test.txt"

So this is what the method call to the above method might look like:
listObjects("percent-container", null, 1000, null);

Even if I URL encode the object name before storing it I still get the same
exception when retrieving a list of contents for the space.
I can run a cURL command straight to the Swift storage provider to get the
object and it returns fine.
Am I doing anything wrong?  Do I need to handle '%' symbols in a special
way?  The docs swift docs don't express any character restrictions on
object names:
http://docs.openstack.org/trunk/openstack-object-storage/admin/content/containers-and-objects.html

Any help is much appreciated!

Thanks,
Erik

Re: SwiftClient parse exception on '%' symbols

Posted by Erik Paulsson <ep...@fedora-commons.org>.
JIRA bug ticket created:
https://issues.apache.org/jira/browse/JCLOUDS-278



On Tue, Sep 10, 2013 at 12:42 PM, Andrew Gaul <ga...@apache.org> wrote:

> Erik, could you test again with 1.6.2 and file a JIRA issue here:
>
> https://issues.apache.org/jira/browse/JCLOUDS
>
> Also, would you like to try fixing this and submitting a GitHub pull
> request?  I can help you with this if you join irc.freenode.net
> #jclouds.
>
> On Tue, Sep 10, 2013 at 12:37:51PM -0400, Erik Paulsson wrote:
> > Hi all!
> >
> > I'm new to the group and looking for a little help.  I'm using
> > *org.jclouds:jclouds-allblobstore
> > v1.5.5* and running into a parse exception using the SwiftClient when
> > object names contain a '%' symbol.
> > For example an object whose name is 'AND_-_100%_TVX/test.txt' will get
> > stored fine, but when I attempt to list the contents of the container
> that
> > the object is in I get the following exception:
> >
> > Sep 10, 2013 10:26:40 AM org.jclouds.logging.jdk.JDKLogger logError
> > SEVERE: Error parsing input
> > java.lang.IllegalArgumentException: *URLDecoder: Illegal hex characters
> in
> > escape (%) pattern - For input string: "_T"*
> >     at java.net.URLDecoder.decode(URLDecoder.java:192)
> >     at org.jclouds.util.Strings2.urlDecode(Strings2.java:97)
> >     at org.jclouds.http.Uris$UriBuilder.appendPath(Uris.java:157)
> >     at
> >
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:82)
> >     at
> >
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:80)
> >     at
> com.google.common.collect.Iterators$9.transform(Iterators.java:893)
> >     at
> >
> com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
> >     at com.google.common.collect.Sets.newTreeSet(Sets.java:345)
> >     at
> >
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:79)
> >     at
> >
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:54)
> >     at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:66)
> >     at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:46)
> >     at
> com.google.common.util.concurrent.Futures$3.apply(Futures.java:376)
> >     at
> >
> com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:518)
> >     at
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> >     at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> >     at java.lang.Thread.run(Thread.java:724)
> >
> > Here is an example of a simple method that generates the exception:
> >
> > private PageSet<ObjectInfo> listObjects(String containerName,
> >                                         String prefix,
> >                                         int maxResults,
> >                                         String marker) {
> >     ListContainerOptions containerOptions =
> > ListContainerOptions.Builder.maxResults(maxResults);
> >     if(marker != null) containerOptions.afterMarker(marker);
> >     if(prefix != null) containerOptions.withPrefix(prefix);
> >     return swiftClient.listObjects(containerName, containerOptions);
> > }
> >
> > Calling this method with the container name of the container containing
> the
> > object whose name contains a '%' symbol and a maxResults of 1000 and null
> > for both prefix and marker will result in the above exception.
> > Let's just say my container name is "percent-container" and I have an
> > object in this container with the name "AND_-_100%_TVX/test.txt"
> >
> > So this is what the method call to the above method might look like:
> > listObjects("percent-container", null, 1000, null);
> >
> > Even if I URL encode the object name before storing it I still get the
> same
> > exception when retrieving a list of contents for the space.
> > I can run a cURL command straight to the Swift storage provider to get
> the
> > object and it returns fine.
> > Am I doing anything wrong?  Do I need to handle '%' symbols in a special
> > way?  The docs swift docs don't express any character restrictions on
> > object names:
> >
> http://docs.openstack.org/trunk/openstack-object-storage/admin/content/containers-and-objects.html
> >
> > Any help is much appreciated!
> >
> > Thanks,
> > Erik
>
> --
> Andrew Gaul
> http://gaul.org/
>

Re: SwiftClient parse exception on '%' symbols

Posted by Andrew Gaul <ga...@apache.org>.
Erik, could you test again with 1.6.2 and file a JIRA issue here:

https://issues.apache.org/jira/browse/JCLOUDS

Also, would you like to try fixing this and submitting a GitHub pull
request?  I can help you with this if you join irc.freenode.net
#jclouds.

On Tue, Sep 10, 2013 at 12:37:51PM -0400, Erik Paulsson wrote:
> Hi all!
> 
> I'm new to the group and looking for a little help.  I'm using
> *org.jclouds:jclouds-allblobstore
> v1.5.5* and running into a parse exception using the SwiftClient when
> object names contain a '%' symbol.
> For example an object whose name is 'AND_-_100%_TVX/test.txt' will get
> stored fine, but when I attempt to list the contents of the container that
> the object is in I get the following exception:
> 
> Sep 10, 2013 10:26:40 AM org.jclouds.logging.jdk.JDKLogger logError
> SEVERE: Error parsing input
> java.lang.IllegalArgumentException: *URLDecoder: Illegal hex characters in
> escape (%) pattern - For input string: "_T"*
>     at java.net.URLDecoder.decode(URLDecoder.java:192)
>     at org.jclouds.util.Strings2.urlDecode(Strings2.java:97)
>     at org.jclouds.http.Uris$UriBuilder.appendPath(Uris.java:157)
>     at
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:82)
>     at
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse$3.apply(ParseObjectInfoListFromJsonResponse.java:80)
>     at com.google.common.collect.Iterators$9.transform(Iterators.java:893)
>     at
> com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
>     at com.google.common.collect.Sets.newTreeSet(Sets.java:345)
>     at
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:79)
>     at
> org.jclouds.openstack.swift.functions.ParseObjectInfoListFromJsonResponse.apply(ParseObjectInfoListFromJsonResponse.java:54)
>     at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:66)
>     at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:46)
>     at com.google.common.util.concurrent.Futures$3.apply(Futures.java:376)
>     at
> com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:518)
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>     at java.lang.Thread.run(Thread.java:724)
> 
> Here is an example of a simple method that generates the exception:
> 
> private PageSet<ObjectInfo> listObjects(String containerName,
>                                         String prefix,
>                                         int maxResults,
>                                         String marker) {
>     ListContainerOptions containerOptions =
> ListContainerOptions.Builder.maxResults(maxResults);
>     if(marker != null) containerOptions.afterMarker(marker);
>     if(prefix != null) containerOptions.withPrefix(prefix);
>     return swiftClient.listObjects(containerName, containerOptions);
> }
> 
> Calling this method with the container name of the container containing the
> object whose name contains a '%' symbol and a maxResults of 1000 and null
> for both prefix and marker will result in the above exception.
> Let's just say my container name is "percent-container" and I have an
> object in this container with the name "AND_-_100%_TVX/test.txt"
> 
> So this is what the method call to the above method might look like:
> listObjects("percent-container", null, 1000, null);
> 
> Even if I URL encode the object name before storing it I still get the same
> exception when retrieving a list of contents for the space.
> I can run a cURL command straight to the Swift storage provider to get the
> object and it returns fine.
> Am I doing anything wrong?  Do I need to handle '%' symbols in a special
> way?  The docs swift docs don't express any character restrictions on
> object names:
> http://docs.openstack.org/trunk/openstack-object-storage/admin/content/containers-and-objects.html
> 
> Any help is much appreciated!
> 
> Thanks,
> Erik

-- 
Andrew Gaul
http://gaul.org/