zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: [ZEPPELIN-2641] Change encoding to UTF-8 when sending request to Livy
Date Thu, 28 Sep 2017 05:05:01 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.7 8a2b46a25 -> 75df4aacc


[ZEPPELIN-2641] Change encoding to UTF-8 when sending request to Livy

Change encoding of the request sent from Zeppelin to Livy to UTF-8. In this way, Zeppelin
can support many more language than using ISO-8895-1 by default.

Bug Fix

[ZEPPELIN-2641](https://issues.apache.org/jira/browse/ZEPPELIN-2641)

Build from source.
Open a Livy note book.
Run some simple print command with Chinese or Korean, see whether the return can show the
character correctly

before
![image](https://user-images.githubusercontent.com/14201792/27174528-11d45216-51ef-11e7-8f46-2f2e8347a3de.png)

after
![image](https://user-images.githubusercontent.com/14201792/27174517-08cdba04-51ef-11e7-989c-88e516b2d265.png)

* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: 汪赫扬 <qwemicheal@gmail.com>

Closes #2412 from qwemicheal/utf-8 and squashes the following commits:

a72ffeb [汪赫扬] change utf8Str to explicit Chinese
8f144bc [汪赫扬] add unit test
f689a7e [汪赫扬] add utf-8 encoding

(cherry picked from commit f7c47af9b552843f63935a59302de31519ae6b97)
Signed-off-by: Jeff Zhang <zjffdu@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/75df4aac
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/75df4aac
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/75df4aac

Branch: refs/heads/branch-0.7
Commit: 75df4aacca0907d251b06da87d9a49920683e48b
Parents: 8a2b46a
Author: 汪赫扬 <qwemicheal@gmail.com>
Authored: Mon Jun 19 12:39:55 2017 +0800
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Thu Sep 28 13:04:43 2017 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java   | 3 ++-
 .../src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/75df4aac/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
----------------------------------------------------------------------
diff --git a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
index 022aef8..2c92bbf 100644
--- a/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
+++ b/livy/src/main/java/org/apache/zeppelin/livy/BaseLivyInterpreter.java
@@ -41,6 +41,7 @@ import org.apache.zeppelin.interpreter.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpEntity;
+import org.springframework.http.MediaType;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
@@ -492,7 +493,7 @@ public abstract class BaseLivyInterpreter extends Interpreter {
     targetURL = livyURL + targetURL;
     LOGGER.debug("Call rest api in {}, method: {}, jsonData: {}", targetURL, method, jsonData);
     HttpHeaders headers = new HttpHeaders();
-    headers.add("Content-Type", "application/json");
+    headers.add("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE);
     headers.add("X-Requested-By", "zeppelin");
     ResponseEntity<String> response = null;
     try {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/75df4aac/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
----------------------------------------------------------------------
diff --git a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java b/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
index 302f002..82fd806 100644
--- a/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
+++ b/livy/src/test/java/org/apache/zeppelin/livy/LivyInterpreterIT.java
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Properties;
 


Mime
View raw message