mirror of https://github.com/apache/jclouds.git
always display some error content
This commit is contained in:
parent
8ab9904481
commit
aa14f5b051
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.handlers;
|
package org.jclouds.aws.handlers;
|
||||||
|
|
||||||
|
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
||||||
import static org.jclouds.http.HttpUtils.releasePayload;
|
import static org.jclouds.http.HttpUtils.releasePayload;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -65,7 +66,9 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
|
||||||
Exception exception = new HttpResponseException(command, response);
|
Exception exception = new HttpResponseException(command, response);
|
||||||
try {
|
try {
|
||||||
AWSError error = null;
|
AWSError error = null;
|
||||||
String message = null;
|
// it is important to always read fully and close streams
|
||||||
|
byte[] data = closeClientButKeepContentStream(response);
|
||||||
|
String message = data != null ? new String(data) : null;
|
||||||
if (response.getPayload() != null) {
|
if (response.getPayload() != null) {
|
||||||
String contentType = response.getPayload().getContentMetadata().getContentType();
|
String contentType = response.getPayload().getContentMetadata().getContentType();
|
||||||
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
|
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
|
||||||
|
|
Loading…
Reference in New Issue