Repository: zeppelin Updated Branches: refs/heads/master 62d953901 -> f3f24f300
[ZEPPELIN-2713] Fix NPE of notebook creat rest api if message is nul⦠â¦l or empty ### What is this PR for? Notebook create rest api will cause NPE when the message is null or empty. ### What type of PR is it? [Bug Fix ] ### Todos * [ ] - Task ### What is the Jira issue? * Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/ * https://issues.apache.org/jira/projects/ZEPPELIN/issues/ZEPPELIN-2713?filter=allopenissues ### How should this be tested? Post to rest api (api/notebook) with nothing, test if NPE ### 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: lichenyang <licheny...@cmss.chinamobile.com> Closes #2457 from reminia/ZEPPELIN-2713 and squashes the following commits: 36e3b46b9 [lichenyang] [ZEPPELIN-2713] Fix NPE of notebook create rest api if message is null or empty Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/f3f24f30 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/f3f24f30 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/f3f24f30 Branch: refs/heads/master Commit: f3f24f3000274260ab413d65f15915b6050e8bd1 Parents: 62d9539 Author: lichenyang <licheny...@cmss.chinamobile.com> Authored: Fri Jun 30 17:24:29 2017 +0800 Committer: Khalid Huseynov <khalid...@gmail.com> Committed: Tue Jul 4 06:11:39 2017 +0900 ---------------------------------------------------------------------- .../org/apache/zeppelin/rest/NotebookRestApi.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/f3f24f30/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java index 50a8671..e18a2e7 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java @@ -332,14 +332,16 @@ public class NotebookRestApi { public Response createNote(String message) throws IOException { String user = SecurityUtils.getPrincipal(); LOG.info("Create new note by JSON {}", message); - NewNoteRequest request = gson.fromJson(message, NewNoteRequest.class); AuthenticationInfo subject = new AuthenticationInfo(user); Note note = notebook.createNote(subject); - List<NewParagraphRequest> initialParagraphs = request.getParagraphs(); - if (initialParagraphs != null) { - for (NewParagraphRequest paragraphRequest : initialParagraphs) { - Paragraph p = note.addNewParagraph(subject); - initParagraph(p, paragraphRequest, user); + NewNoteRequest request = gson.fromJson(message, NewNoteRequest.class); + if (request != null) { + List<NewParagraphRequest> initialParagraphs = request.getParagraphs(); + if (initialParagraphs != null) { + for (NewParagraphRequest paragraphRequest : initialParagraphs) { + Paragraph p = note.addNewParagraph(subject); + initParagraph(p, paragraphRequest, user); + } } } note.addNewParagraph(subject); // add one paragraph to the last