You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2020/11/03 15:21:41 UTC
[zeppelin] branch master updated: [ZEPPELIN-5118]. Upgrade gson in
zeppelin-zengine
This is an automated email from the ASF dual-hosted git repository.
zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new dd77819 [ZEPPELIN-5118]. Upgrade gson in zeppelin-zengine
dd77819 is described below
commit dd77819c2b6cb08db4d05217b6f71fa17e6eeb4a
Author: Jeff Zhang <zj...@apache.org>
AuthorDate: Wed Oct 28 13:47:27 2020 +0800
[ZEPPELIN-5118]. Upgrade gson in zeppelin-zengine
### What is this PR for?
This PR is to upgrade gson in `zeppelin-zengine`, otherwise the integration test of zeppelin-client may fail in IDE because of gson version conflict.
### What type of PR is it?
[ Improvement ]
### Todos
* [ ] - Task
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-5118
### How should this be tested?
* CI pass
https://travis-ci.com/github/zjffdu/zeppelin/builds/197206407
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Jeff Zhang <zj...@apache.org>
Closes #3963 from zjffdu/ZEPPELIN-5118 and squashes the following commits:
6421ad14d [Jeff Zhang] [ZEPPELIN-5118]. Upgrade gson in zeppelin-zengine
---
pom.xml | 4 +-
.../ZeppelinClientWithAuthIntegrationTest.java | 8 ----
zeppelin-interpreter-shaded/pom.xml | 1 -
zeppelin-plugins/notebookrepo/s3/pom.xml | 11 ++++-
.../apache/zeppelin/rest/HeliumRestApiTest.java | 20 ++++-----
.../apache/zeppelin/rest/NotebookRestApiTest.java | 6 +--
.../interpreter/InterpreterInfoSaving.java | 8 ++--
.../zeppelin/interpreter/InterpreterSetting.java | 51 ++++------------------
8 files changed, 37 insertions(+), 72 deletions(-)
diff --git a/pom.xml b/pom.xml
index 90ce0ae..4e19a64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -122,8 +122,8 @@
<slf4j.version>1.7.30</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<libthrift.version>0.13.0</libthrift.version>
- <gson.version>2.2</gson.version>
- <gson-extras.version>0.2.1</gson-extras.version>
+ <gson.version>2.8.6</gson.version>
+ <gson-extras.version>0.2.2</gson-extras.version>
<jetty.version>9.4.31.v20200723</jetty.version>
<httpcomponents.core.version>4.4.1</httpcomponents.core.version>
<httpcomponents.client.version>4.5.1</httpcomponents.client.version>
diff --git a/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZeppelinClientWithAuthIntegrationTest.java b/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZeppelinClientWithAuthIntegrationTest.java
index 9b0fc93..3361d7f 100644
--- a/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZeppelinClientWithAuthIntegrationTest.java
+++ b/zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/ZeppelinClientWithAuthIntegrationTest.java
@@ -19,9 +19,6 @@ package org.apache.zeppelin.integration;
import org.apache.zeppelin.client.ClientConfig;
-import org.apache.zeppelin.client.NoteResult;
-import org.apache.zeppelin.client.ParagraphResult;
-import org.apache.zeppelin.client.Status;
import org.apache.zeppelin.client.ZeppelinClient;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.notebook.Notebook;
@@ -31,11 +28,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
diff --git a/zeppelin-interpreter-shaded/pom.xml b/zeppelin-interpreter-shaded/pom.xml
index f00a496..f8cd63f 100644
--- a/zeppelin-interpreter-shaded/pom.xml
+++ b/zeppelin-interpreter-shaded/pom.xml
@@ -37,7 +37,6 @@
<properties>
<!--plugin versions-->
- <plugin.shade.version>2.3</plugin.shade.version>
<shaded.dependency.prefix>org.apache.zeppelin.shaded</shaded.dependency.prefix>
</properties>
diff --git a/zeppelin-plugins/notebookrepo/s3/pom.xml b/zeppelin-plugins/notebookrepo/s3/pom.xml
index b61c1f3..eee6b2d 100644
--- a/zeppelin-plugins/notebookrepo/s3/pom.xml
+++ b/zeppelin-plugins/notebookrepo/s3/pom.xml
@@ -57,9 +57,18 @@
<dependency>
<groupId>org.gaul</groupId>
<artifactId>s3proxy</artifactId>
- <version>1.6.1</version>
+ <version>1.7.1</version>
+ <scope>test</scope>
<exclusions>
<exclusion>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ </exclusion>
+ <exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java
index ae205ae..fa472d4 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
-import com.google.gson.internal.StringMap;
import com.google.gson.reflect.TypeToken;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -36,6 +35,7 @@ import org.junit.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Map;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -114,7 +114,7 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
assertThat(get1, isAllowed());
Map<String, Object> resp1 = gson.fromJson(EntityUtils.toString(get1.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
+ List<Map> body1 = (List<Map>) resp1.get("body");
assertEquals(0, body1.size());
// Enable "name1" package
@@ -124,10 +124,10 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
assertThat(get2, isAllowed());
Map<String, Object> resp2 = gson.fromJson(EntityUtils.toString(get2.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");
+ List<Map> body2 = (List<Map>) resp2.get("body");
assertEquals(1, body2.size());
- StringMap<Object> pkg = (StringMap<Object>) body2.get(0).get("pkg");
+ Map pkg = (Map) body2.get(0).get("pkg");
assertEquals("name1", pkg.get("name"));
get1.close();
get2.close();
@@ -140,10 +140,10 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
assertThat(get, isAllowed());
Map<String, Object> resp = gson.fromJson(EntityUtils.toString(get.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- List<StringMap<Object>> body = (List<StringMap<Object>>) resp.get("body");
+ List<Map> body = (List<Map>) resp.get("body");
assertEquals(1, body.size());
- StringMap<Object> pkg = (StringMap<Object>) body.get(0).get("pkg");
+ Map pkg = (Map) body.get(0).get("pkg");
assertEquals("name1", pkg.get("name"));
get.close();
}
@@ -154,7 +154,7 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
assertThat(get, isAllowed());
Map<String, Object> resp = gson.fromJson(EntityUtils.toString(get.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- StringMap<Object> body = (StringMap<Object>) resp.get("body");
+ Map body = (Map) resp.get("body");
// ToDo: Apply config with POST command and check update
assertEquals(0, body.size());
get.close();
@@ -168,7 +168,7 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
assertThat(get, isAllowed());
Map<String, Object> resp = gson.fromJson(EntityUtils.toString(get.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- StringMap<Object> body = (StringMap<Object>) resp.get("body");
+ Map body = (Map) resp.get("body");
assertTrue(body.containsKey("confPersisted"));
get.close();
}
@@ -183,7 +183,7 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
CloseableHttpResponse get1 = httpGet("/helium/package/" + packageName);
Map<String, Object> resp1 = gson.fromJson(EntityUtils.toString(get1.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
+ List<Map> body1 = (List<Map>) resp1.get("body");
assertEquals(true, body1.get(0).get("enabled"));
get1.close();
@@ -194,7 +194,7 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
CloseableHttpResponse get2 = httpGet("/helium/package/" + packageName);
Map<String, Object> resp2 = gson.fromJson(EntityUtils.toString(get2.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() { }.getType());
- List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");
+ List<Map> body2 = (List<Map>) resp2.get("body");
assertEquals(false, body2.get(0).get("enabled"));
get2.close();
}
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
index e3a9bd8..2b31ee5 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import com.google.gson.Gson;
-import com.google.gson.internal.StringMap;
import com.google.gson.reflect.TypeToken;
import org.apache.zeppelin.interpreter.InterpreterSetting;
@@ -43,6 +42,7 @@ import org.junit.runners.MethodSorters;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -183,9 +183,9 @@ public class NotebookRestApiTest extends AbstractTestRestApi {
resp = gson.fromJson(EntityUtils.toString(post.getEntity(), StandardCharsets.UTF_8),
new TypeToken<Map<String, Object>>() {}.getType());
assertEquals("OK", resp.get("status"));
- StringMap stringMap = (StringMap) resp.get("body");
+ Map stringMap = (Map) resp.get("body");
assertEquals("ERROR", stringMap.get("code"));
- List<StringMap> interpreterResults = (List<StringMap>) stringMap.get("msg");
+ List<Map> interpreterResults = (List<Map>) stringMap.get("msg");
assertTrue(interpreterResults.get(0).toString(),
interpreterResults.get(0).get("data").toString().contains("invalid_cmd: command not found"));
post.close();
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfoSaving.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfoSaving.java
index cb7e703..04da876 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfoSaving.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterInfoSaving.java
@@ -21,7 +21,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import com.google.gson.internal.StringMap;
import org.apache.commons.io.IOUtils;
import org.apache.zeppelin.common.JsonSerializable;
import org.slf4j.Logger;
@@ -31,7 +30,6 @@ import org.eclipse.aether.repository.RemoteRepository;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -47,7 +45,7 @@ import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
public class InterpreterInfoSaving implements JsonSerializable {
private static final Logger LOGGER = LoggerFactory.getLogger(InterpreterInfoSaving.class);
- private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public Map<String, InterpreterSetting> interpreterSettings = new HashMap<>();
public List<RemoteRepository> interpreterRepositories = new ArrayList<>();
@@ -88,10 +86,10 @@ public class InterpreterInfoSaving implements JsonSerializable {
@Override
public String toJson() {
- return gson.toJson(this);
+ return GSON.toJson(this);
}
public static InterpreterInfoSaving fromJson(String json) {
- return gson.fromJson(json, InterpreterInfoSaving.class);
+ return GSON.fromJson(json, InterpreterInfoSaving.class);
}
}
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java
index 989fb80..487cf4d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSetting.java
@@ -26,7 +26,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
-import com.google.gson.internal.StringMap;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
@@ -58,7 +57,6 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -548,16 +546,7 @@ public class InterpreterSetting {
}
public void setProperties(Object object) {
- if (object instanceof StringMap) {
- StringMap<String> map = (StringMap) properties;
- Properties newProperties = new Properties();
- for (Entry<String, String> mapEntries : map.entrySet()) {
- newProperties.put(mapEntries.getKey(), mapEntries.getValue());
- }
- this.properties = newProperties;
- } else {
- this.properties = object;
- }
+ this.properties = object;
}
/**
@@ -567,11 +556,11 @@ public class InterpreterSetting {
* @param propertiesInTemplate
*/
public void fillPropertyDescription(Object propertiesInTemplate) {
- if (propertiesInTemplate instanceof LinkedHashMap) {
- LinkedHashMap<String, DefaultInterpreterProperty> propertiesInTemplate2 =
- (LinkedHashMap<String, DefaultInterpreterProperty>) propertiesInTemplate;
- if (this.properties instanceof LinkedHashMap) {
- LinkedHashMap<String, InterpreterProperty> newInterpreterProperties = (LinkedHashMap)this.properties;
+ if (propertiesInTemplate instanceof Map) {
+ Map<String, DefaultInterpreterProperty> propertiesInTemplate2 =
+ (Map<String, DefaultInterpreterProperty>) propertiesInTemplate;
+ if (this.properties instanceof Map) {
+ Map<String, InterpreterProperty> newInterpreterProperties = (Map)this.properties;
for (Map.Entry<String, InterpreterProperty> entry : newInterpreterProperties.entrySet()) {
if (propertiesInTemplate2.containsKey(entry.getKey())) {
entry.getValue().setDescription(propertiesInTemplate2.get(entry.getKey()).getDescription());
@@ -1030,29 +1019,7 @@ public class InterpreterSetting {
// For backward compatibility of interpreter.json format after ZEPPELIN-2403
static Map<String, InterpreterProperty> convertInterpreterProperties(Object properties) {
- if (properties instanceof StringMap) {
- Map<String, InterpreterProperty> newProperties = new LinkedHashMap<>();
- StringMap p = (StringMap) properties;
- for (Object o : p.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
- if (!(entry.getValue() instanceof StringMap)) {
- InterpreterProperty newProperty = new InterpreterProperty(
- entry.getKey().toString(),
- entry.getValue(),
- InterpreterPropertyType.STRING.getValue());
- newProperties.put(entry.getKey().toString(), newProperty);
- } else {
- StringMap stringMap = (StringMap) entry.getValue();
- InterpreterProperty newProperty = new InterpreterProperty(
- entry.getKey().toString(),
- stringMap.get("value"),
- stringMap.containsKey("type") ? stringMap.get("type").toString() : "string");
- newProperties.put(newProperty.getName(), newProperty);
- }
- }
- return newProperties;
-
- } else if (properties instanceof Map) {
+ if (properties instanceof Map) {
Map<String, Object> dProperties =
(Map<String, Object>) properties;
Map<String, InterpreterProperty> newProperties = new LinkedHashMap<>();
@@ -1061,8 +1028,8 @@ public class InterpreterSetting {
Object value = dPropertiesEntry.getValue();
if (value instanceof InterpreterProperty) {
return (Map<String, InterpreterProperty>) properties;
- } else if (value instanceof StringMap) {
- StringMap stringMap = (StringMap) value;
+ } else if (value instanceof Map) {
+ Map stringMap = (Map) value;
InterpreterProperty newProperty = new InterpreterProperty(
key,
stringMap.get("value"),