[jboss-remoting-commits] JBoss Remoting SVN: r5716 - remoting2/branches/2.2/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Feb 17 14:11:29 EST 2010


Author: ron.sigal at jboss.com
Date: 2010-02-17 14:11:28 -0500 (Wed, 17 Feb 2010)
New Revision: 5716

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java
Log:
JBREM-1180: Checks for null host, possibly indicating an ill-formed URI.

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java	2010-02-17 15:50:32 UTC (rev 5715)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java	2010-02-17 19:11:28 UTC (rev 5716)
@@ -235,6 +235,11 @@
    public static final String LEGACY_PARSING = "legacyParsing";
    
    /**
+    * Constant to determine if warning about null host should be logged.
+    */
+   public static final String SUPPRESS_HOST_WARNING = "suppressHostWarning";
+   
+   /**
     * Constructs the object used to identify a remoting server via simple uri format string (e.g. socket://myhost:7000).
     * Note: the uri passed may not always be the one returned via call to getLocatorURI() as may need to change if
     * port not specified, host is 0.0.0.0, etc.  If need original uri that is passed to this constructor, need to
@@ -310,6 +315,7 @@
       {
          URI uri = new URI(encodePercent(uriString));
          protocol = uri.getScheme();
+         checkHost(originalURL, uri.getHost());
          host = decodePercent(resolveHost(uri.getHost()));
          port = uri.getPort();
          path = uri.getPath();
@@ -384,6 +390,17 @@
       }
             }
 
+   private static void checkHost(String uri, String host)
+   {
+      if (host == null && !Boolean.getBoolean(SUPPRESS_HOST_WARNING))
+      {
+         StringBuffer sb = new StringBuffer("Host resolves to null in ");
+         sb.append(uri).append(". Perhaps the host contains an invalid character.  ");
+         sb.append("See http://www.ietf.org/rfc/rfc2396.txt.");
+         log.warn(sb.toString());
+      }
+   }
+   
    private static final String resolveHost(String host)
    {
       if (host == null)



More information about the jboss-remoting-commits mailing list