mirror of
https://github.com/apache/jclouds.git
synced 2025-02-06 18:19:03 +00:00
JCLOUDS-1509: read AWS response data with the UTF-8 charset explicitly
AWS response data is encoded in UTF-8. Creating a String from said data using the JVM's default charset results in incorrect encoding on environments in which the JVM's default charset is not UTF-8. https://issues.apache.org/jira/browse/JCLOUDS-1509
This commit is contained in:
parent
fe8d96af14
commit
95c4443022
@ -20,6 +20,7 @@ import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
||||
import static org.jclouds.http.HttpUtils.releasePayload;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
@ -65,7 +66,7 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler {
|
||||
AWSError error = null;
|
||||
// it is important to always read fully and close streams
|
||||
byte[] data = closeClientButKeepContentStream(response);
|
||||
String message = data != null ? new String(data) : null;
|
||||
String message = data != null ? new String(data, StandardCharsets.UTF_8) : null;
|
||||
if (response.getPayload() != null) {
|
||||
String contentType = response.getPayload().getContentMetadata().getContentType();
|
||||
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user