Repository: jclouds
Updated Branches:
  refs/heads/master c8bbb44f3 -> e0a7ea7fd


Only quote ETag if it does not already have quotes


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/e0a7ea7f
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/e0a7ea7f
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/e0a7ea7f

Branch: refs/heads/master
Commit: e0a7ea7fdf4554d919b23ce72391a37e41d7cad8
Parents: 7eb46cc
Author: Andrew Gaul <[email protected]>
Authored: Fri Feb 12 22:24:33 2016 -0800
Committer: Andrew Gaul <[email protected]>
Committed: Tue Feb 16 16:29:54 2016 -0800

----------------------------------------------------------------------
 .../java/org/jclouds/s3/options/CopyObjectOptions.java   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/e0a7ea7f/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java
----------------------------------------------------------------------
diff --git 
a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java 
b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java
index 374278d..d9e6064 100644
--- a/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java
+++ b/apis/s3/src/main/java/org/jclouds/s3/options/CopyObjectOptions.java
@@ -226,7 +226,7 @@ public class CopyObjectOptions extends 
BaseHttpRequestOptions {
    public CopyObjectOptions ifSourceETagMatches(String eTag) {
       checkState(getIfNoneMatch() == null, "ifETagDoesntMatch() is not 
compatible with ifETagMatches()");
       checkState(getIfModifiedSince() == null, "ifModifiedSince() is not 
compatible with ifETagMatches()");
-      replaceHeader(COPY_SOURCE_IF_MATCH, String.format("\"%1$s\"", 
checkNotNull(eTag, "eTag")));
+      replaceHeader(COPY_SOURCE_IF_MATCH, maybeQuoteETag(checkNotNull(eTag, 
"eTag")));
       return this;
    }
 
@@ -243,7 +243,7 @@ public class CopyObjectOptions extends 
BaseHttpRequestOptions {
       checkState(getIfMatch() == null, "ifETagMatches() is not compatible with 
ifETagDoesntMatch()");
       Preconditions.checkState(getIfUnmodifiedSince() == null,
                "ifUnmodifiedSince() is not compatible with 
ifETagDoesntMatch()");
-      replaceHeader(COPY_SOURCE_IF_NO_MATCH, String.format("\"%s\"", 
checkNotNull(eTag, "ifETagDoesntMatch")));
+      replaceHeader(COPY_SOURCE_IF_NO_MATCH, maybeQuoteETag(checkNotNull(eTag, 
"ifETagDoesntMatch")));
       return this;
    }
 
@@ -397,4 +397,11 @@ public class CopyObjectOptions extends 
BaseHttpRequestOptions {
          return options.overrideMetadataWith(metadata);
       }
    }
+
+   private static String maybeQuoteETag(String eTag) {
+      if (!eTag.startsWith("\"") && !eTag.endsWith("\"")) {
+         eTag = "\"" + eTag + "\"";
+      }
+      return eTag;
+   }
 }

Reply via email to