Repository: zeppelin Updated Branches: refs/heads/master bb72b3dea -> 6db9929dd
[HOTFIX] Remove adduser while creating note ### What is this PR for? Adding user paragraph while creating paragraph makes default paragraph and user paragraph have same reference. It breaks personalized mode works well. ### What type of PR is it? [Bug Fix | Hot Fix] ### Todos * [x] - Remove `addUser` from `createParagraph` * [x] - Add test case for it ### What is the Jira issue? N/A ### How should this be tested? N/A ### Screenshots (if appropriate) N/A ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jongyoul Lee <jongy...@gmail.com> Closes #2292 from jongyoul/hotfix/remove-wrong-adduser-and-add-testcase and squashes the following commits: 6ed521a4 [Jongyoul Lee] Removed adduser while creating note Added test to guarantee paragraph.getUserParagraph is different from paragraph itself Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/6db9929d Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/6db9929d Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/6db9929d Branch: refs/heads/master Commit: 6db9929dd3caf957e41344b2cbc65eb515fde615 Parents: bb72b3d Author: Jongyoul Lee <jongy...@gmail.com> Authored: Thu Apr 27 02:01:23 2017 +0900 Committer: Jongyoul Lee <jongy...@apache.org> Committed: Fri May 5 01:58:36 2017 +0900 ---------------------------------------------------------------------- .../java/org/apache/zeppelin/notebook/Note.java | 1 - .../java/org/apache/zeppelin/notebook/NoteTest.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6db9929d/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 b19152d..b23048a 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 @@ -353,7 +353,6 @@ public class Note implements Serializable, ParagraphJobListener { private Paragraph createParagraph(int index, AuthenticationInfo authenticationInfo) { Paragraph p = new Paragraph(this, this, factory, interpreterSettingManager); p.setAuthenticationInfo(authenticationInfo); - p.addUser(p, p.getUser()); setParagraphMagic(p, index); return p; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6db9929d/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java index 1c9cfc9..0eb37df 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NoteTest.java @@ -217,4 +217,20 @@ public class NoteTest { assertEquals("getName should return same as getId when name is empty", note.getId(), note.getName()); } + + @Test + public void personalizedModeReturnDifferentParagraphInstancePerUser() { + Note note = new Note(repo, interpreterFactory, interpreterSettingManager, jobListenerFactory, index, credentials, noteEventListener); + + String user1 = "user1"; + String user2 = "user2"; + note.setPersonalizedMode(true); + note.addNewParagraph(new AuthenticationInfo(user1)); + Paragraph baseParagraph = note.getParagraphs().get(0); + Paragraph user1Paragraph = baseParagraph.getUserParagraph(user1); + Paragraph user2Paragraph = baseParagraph.getUserParagraph(user2); + assertNotEquals(System.identityHashCode(baseParagraph), System.identityHashCode(user1Paragraph)); + assertNotEquals(System.identityHashCode(baseParagraph), System.identityHashCode(user2Paragraph)); + assertNotEquals(System.identityHashCode(user1Paragraph), System.identityHashCode(user2Paragraph)); + } }