From ef8df315ab566ee960cf312d70a261f0b20e66a2 Mon Sep 17 00:00:00 2001 From: Bela Ban Date: Wed, 21 Nov 2012 18:31:05 +0100 Subject: [PATCH] - Passing the jgroups.bind_addr system property to build.xml - Replacing String.length() > 0 with isEmpty() --- build.xml | 1 + src/org/jgroups/stack/Configurator.java | 21 +++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build.xml b/build.xml index f2b012a4071..1b91b5ff49b 100644 --- a/build.xml +++ b/build.xml @@ -409,6 +409,7 @@ > + diff --git a/src/org/jgroups/stack/Configurator.java b/src/org/jgroups/stack/Configurator.java index dd2538896dc..3d87508d852 100644 --- a/src/org/jgroups/stack/Configurator.java +++ b/src/org/jgroups/stack/Configurator.java @@ -372,7 +372,7 @@ private static List createProtocols(List protoc for(int i=0; i < protocol_configs.size(); i++) { protocol_config=protocol_configs.get(i); singleton_name=protocol_config.getProperties().get(Global.SINGLETON_NAME); - if(singleton_name != null && singleton_name.trim().length() > 0) { + if(singleton_name != null && !singleton_name.trim().isEmpty()) { Map> singleton_transports=ProtocolStack.getSingletonTransports(); synchronized(singleton_transports) { if(i > 0) { // crude way to check whether protocol is a transport @@ -710,8 +710,6 @@ public static List getInetAddresses(List protocols) throw // collect InetAddressInfo for(Protocol protocol : protocols) { - String protocolName=protocol.getName(); - //traverse class hierarchy and find all annotated fields and add them to the list if annotated for(Class clazz=protocol.getClass(); clazz != null; clazz=clazz.getSuperclass()) { Field[] fields=clazz.getDeclaredFields(); @@ -770,7 +768,7 @@ public static void setDefaultValues(List protocol_configs String defaultValue=null; if(InetAddressInfo.isInetAddressRelated(methods[j])) { defaultValue=ip_version == StackType.IPv4? annotation.defaultValueIPv4() : annotation.defaultValueIPv6(); - if(defaultValue != null && defaultValue.length() > 0) { + if(defaultValue != null && !defaultValue.isEmpty()) { Object converted=null; try { if(defaultValue.equalsIgnoreCase(Global.NON_LOOPBACK_ADDRESS)) @@ -804,7 +802,7 @@ public static void setDefaultValues(List protocol_configs String defaultValue=null; if(InetAddressInfo.isInetAddressRelated(protocol, fields[j])) { defaultValue=ip_version == StackType.IPv4? annotation.defaultValueIPv4() : annotation.defaultValueIPv6(); - if(defaultValue != null && defaultValue.length() > 0) { + if(defaultValue != null && !defaultValue.isEmpty()) { // condition for invoking converter if(defaultValue != null || !PropertyHelper.usesDefaultConverter(fields[j])) { Object converted=null; @@ -853,7 +851,7 @@ public static void setDefaultValues(List protocols, StackType ip_versi Property annotation=fields[j].getAnnotation(Property.class); String defaultValue=ip_version == StackType.IPv4? annotation.defaultValueIPv4() : annotation.defaultValueIPv6(); - if(defaultValue != null && defaultValue.length() > 0) { + if(defaultValue != null && !defaultValue.isEmpty()) { // condition for invoking converter Object converted=null; try { @@ -1038,7 +1036,7 @@ static void checkDependencyReferencesPresent(List objects, Map } String dependsClause = annotation.dependsUpon() ; - if (dependsClause.trim().length() == 0) + if (dependsClause.trim().isEmpty()) continue ; // split dependsUpon specifier into tokens; trim each token; search for token in list @@ -1085,7 +1083,7 @@ public static void resolveAndInvokePropertyMethod(Object obj, Method method, Map if(propertyName != null && propertyValue != null) { String deprecated_msg=annotation.deprecatedMessage(); - if(deprecated_msg != null && deprecated_msg.length() > 0) { + if(deprecated_msg != null && !deprecated_msg.isEmpty()) { log.warn(Util.getMessage("Deprecated", method.getDeclaringClass().getSimpleName() + "." + methodName, deprecated_msg)); } @@ -1131,7 +1129,7 @@ public static void resolveAndAssignField(Object obj, Field field, Map 0) { + if(deprecated_msg != null && !deprecated_msg.isEmpty()) { log.warn(Util.getMessage("Deprecated", field.getDeclaringClass().getSimpleName() + "." + field.getName(), deprecated_msg)); @@ -1192,7 +1190,7 @@ private static String grabSystemProp(Property annotation) { String retval=null; for(String system_property_name: system_property_names) { - if(system_property_name != null && system_property_name.length() > 0) { + if(system_property_name != null && !system_property_name.isEmpty()) { if(system_property_name.equals(Global.BIND_ADDR)) if(Util.isBindAddressPropertyIgnored()) continue; @@ -1251,7 +1249,6 @@ public static class InetAddressInfo { this.convertedValue = convertedValue ; // set the property name - Property annotation=fieldOrMethod.getAnnotation(Property.class); if (isField()) propertyName=PropertyHelper.getPropertyName((Field)fieldOrMethod, properties) ; else @@ -1273,7 +1270,7 @@ public static class InetAddressInfo { } else if (!isField() && isParameterized) { // the Method has several parameters (and so types) - Type[] types = (Type[])((Method)fieldOrMethod).getGenericParameterTypes(); + Type[] types =((Method)fieldOrMethod).getGenericParameterTypes(); ParameterizedType mpt = (ParameterizedType) types[0] ; this.baseType = mpt.getActualTypeArguments()[0] ; }