This is an automated email from the ASF dual-hosted git repository.
pdallig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new 114a06f [ZEPPELIN-5468]Fast return when invalid ticket of no session
case
114a06f is described below
commit 114a06f37b96e46414d6293bc73dfddf288dd4cd
Author: vmaster <[email protected]>
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)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no
Author: vmaster <[email protected]>
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
(cherry picked from commit 831dc50bd81e0f087dfe9e3099c19f45df0da844)
Signed-off-by: Philipp Dallig <[email protected]>
---
.../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 677b1b3..b7359b7 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;
}