Display IP address in range 0-255 and not -127-127
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 25 Mar 2009 13:32:17 +0000 (13:32 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 25 Mar 2009 13:32:17 +0000 (13:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@758249 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/tribes/membership/MemberImpl.java
java/org/apache/catalina/tribes/util/Arrays.java

index 5c1c7bb..8a86648 100644 (file)
@@ -452,7 +452,7 @@ public class MemberImpl implements Member, java.io.Externalizable {
                 if (DO_DNS_LOOKUPS)
                     this.hostname = java.net.InetAddress.getByAddress(host).getHostName();
                 else
-                    this.hostname = org.apache.catalina.tribes.util.Arrays.toString(host);
+                    this.hostname = org.apache.catalina.tribes.util.Arrays.toString(host,0,host.length,true);
                 return this.hostname;
             }catch ( IOException x ) {
                 throw new RuntimeException("Unable to parse hostname.",x);
index 5f2cbf3..e732cb2 100644 (file)
@@ -56,9 +56,14 @@ public class Arrays {
     }
 
     public static String toString(byte[] data, int offset, int length) {
+        return toString(data,offset,length,false);
+    }
+    
+    public static String toString(byte[] data, int offset, int length, boolean asInt) {
         StringBuffer buf = new StringBuffer("{");
         if ( data != null && length > 0 ) {
-            buf.append(data[offset++]);
+            if (asInt) buf.append((int)data[offset++]);
+            else buf.append(data[offset++]);
             for (int i = offset; i < length; i++) {
                 buf.append(", ").append(data[i]);
             }
@@ -66,7 +71,7 @@ public class Arrays {
         buf.append("}");
         return buf.toString();
     }
-    
+
     public static String toString(Object[] data) {
         return toString(data,0,data!=null?data.length:0);
     }