Skip to content

Commit

Permalink
- Passing the jgroups.bind_addr system property to build.xml
Browse files Browse the repository at this point in the history
- Replacing String.length()  > 0 with isEmpty()
  • Loading branch information
belaban committed Nov 21, 2012
1 parent eda33ea commit ef8df31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions build.xml
Expand Up @@ -409,6 +409,7 @@
>
<jvmarg value="-Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack}"/>
<jvmarg value="-Djava.net.preferIPv6Addresses=${java.net.preferIPv6Addresses}"/>
<jvmarg value="-Djgroups.bind_addr=${jgroups.bind_addr}"/>
<xmlfileset dir="${testng.conf.dir}" includes="byteman.xml"/>
</testng>
</target>
Expand Down
21 changes: 9 additions & 12 deletions src/org/jgroups/stack/Configurator.java
Expand Up @@ -372,7 +372,7 @@ private static List<Protocol> createProtocols(List<ProtocolConfiguration> 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<String,Tuple<TP, ProtocolStack.RefCounter>> singleton_transports=ProtocolStack.getSingletonTransports();
synchronized(singleton_transports) {
if(i > 0) { // crude way to check whether protocol is a transport
Expand Down Expand Up @@ -710,8 +710,6 @@ public static List<InetAddress> getInetAddresses(List<Protocol> 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();
Expand Down Expand Up @@ -770,7 +768,7 @@ public static void setDefaultValues(List<ProtocolConfiguration> 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))
Expand Down Expand Up @@ -804,7 +802,7 @@ public static void setDefaultValues(List<ProtocolConfiguration> 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;
Expand Down Expand Up @@ -853,7 +851,7 @@ public static void setDefaultValues(List<Protocol> 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 {
Expand Down Expand Up @@ -1038,7 +1036,7 @@ static void checkDependencyReferencesPresent(List<AccessibleObject> 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
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -1131,7 +1129,7 @@ public static void resolveAndAssignField(Object obj, Field field, Map<String,Str

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", field.getDeclaringClass().getSimpleName() + "." + field.getName(),
deprecated_msg));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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] ;
}
Expand Down

0 comments on commit ef8df31

Please sign in to comment.