Skip to content

Commit

Permalink
ONOS-5850 Fix annotations null values
Browse files Browse the repository at this point in the history
Change-Id: I324186858cde2ebc16a3a488378ce731cbb82aac
  • Loading branch information
Andrea-Campanella authored and ray-milkey committed Jan 20, 2017
1 parent 1cf1fa4 commit c8b871a
Showing 1 changed file with 10 additions and 8 deletions.
Expand Up @@ -671,19 +671,21 @@ private PortDescription buildPortDescription(PortDescPropertyType ptype, OFExpPo
*
* @param portName the port name
* @param portMac the port mac
* @return annotation containing the port name if one is found,
* null otherwise
* @return annotation containing port name and/or port MAC if any of
* the two is found, empty otherwise
*/
private SparseAnnotations makePortAnnotation(String portName, String portMac) {
SparseAnnotations annotations = null;
DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
String pName = Strings.emptyToNull(portName);
String pMac = Strings.emptyToNull(portMac);
if (portName != null) {
annotations = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, pName)
.set(AnnotationKeys.PORT_MAC, pMac).build();
if (pName != null) {
builder.set(AnnotationKeys.PORT_NAME, pName);
}
return annotations;
if (pMac != null) {
builder.set(AnnotationKeys.PORT_MAC, pMac);
}
//Returns an empty annotation if both pName and pMac are null
return builder.build();
}

/**
Expand Down

0 comments on commit c8b871a

Please sign in to comment.