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 1202b4c  [ZEPPELIN-4606]. Run paragraph rest api cause the paragraph 
configuration missing after execution
1202b4c is described below

commit 1202b4c7d08ba61ee66dcd2bbed853f9775eaf89
Author: Jeff Zhang <zjf...@apache.org>
AuthorDate: Tue Feb 11 16:55:56 2020 +0800

    [ZEPPELIN-4606]. Run paragraph rest api cause the paragraph configuration 
missing after execution
    
    ### What is this PR for?
    This PR fix the issue by only setting config and setting when they are not 
empty. Because when invoking rest api, the paragraph config won't be passed to 
backend, in that case it would use an empty Map to override the existing config.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-4606
    
    ### How should this be tested?
    * CI pass
    
    ### 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 <zjf...@apache.org>
    
    Closes #3637 from zjffdu/ZEPPELIN-4606 and squashes the following commits:
    
    8b5b1dea1 [Jeff Zhang] [ZEPPELIN-4606]. Run paragraph rest api cause the 
paragraph configuration missing after execution
---
 .../org/apache/zeppelin/service/NotebookService.java     | 16 ++++++++++++----
 .../org/apache/zeppelin/service/NotebookServiceTest.java |  4 ++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git 
a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
 
b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
index 6a0af51..7ed3331 100644
--- 
a/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
+++ 
b/zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java
@@ -309,16 +309,24 @@ public class NotebookService {
     p.setText(text);
     p.setTitle(title);
     p.setAuthenticationInfo(context.getAutheInfo());
-    p.settings.setParams(params);
-    p.setConfig(config);
+    if (params != null && !params.isEmpty()) {
+      p.settings.setParams(params);
+    }
+    if (config != null && !config.isEmpty()) {
+      p.setConfig(config);
+    }
 
     if (note.isPersonalizedMode()) {
       p = p.getUserParagraph(context.getAutheInfo().getUser());
       p.setText(text);
       p.setTitle(title);
       p.setAuthenticationInfo(context.getAutheInfo());
-      p.settings.setParams(params);
-      p.setConfig(config);
+      if (params != null && !params.isEmpty()) {
+        p.settings.setParams(params);
+      }
+      if (config != null && !config.isEmpty()) {
+        p.setConfig(config);
+      }
     }
 
     try {
diff --git 
a/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
 
b/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
index 8201f26..f77edc2 100644
--- 
a/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
+++ 
b/zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java
@@ -343,10 +343,13 @@ public class NotebookServiceTest {
 
     // run paragraph asynchronously
     reset(callback);
+    p.getConfig().put("colWidth", "6.0");
+    p.getConfig().put("title", true);
     boolean runStatus = notebookService.runParagraph(note1.getId(), p.getId(), 
"my_title", "1+1",
         new HashMap<>(), new HashMap<>(), false, false, context, callback);
     assertTrue(runStatus);
     verify(callback).onSuccess(p, context);
+    assertEquals(2, p.getConfig().size());
 
     // run paragraph synchronously via correct code
     reset(callback);
@@ -354,6 +357,7 @@ public class NotebookServiceTest {
         new HashMap<>(), new HashMap<>(), false, true, context, callback);
     assertTrue(runStatus);
     verify(callback).onSuccess(p, context);
+    assertEquals(2, p.getConfig().size());
 
     // run all paragraphs
     reset(callback);

Reply via email to