Repository: zeppelin
Updated Branches:
  refs/heads/master 80735bc0d -> 36a7e38ff


[ZEPPELIN- 1298] Log instead of throwing trace for ping messages

### What is this PR for?
When non authenticated user in non-anonymous mode tries to send any websocket 
api message it results in throwing a traceback. However on PING message we 
don't need to show the whole traceback and we can just log in order not to 
pollute the logs file.

### What type of PR is it?
Hot Fix

### Todos
* [x] - log and return on PING

### What is the Jira issue?
[Zeppelin-1298](https://issues.apache.org/jira/browse/ZEPPELIN-1298)

### How should this be tested?
Follow the steps in issue and shouldn't get repeating traceback.

### 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: Khalid Huseynov <[email protected]>

Closes #1293 from khalidhuseynov/hotfix/zeppelin-1298 and squashes the 
following commits:

ff7812a [Khalid Huseynov] warn if non-empty invalid ticket
6da7bd4 [Khalid Huseynov] log in debug mode all invalid ticket cases
c1160a7 [Khalid Huseynov] don't throw exception on ping


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/36a7e38f
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/36a7e38f
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/36a7e38f

Branch: refs/heads/master
Commit: 36a7e38ffd6af614ad770a6e23ec1fd98a90c809
Parents: 80735bc
Author: Khalid Huseynov <[email protected]>
Authored: Mon Aug 8 08:18:10 2016 +0400
Committer: Mina Lee <[email protected]>
Committed: Tue Aug 9 09:54:15 2016 +0900

----------------------------------------------------------------------
 .../org/apache/zeppelin/socket/NotebookServer.java   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/36a7e38f/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
----------------------------------------------------------------------
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 00971ad..49aafa4 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
@@ -20,6 +20,8 @@ import com.google.common.base.Strings;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.reflect.TypeToken;
+
+import org.apache.commons.lang.StringUtils;
 import org.apache.zeppelin.conf.ZeppelinConfiguration;
 import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
 import org.apache.zeppelin.display.AngularObject;
@@ -131,8 +133,17 @@ public class NotebookServer extends WebSocketServlet 
implements
       }
       
       String ticket = 
TicketContainer.instance.getTicket(messagereceived.principal);
-      if (ticket != null && !ticket.equals(messagereceived.ticket))
-        throw new Exception("Invalid ticket " + messagereceived.ticket + " != 
" + ticket);
+      if (ticket != null && !ticket.equals(messagereceived.ticket)){
+        /* not to pollute logs, log instead of exception */
+        if (StringUtils.isEmpty(messagereceived.ticket)) {
+          LOG.debug("{} message: invalid ticket {} != {}", messagereceived.op,
+              messagereceived.ticket, ticket);
+        } else {
+          LOG.warn("{} message: invalid ticket {} != {}", messagereceived.op,
+              messagereceived.ticket, ticket);
+        }
+        return;
+      }
 
       ZeppelinConfiguration conf = ZeppelinConfiguration.create();
       boolean allowAnonymous = conf.

Reply via email to