You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pe...@apache.org on 2005/11/06 10:39:29 UTC

svn commit: r331098 - /tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java

Author: pero
Date: Sun Nov  6 01:39:26 2005
New Revision: 331098

URL: http://svn.apache.org/viewcvs?rev=331098&view=rev
Log:
Fix NPE when simple use only "GET <uri> HTTP/1.0\r\n\r\n"

Why endpoint.getAddress() don't give back local address?
Tested at Windows XP with tomcat 5.5.12.

Modified:
    tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java

Modified: tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=331098&r1=331097&r2=331098&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java Sun Nov  6 01:39:26 2005
@@ -830,7 +830,7 @@
      */
     public void parseHost(MessageBytes valueMB) {
 
-        if (valueMB == null || valueMB.isNull()) {
+        if (valueMB == null || (valueMB != null && valueMB.isNull()) ) {
             // HTTP/1.0
             // Default is what the socket tells us. Overriden if a host is
             // found/parsed
@@ -838,8 +838,14 @@
             InetAddress localAddress = endpoint.getAddress()/*socket.getLocalAddress()*/;
             // Setting the socket-related fields. The adapter doesn't know
             // about socket.
-            request.setLocalHost(localAddress.getHostName());
-            request.serverName().setString(localAddress.getHostName());
+            if(localAddress != null) {
+                request.setLocalHost(localAddress.getHostName());
+                request.serverName().setString(localAddress.getHostName());
+            } else {
+               log.error("host address " + endpoint.getPort() + " '" + endpoint.getAddress() + "'");
+               request.setLocalHost("localhost");
+               request.serverName().setString("localhost");
+            }
             return;
         }
 



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


Re: svn commit: r331098 - /tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java

Posted by Remy Maucherat <re...@apache.org>.
pero@apache.org wrote:
> Author: pero
> Date: Sun Nov  6 01:39:26 2005
> New Revision: 331098
> 
> URL: http://svn.apache.org/viewcvs?rev=331098&view=rev
> Log:
> Fix NPE when simple use only "GET <uri> HTTP/1.0\r\n\r\n"
> 
> Why endpoint.getAddress() don't give back local address?
> Tested at Windows XP with tomcat 5.5.12.

This patch does not make any sense to me, starting with the modified 
condition. I understand it is trying to fix a problem, but this is not a 
good way. -1.

Note: Obviously, the HTTP connector has the same code.

Rémy

> Modified: tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
> URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=331098&r1=331097&r2=331098&view=diff
> ==============================================================================
> --- tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
> +++ tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java Sun Nov  6 01:39:26 2005
> @@ -830,7 +830,7 @@
>       */
>      public void parseHost(MessageBytes valueMB) {
>  
> -        if (valueMB == null || valueMB.isNull()) {
> +        if (valueMB == null || (valueMB != null && valueMB.isNull()) ) {
>              // HTTP/1.0
>              // Default is what the socket tells us. Overriden if a host is
>              // found/parsed
> @@ -838,8 +838,14 @@
>              InetAddress localAddress = endpoint.getAddress()/*socket.getLocalAddress()*/;
>              // Setting the socket-related fields. The adapter doesn't know
>              // about socket.
> -            request.setLocalHost(localAddress.getHostName());
> -            request.serverName().setString(localAddress.getHostName());
> +            if(localAddress != null) {
> +                request.setLocalHost(localAddress.getHostName());
> +                request.serverName().setString(localAddress.getHostName());
> +            } else {
> +               log.error("host address " + endpoint.getPort() + " '" + endpoint.getAddress() + "'");
> +               request.setLocalHost("localhost");
> +               request.serverName().setString("localhost");
> +            }
>              return;
>          }
>  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 
> 
> 


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