tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1074159 - /tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
Date Thu, 24 Feb 2011 14:15:35 GMT
Author: markt
Date: Thu Feb 24 14:15:34 2011
New Revision: 1074159

URL: http://svn.apache.org/viewvc?rev=1074159&view=rev
Log:
Avoid NPE if no u-a header

Modified:
    tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java

Modified: tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java?rev=1074159&r1=1074158&r2=1074159&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java Thu Feb 24
14:15:34 2011
@@ -125,10 +125,13 @@ public class CrawlerSessionManagerValve 
 
             // Is this a crawler - cheack the UA headers
             Enumeration<String> uaHeaders = request.getHeaders("user-agent");
-            String uaHeader = uaHeaders.nextElement();
+            String uaHeader = null;
+            if (uaHeaders.hasMoreElements()) {
+                uaHeader = uaHeaders.nextElement();
+            }
             
             // If more than one UA header - assume not a bot
-            if (!uaHeaders.hasMoreElements()) {
+            if (uaHeader != null && !uaHeaders.hasMoreElements()) {
 
                 if (log.isDebugEnabled()) {
                     log.debug(request.hashCode() + ": UserAgent=" + uaHeader);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message