NO-JIRA Fix NPE seen in test case logs

This commit is contained in:
Michael André Pearce 2018-10-10 07:56:56 +01:00 committed by Michael Andre Pearce
parent 0d665b5321
commit b2af19db2d
1 changed files with 10 additions and 10 deletions

View File

@ -32,6 +32,7 @@ public class AddressInfo {
private boolean autoCreated = false;
private static final EnumSet<RoutingType> EMPTY_ROUTING_TYPES = EnumSet.noneOf(RoutingType.class);
private EnumSet<RoutingType> routingTypes;
private RoutingType firstSeen;
@ -91,26 +92,25 @@ public class AddressInfo {
}
public EnumSet<RoutingType> getRoutingTypes() {
return routingTypes;
return routingTypes == null ? EMPTY_ROUTING_TYPES : routingTypes;
}
public AddressInfo setRoutingTypes(EnumSet<RoutingType> routingTypes) {
public AddressInfo setRoutingTypes(final EnumSet<RoutingType> routingTypes) {
this.routingTypes = routingTypes;
if (!routingTypes.isEmpty()) {
this.firstSeen = this.routingTypes.iterator().next();
if (routingTypes != null && !routingTypes.isEmpty()) {
this.firstSeen = routingTypes.iterator().next();
} else {
this.firstSeen = null;
}
return this;
}
public AddressInfo addRoutingType(RoutingType routingType) {
public AddressInfo addRoutingType(final RoutingType routingType) {
if (routingType != null) {
if (routingTypes == null) {
if (routingTypes == null || routingTypes.isEmpty()) {
routingTypes = EnumSet.of(routingType);
firstSeen = routingType;
} else {
if (routingTypes.isEmpty()) {
firstSeen = routingType;
}
routingTypes.add(routingType);
}
}
@ -127,7 +127,7 @@ public class AddressInfo {
buff.append("Address [name=" + name);
buff.append(", id=" + id);
buff.append(", routingTypes={");
for (RoutingType routingType : routingTypes) {
for (RoutingType routingType : getRoutingTypes()) {
buff.append(routingType.toString() + ",");
}
// delete hanging comma