Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-278

SwiftClient parse exception on '%' symbols

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.10, 1.6.2
    • 1.7.0
    • jclouds-blobstore
    • Tested on:
      org.jclouds:jclouds-allblobstore:1.5.5
      AND
      org.apache.jclouds:jclouds-allblobstore:1.6.2-incubating

    Description

      I've tested this using org.jclouds:jclouds-allblobstore v1.5.5 and 1.6.2-incubating. I get 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)

      This may affect more than just the SwiftClient API since it looks like the bug may be in:
      org.jclouds.util.Strings2.urlDecode
      org.jclouds.http.Uris$UriBuilder.appendPath

      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

      Attachments

        1. JCLOUDS-278-master.patch
          4 kB
          Andrew Phillips

        Activity

          People

            gaul Andrew Gaul
            paulsson Erik Paulsson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: