You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2019/08/08 15:25:13 UTC

[jclouds] branch 2.1.x updated: JCLOUDS-1509: read AWS response data with the UTF-8 charset explicitly

This is an automated email from the ASF dual-hosted git repository.

gaul pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/jclouds.git


The following commit(s) were added to refs/heads/2.1.x by this push:
     new 95c4443  JCLOUDS-1509: read AWS response data with the UTF-8 charset explicitly
95c4443 is described below

commit 95c4443022f9bfaa87952d5ac59befe0b89d755e
Author: Roded Bahat <ro...@model9.io>
AuthorDate: Thu Aug 8 15:32:25 2019 +0300

    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
---
 .../java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java
index c298fc7..2ebe0d3 100644
--- a/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java
+++ b/apis/sts/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java
@@ -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)) {