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/12/15 02:12:11 UTC

[jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Also deprecate byte[], File, InputSupplier&lt;InputStream&gt;, and String
Payloads.  Callers should instead provide a ByteSource via
ByteSource.wrap(byte[]) and Files.asByteSource(File)
You can merge this Pull Request by running:

  git pull https://github.com/maginatics/jclouds byte-source

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

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

-- Commit Summary --

  * JCLOUDS-410. Add support for ByteSource Payloads

-- File Changes --

    M blobstore/src/main/java/org/jclouds/blobstore/domain/BlobBuilder.java (11)
    M blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java (11)
    M core/src/main/java/org/jclouds/http/HttpMessage.java (13)
    M core/src/main/java/org/jclouds/http/HttpUtils.java (3)
    M core/src/main/java/org/jclouds/io/Payloads.java (12)
    M core/src/main/java/org/jclouds/io/payloads/ByteArrayPayload.java (1)
    A core/src/main/java/org/jclouds/io/payloads/ByteSourcePayload.java (64)
    M core/src/main/java/org/jclouds/io/payloads/FilePayload.java (1)
    M core/src/main/java/org/jclouds/io/payloads/InputStreamSupplierPayload.java (1)
    M core/src/main/java/org/jclouds/io/payloads/StringPayload.java (1)

-- Patch Links --

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     public static StringPayload newStringPayload(String data) {
>        return new StringPayload(checkNotNull(data, "data"));
>     }
>  
> +   @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -28,6 +28,7 @@
>  /**
>   * @author Adrian Cole
>   */
> +@Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

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

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -66,14 +67,25 @@ public T payload(Payload payload) {
>        /**
>         * @see HttpMessage#getPayload()
>         */
> +      @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Gaul <no...@github.com>.
>     PayloadBlobBuilder payload(String payload);
>  
>     /**
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource)

Users would call ```Files.asByteSource(File)```.  ```ByteSources.asByteSource(InputStream)``` is not generally a safe API and we should remove these kinds of things.

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -29,6 +29,7 @@
>  /**
>   * @author Adrian Cole
>   */
> +@Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     PayloadBlobBuilder payload(String payload);
>  
>     /**
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource)

How would a user convert a file to a ByteSource? `ByteSources.asByteSource(new FileInputStream(file))`? Would that result in the FIS not being closed?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -27,7 +27,9 @@
>  
>  /**
>   * @author Adrian Cole
> + * @deprecated see newPayload(ByteSource)

"newPayload" in which class?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -25,6 +25,7 @@
>  /**
>   * @author Adrian Cole
>   */
> +@Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> +         throw Throwables.propagate(e);
> +      }
> +   }
> +
> +   @Override
> +   public boolean isRepeatable() {
> +      return true;
> +   }
> +
> +   /**
> +    * if we created the stream, then it is already consumed on close.
> +    */
> +   @Override
> +   public void release() {
> +      if (toClose.size() > 0)
> +         for (InputStream content = toClose.remove(0); toClose.size() > 0; content = toClose.remove(0))

`!toClose.isEmpty()`?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -77,21 +78,32 @@
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource)

"use {@code payload(ByteSource.wrap(byteArrayPayload))}"?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> +      } catch (IOException e) {
> +         throw Throwables.propagate(e);
> +      }
> +   }
> +
> +   @Override
> +   public boolean isRepeatable() {
> +      return true;
> +   }
> +
> +   /**
> +    * if we created the stream, then it is already consumed on close.
> +    */
> +   @Override
> +   public void release() {
> +      if (toClose.size() > 0)

`!toClose.isEmpty()`?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

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

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     public static StringPayload newStringPayload(String data) {
>        return new StringPayload(checkNotNull(data, "data"));
>     }
>  
> +   /**
> +    * @deprecated see newPayload(ByteSource)

"see {@link newByteSourcePayload(ByteSource)}"?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -24,7 +24,9 @@
>  
>  /**
>   * @author Adrian Cole
> + * @deprecated see newPayload(ByteSource)

"newPayload" in which class?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Gaul <no...@github.com>.
Addressed all comments.

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     PayloadBlobBuilder payload(byte[] payload);
>  
>     /**
> +    *
> +    * @param payload
> +    *           payload you wish to construct the {@link Blob} with.
> +    */
> +   PayloadBlobBuilder payload(ByteSource byteSource);
> +
> +   /**
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
>      */

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     public static ByteArrayPayload newByteArrayPayload(byte[] data) {
>        return new ByteArrayPayload(checkNotNull(data, "data"));
>     }
>  
> +   public static ByteSourcePayload newByteSourcePayload(ByteSource data) {
> +      return new ByteSourcePayload(checkNotNull(data, "data"));
> +   }
> +
> +   /**
> +    * @deprecated see newPayload(ByteSource)

"see {@link newByteSourcePayload(ByteSource)}"?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Gaul <no...@github.com>.
Addressed all comments.

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>        
>        /**
>         * @see HttpMessage#getPayload()
>         */
> +      @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -92,6 +102,7 @@
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
>      */
> +   @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource))

Duplicate `)`. How about "use {@code payload(ByteSource.wrap(stringPayload.getBytes(Charsets.UTF_8))}"?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

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

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Gaul <no...@github.com>.
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource))

Done.

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -27,6 +27,7 @@
>   * 
>   * @author Adrian Cole
>   */
> +@Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #475](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/475/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #474](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/474/) UNSTABLE
Looks like there's a problem with this pull request

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -61,14 +69,30 @@ public static InputStreamPayload newInputStreamPayload(InputStream data) {
>        return new InputStreamPayload(checkNotNull(data, "data"));
>     }
>  
> +   /**
> +    * @deprecated see newPayload(ByteSource)

"see {@link newByteSourcePayload(ByteSource)}"?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     public static ByteArrayPayload newByteArrayPayload(byte[] data) {
>        return new ByteArrayPayload(checkNotNull(data, "data"));
>     }
>  
> +   public static ByteSourcePayload newByteSourcePayload(ByteSource data) {
> +      return new ByteSourcePayload(checkNotNull(data, "data"));
> +   }
> +
> +   @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

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

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -90,6 +102,7 @@ public T payload(InputStream payload) {
>        /**
>         * @see HttpMessage#getPayload()
>         */
> +      @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

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

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #938](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/938/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -26,7 +26,9 @@
>   * a different encoding, please use {@link ByteArrayPayload}.
>   * 
>   * @author Adrian Cole
> + * @deprecated see newPayload(ByteSource)

"newPayload" in which class?

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Gaul <no...@github.com>.
>     public static StringPayload newStringPayload(String data) {
>        return new StringPayload(checkNotNull(data, "data"));
>     }
>  
> +   /**
> +    * @deprecated see newPayload(ByteSource)

Changed to ```@deprecated see ByteSourcePayload```.

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -61,14 +66,21 @@ public static InputStreamPayload newInputStreamPayload(InputStream data) {
>        return new InputStreamPayload(checkNotNull(data, "data"));
>     }
>  
> +   @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
> @@ -78,13 +79,22 @@
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
>      */
> +   @Deprecated

Add `@deprecated` Javadoc to describe alternative(s)

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

Re: [jclouds] JCLOUDS-410. Add support for ByteSource Payloads (#234)

Posted by Andrew Phillips <no...@github.com>.
>     PayloadBlobBuilder payload(String payload);
>  
>     /**
>      * 
>      * @param payload
>      *           payload you wish to construct the {@link Blob} with.
> +    * @deprecated see payload(ByteSource)

Learned something new again...thanks! ;-)

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