chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r774549 - /hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java
Date Wed, 13 May 2009 21:53:28 GMT
Author: eyang
Date: Wed May 13 21:53:28 2009
New Revision: 774549

URL: http://svn.apache.org/viewvc?rev=774549&view=rev
Log:
CHUKWA-234. Improved handling of null session for XssFilter. (Eric Yang)

Modified:
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java?rev=774549&r1=774548&r2=774549&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/util/XssFilter.java Wed May 13 21:53:28
2009
@@ -38,17 +38,22 @@
 
     public XssFilter(HttpServletRequest request) {
       this.request = request;
-      this.session = request.getSession();
-      for (Enumeration e = request.getParameterNames() ; e.hasMoreElements() ;) {
-        Pattern p = Pattern.compile("_session\\.(.*)");
-        String name = (String) e.nextElement();
-        Matcher matcher = p.matcher(name);
-        if(matcher.find()) {
+      try {
+        this.session = request.getSession();
+        for (Enumeration e = request.getParameterNames() ; e.hasMoreElements() ;) {
+          Pattern p = Pattern.compile("_session\\.(.*)");
+          String name = (String) e.nextElement();
+          Matcher matcher = p.matcher(name);
+          if(matcher.find()) {
             String realName = matcher.group(1);
-            session.setAttribute(realName,filter(request.getParameter(name)));
+            if(session!=null) {
+              session.setAttribute(realName,filter(request.getParameter(name)));
+            }
+          }
         }
+      } catch(NullPointerException ex) {
+        // Do nothing if session does not exist.
       }
-
     }
     
     public String getParameter(String key) {



Mime
View raw message