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

openstack-swift provider throws different exceptions for copyBlob

    XMLWordPrintableJSON

Details

    Description

      S3 and LocalBlobStore both throw KeyNotFoundException if copyBlob is called with an non-existent source key, but openstack-swift throws different exceptions depends on how copyBlob is used.

         @Test(groups = { "integration", "live" })
         public void testCopy404Blob() throws Exception {
            BlobStore blobStore = view.getBlobStore();
            String container = getContainerName();
            try {
               blobStore.copyBlob(container, "blob", container, "blob2", CopyOptions.NONE);
            } catch (KeyNotFoundException e) {
            } finally {
               returnContainer(container);
            }
         }
      
         @Test(groups = { "integration", "live" })
         public void testCopy404BlobMeta() throws Exception {
            BlobStore blobStore = view.getBlobStore();
            String container = getContainerName();
            try {
               blobStore.copyBlob(container, "blob", container, "blob2",
                       CopyOptions.builder().userMetadata(ImmutableMap.of("x", "1")).build());
            } catch (KeyNotFoundException e) {
            } finally {
               returnContainer(container);
            }
         }
      

      The first test throws NullPointerException:

      java.lang.NullPointerException: null
              at org.jclouds.openstack.swift.v1.blobstore.RegionScopedSwiftBlobStore.copyBlob(RegionScopedSwiftBlobStore.java:287)
              at org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest.testCopy404Blob(BaseBlobIntegrationTest.java:992)
      

      whereas the latter throws a swift specific exception:

      org.jclouds.openstack.swift.v1.CopyObjectException: Either the source path '/khc-blobstore0/blob' or the destination path '/khc-blobstore0/blob2' was not found. (message: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>)
              at org.jclouds.openstack.swift.v1.handlers.SwiftErrorHandler.handleError(SwiftErrorHandler.java:64)
              at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:65)
              at org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:136)
              at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:105)
              at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
              at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
              at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
              at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
              at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
              at com.sun.proxy.$Proxy73.copy(Unknown Source)
              at org.jclouds.openstack.swift.v1.blobstore.RegionScopedSwiftBlobStore.copyBlob(RegionScopedSwiftBlobStore.java:307)
              at org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest.testCopy404BlobMeta(BaseBlobIntegrationTest.java:1004)
      

      Attachments

        Activity

          People

            zack-s Zack Shoylev
            khc Ka-Hing Cheung
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: