You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2015/12/24 06:19:20 UTC
incubator-zeppelin git commit: ZEPPELIN-527 Fix NPE while retrieving
job status from notebook
Repository: incubator-zeppelin
Updated Branches:
refs/heads/master ad7a6c082 -> 927f48225
ZEPPELIN-527 Fix NPE while retrieving job status from notebook
### What is this PR for?
Fix NPE while retrieving job status from notebook which contains "never run" / "first run but not finished".
### What type of PR is it?
Bug Fix
### Todos
### Is there a relevant Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-527
### How should this be tested?
1. Create a new notebook (```but don't run notebook!```)
2. Open ```http://<zeppelin host>:<zeppelin port>/api/notebook/job/<new notebook id>```
3. You can see HTTP STATUS 500 before this PR, but you can see HTTP STATUS 200 after this PR.
### Screenshots (if appropriate)
![2015-12-22 1 25 36](https://cloud.githubusercontent.com/assets/1317309/11947812/87605786-a8af-11e5-9d3f-3fda7efd12da.png)
### Questions:
* Does the licenses files need update? (No)
* Is there breaking changes for older versions? (No)
* Does this needs documentation? (No)
Author: Jungtaek Lim <ka...@gmail.com>
Closes #562 from HeartSaVioR/ZEPPELIN-527 and squashes the following commits:
a1eacb6 [Jungtaek Lim] Merge branch 'master' into ZEPPELIN-527
e08519e [Jungtaek Lim] ZEPPELIN-527 Don't include null value to the Map
f296406 [Jungtaek Lim] ZEPPELIN-527 Fix NPE while retrieving job status from notebook
Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/927f4822
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/927f4822
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/927f4822
Branch: refs/heads/master
Commit: 927f482256d6da052edaf99d41ddbddf80334f7c
Parents: ad7a6c0
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Dec 24 13:16:55 2015 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Thu Dec 24 14:20:56 2015 +0900
----------------------------------------------------------------------
.../zeppelin/rest/ZeppelinRestApiTest.java | 32 +++++++++++++++-----
.../java/org/apache/zeppelin/notebook/Note.java | 8 +++--
2 files changed, 31 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/927f4822/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
index 2bca9c0..2db3092 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
@@ -17,12 +17,6 @@
package org.apache.zeppelin.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -46,6 +40,8 @@ import org.junit.runners.MethodSorters;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
+import static org.junit.Assert.*;
+
/**
* BASIC Zeppelin rest api tests
*
@@ -530,6 +526,28 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
assertThat("", deleteCron, isAllowed());
deleteCron.releaseConnection();
ZeppelinServer.notebook.removeNote(note.getId());
- }
+ }
+
+ @Test
+ public void testRegressionZEPPELIN_527() throws IOException {
+ Note note = ZeppelinServer.notebook.createNote();
+
+ note.setName("note for run test");
+ Paragraph paragraph = note.addParagraph();
+ paragraph.setText("%spark\nval param = z.input(\"param\").toString\nprintln(param)");
+
+ note.persist();
+
+ GetMethod getNoteJobs = httpGet("/notebook/job/" + note.getId());
+ assertThat("test notebook jobs run:", getNoteJobs, isAllowed());
+ Map<String, Object> resp = gson.fromJson(getNoteJobs.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
+ }.getType());
+ List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body");
+ assertFalse(body.get(0).containsKey("started"));
+ assertFalse(body.get(0).containsKey("finished"));
+ getNoteJobs.releaseConnection();
+
+ ZeppelinServer.notebook.removeNote(note.getId());
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/927f4822/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index 6a3074f..d193ecc 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -312,8 +312,12 @@ public class Note implements Serializable, JobListener {
Map<String, String> info = new HashMap<>();
info.put("id", p.getId());
info.put("status", p.getStatus().toString());
- info.put("started", p.getDateStarted().toString());
- info.put("finished", p.getDateFinished().toString());
+ if (p.getDateStarted() != null) {
+ info.put("started", p.getDateStarted().toString());
+ }
+ if (p.getDateFinished() != null) {
+ info.put("finished", p.getDateFinished().toString());
+ }
paragraphsInfo.add(info);
}
}