You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Andrew Gaul <no...@github.com> on 2013/10/09 01:04:42 UTC

[jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Atmos does not return a location header when writing zero-length
objects, which normally throws an HttpResponseException: no uri in
headers or content.
You can merge this Pull Request by running:

  git pull https://github.com/maginatics/jclouds atmos-zero-length-objects

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds/pull/172

-- Commit Summary --

  * JCLOUDS-339. Handle zero-length objects in Atmos

-- File Changes --

    M apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java (2)
    A apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseURIFromListOrLocationHeaderIf20xHandleZeroLength.java (43)
    M apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java (5)
    M apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java (10)
    M core/src/main/java/org/jclouds/http/functions/ParseURIFromListOrLocationHeaderIf20x.java (2)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/172.patch
https://github.com/jclouds/jclouds/pull/172.diff

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Gaul <no...@github.com>.
> @@ -127,6 +128,7 @@
>     @POST
>     @Path("/{parent}/{name}")
>     @Headers(keys = EXPECT, values = "100-continue")
> +   @ResponseParser(ParseURIFromListOrLocationHeaderIf20xHandleZeroLength.class)
>     @Consumes(MediaType.WILDCARD)
>     ListenableFuture<URI> createFile(

jclouds exclusively uses the namespace interface, so it can find these by path.  Atmos also offers an object interface which allows clients to upload a nameless object and Atmos vends an object ID.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6844374

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Gaul <no...@github.com>.
Closed #172.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Gaul <no...@github.com>.
> +
> +import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
> +import static org.jclouds.http.HttpUtils.releasePayload;
> +
> +import java.net.URI;
> +
> +import org.jclouds.http.HttpResponse;
> +import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
> +
> +/**
> + * Parses a single URI from a list, returning null when blob length was zero.
> + * Atmos returns "HTTP/1.1 201 null" when putting zero-length blobs.
> + *
> + * @author Andrew Gaul
> + */
> +public class ParseURIFromListOrLocationHeaderIf20xHandleZeroLength extends ParseURIFromListOrLocationHeaderIf20x {

Will change to ```ParseURIFromListOrLocationHeaderIf20xAndNotNull```.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6844384

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #755](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/755/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25939001

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Phillips <no...@github.com>.
> +
> +import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
> +import static org.jclouds.http.HttpUtils.releasePayload;
> +
> +import java.net.URI;
> +
> +import org.jclouds.http.HttpResponse;
> +import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
> +
> +/**
> + * Parses a single URI from a list, returning null when blob length was zero.
> + * Atmos returns "HTTP/1.1 201 null" when putting zero-length blobs.
> + *
> + * @author Andrew Gaul
> + */
> +public class ParseNullableURIFromListOrLocationHeaderIf20x extends ParseURIFromListOrLocationHeaderIf20x {

Nice! Thanks! ;-)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6848748

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Phillips <no...@github.com>.
> +
> +import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
> +import static org.jclouds.http.HttpUtils.releasePayload;
> +
> +import java.net.URI;
> +
> +import org.jclouds.http.HttpResponse;
> +import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
> +
> +/**
> + * Parses a single URI from a list, returning null when blob length was zero.
> + * Atmos returns "HTTP/1.1 201 null" when putting zero-length blobs.
> + *
> + * @author Andrew Gaul
> + */
> +public class ParseURIFromListOrLocationHeaderIf20xHandleZeroLength extends ParseURIFromListOrLocationHeaderIf20x {

Wow, name is a bit of a mouthful :-( It really is still `ParseURIFromListOrLocationHeaderIf20x`, but I can see if we don't want the same name but then in a different package, too. "HandleZeroLength", though, is _not_ what the response parser does, really - it handles "201null", no?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6843993

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Phillips <no...@github.com>.
> @@ -127,6 +128,7 @@
>     @POST
>     @Path("/{parent}/{name}")
>     @Headers(keys = EXPECT, values = "100-continue")
> +   @ResponseParser(ParseURIFromListOrLocationHeaderIf20xHandleZeroLength.class)
>     @Consumes(MediaType.WILDCARD)
>     ListenableFuture<URI> createFile(

Do we need to document somewhere (annotation, Javadoc etc.) that this is `@Nullable` now? See also the general question about how to actually _use_ these objects..?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6844074

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Gaul <no...@github.com>.
@timuralp this commit should address the symptoms you encountered.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25935189

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #293](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/293/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25939000

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Phillips <no...@github.com>.
> Atmos does not return a location header when writing zero-length objects

Just in general...if you don't get a URI back for these objects, how are you supposed to access them? Or how would you get a URI back for one of these after creating it?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25936925

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #754](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/754/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25936116

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by Andrew Gaul <no...@github.com>.
> @@ -127,6 +128,7 @@
>     @POST
>     @Path("/{parent}/{name}")
>     @Headers(keys = EXPECT, values = "100-continue")
> +   @ResponseParser(ParseURIFromListOrLocationHeaderIf20xHandleZeroLength.class)
>     @Consumes(MediaType.WILDCARD)
>     ListenableFuture<URI> createFile(

I will add a ```@CheckForNull``` annotation.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172/files#r6844389

Re: [jclouds] JCLOUDS-339. Handle zero-length objects in Atmos (#172)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #292](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/292/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/172#issuecomment-25936089