Reamer commented on a change in pull request #4186:
URL: https://github.com/apache/zeppelin/pull/4186#discussion_r686646534



##########
File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
##########
@@ -263,19 +263,17 @@ public void onMessage(NotebookSocket conn, String msg) {
       }
 
       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());

Review comment:
       As I mentioned earlier, debug output with an empty 
`receivedMessage.ticket` makes no sense, so I would remove the if and always 
output the invalid ticket in the debug output.
   
   Your current code:
   ```java
   } 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.")));
     }
     return;
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to