This is an automated email from the ASF dual-hosted git repository.

pdallig pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new 831dc50  [ZEPPELIN-5468]Fast return when invalid ticket of no session 
case
831dc50 is described below

commit 831dc50bd81e0f087dfe9e3099c19f45df0da844
Author: vmaster <vmaster...@gmail.com>
AuthorDate: Sat Jul 24 12:12:34 2021 +0800

    [ZEPPELIN-5468]Fast return when invalid ticket of no session case
    
    ### What is this PR for?
    Fix NullPointerException of org.apache.zeppelin.socket.NotebookServer when 
invalid ticket message received
    This exception may occur when server sessions is not contains received 
principal. In other words, it happend when no session case.
    
    ### What type of PR is it?
    Bug Fix
    
    ### Todos
    haven't
    
    ### What is the Jira issue?
    [ZEPPELIN-5468] Fix NullPointerException of 
org.apache.zeppelin.socket.NotebookServer when invalid ticket message received
    
    ### How should this be tested?
    Login visit page and then logout in other page, see log output
    
    ### Screenshots (if appropriate)
    
![image](https://user-images.githubusercontent.com/18046946/126857669-2997491c-5fba-489f-8beb-2c5fc0fd367a.png)
    
    ### Questions:
    * Does the licenses files need update?  no
    * Is there breaking changes for older versions? no
    * Does this needs documentation? no
    
    Author: vmaster <vmaster...@gmail.com>
    
    Closes #4186 from aib628/branch-0.9-bugfix and squashes the following 
commits:
    
    026c1f872 [vmaster] [bugfix]Fast return when invalid ticket of no session 
case
---
 .../org/apache/zeppelin/socket/NotebookServer.java    | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git 
a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java 
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
index 34b8244..14d6059 100644
--- 
a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
+++ 
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
@@ -263,19 +263,16 @@ public class NotebookServer extends WebSocketServlet
       }
 
       TicketContainer.Entry ticketEntry = 
TicketContainer.instance.getTicketEntry(receivedMessage.principal);
-      if (ticketEntry != null &&
-              (!ticketEntry.getTicket().equals(receivedMessage.ticket))) {
+      if (ticketEntry == null || StringUtils.isEmpty(ticketEntry.getTicket())) 
{
+        LOG.debug("{} message: invalid ticket {}", receivedMessage.op, 
receivedMessage.ticket);
+        return;
+      } else if (!ticketEntry.getTicket().equals(receivedMessage.ticket)) {
         /* not to pollute logs, log instead of exception */
-        if (StringUtils.isEmpty(receivedMessage.ticket)) {
-          LOG.debug("{} message: invalid ticket {} != {}", receivedMessage.op,
-                  receivedMessage.ticket, ticketEntry.getTicket());
-        } else {
-          if (!receivedMessage.op.equals(OP.PING)) {
-            conn.send(serializeMessage(new 
Message(OP.SESSION_LOGOUT).put("info",
-                    "Your ticket is invalid possibly due to server restart. "
-                            + "Please login again.")));
-          }
+        LOG.debug("{} message: invalid ticket {} != {}", receivedMessage.op, 
receivedMessage.ticket, ticketEntry.getTicket());
+        if (!receivedMessage.op.equals(OP.PING)) {
+          conn.send(serializeMessage(new 
Message(OP.SESSION_LOGOUT).put("info", "Your ticket is invalid possibly due to 
server restart. Please login again.")));
         }
+
         return;
       }
 

Reply via email to