> @@ -119,4 +129,9 @@ private static boolean hasPayload(final HttpResponse 
> response) {
>        return response.getPayload() != null && 
> response.getPayload().getRawContent() != null;
>     }
>  
> +   private static boolean isSoapPayload( final InputStream is ) throws 
> IOException {
> +      String content = CharStreams.toString( new InputStreamReader( is, 
> Charsets.UTF_8 ) );
> +      is.reset();
> +      return endSoapTag.matcher( content ).find();
> +   }

Understood.

The issue I see in your code is that you read the *original* InputStream into a 
String, and then your *reset* it, but that stream might not be replayable. That 
is the reason why we buffer it into a ByteArrayInputStream: we need to read it 
to see if there is an error, and if it is an OK response, we'll have to read it 
again to deserialize it to the right object. To do that, we *must* have a 
replayable inputstream and that's why we buffer it into a ByteArrayInputStream.

To make sure everything works, I'd change the code si the `isSoapPayload` 
method reads the already buffered stream. Makes sense? 

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

Reply via email to