Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Printing non-string props (e.g. InetAddresses) correctly (https://iss…

  • Loading branch information...
commit 9b0d0f85a030f398006f7f705251a5e9e47c164b 1 parent 2f6400d
@belaban authored
View
38 src/org/jgroups/conf/PropertyConverters.java
@@ -3,6 +3,7 @@
import org.jgroups.Global;
import org.jgroups.View;
import org.jgroups.stack.Configurator;
+import org.jgroups.stack.IpAddress;
import org.jgroups.stack.Protocol;
import org.jgroups.util.StackType;
import org.jgroups.util.Util;
@@ -10,6 +11,7 @@
import java.lang.reflect.Field;
import java.net.*;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.Callable;
@@ -64,7 +66,21 @@ public Object convert(Object obj, Class<?> propertyFieldType, String propertyNam
}
public String toString(Object value) {
- return value.getClass().getName();
+ if(value instanceof Collection) {
+ StringBuilder sb=new StringBuilder();
+ Collection<IpAddress> list=(Collection<IpAddress>)value;
+ boolean first=true;
+ for(IpAddress addr: list) {
+ if(first)
+ first=false;
+ else
+ sb.append(",");
+ sb.append(addr.getIpAddress().getHostAddress()).append("[").append(addr.getPort()).append("]");
+ }
+ return sb.toString();
+ }
+ else
+ return value.getClass().getName();
}
private static int getPortRange(Protocol protocol) throws Exception {
@@ -81,8 +97,22 @@ public Object convert(Object obj, Class<?> propertyFieldType, String propertyNam
}
public String toString(Object value) {
- return value.getClass().getName();
- }
+ if(value instanceof Collection) {
+ StringBuilder sb=new StringBuilder();
+ Collection<InetSocketAddress> list=(Collection<InetSocketAddress>)value;
+ boolean first=true;
+ for(InetSocketAddress addr: list) {
+ if(first)
+ first=false;
+ else
+ sb.append(",");
+ sb.append(addr.getAddress().getHostAddress()).append("[").append(addr.getPort()).append("]");
+ }
+ return sb.toString();
+ }
+ else
+ return value.getClass().getName();
+ }
}
public static class BindInterface implements PropertyConverter {
@@ -282,6 +312,8 @@ protected static Inet6Address getScopedInetAddress(Inet6Address addr) {
}
public String toString(Object value) {
+ if(value instanceof InetAddress)
+ return ((InetAddress)value).getHostAddress();
return value != null? value.toString() : null;
}
}
View
4 src/org/jgroups/conf/ProtocolConfiguration.java
@@ -50,8 +50,10 @@ public ProtocolConfiguration(String config_str) throws Exception {
public ProtocolConfiguration(String protocol_name, Map<String,String> properties) {
this.protocol_name=protocol_name;
- if(!properties.isEmpty())
+ if(!properties.isEmpty()) {
this.properties.putAll(properties);
+ properties_str=propertiesToString();
+ }
}
public String getProtocolName() {
Please sign in to comment.
Something went wrong with that request. Please try again.