BGP routepolicy distribution bug fixes.
Change-Id: I2176e3872391658263d6817ac8850a3390de00de
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
index 19f3126..d766f0d 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
@@ -171,15 +171,17 @@
if ((as4pathSet != null) && (as4pathSeq != null)) {
int iAsLenIndex = cb.writerIndex();
cb.writeByte(0);
- cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
- cb.writeByte(as4pathSeq.size());
+ if (as4pathSeq.size() != 0) {
+ cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
+ cb.writeByte(as4pathSeq.size());
- for (int j = 0; j < as4pathSeq.size(); j++) {
- cb.writeInt(as4pathSeq.get(j));
+ for (int j = 0; j < as4pathSeq.size(); j++) {
+ cb.writeInt(as4pathSeq.get(j));
+ }
+
+ int asLen = cb.writerIndex() - iAsLenIndex;
+ cb.setByte(iAsLenIndex, (byte) (asLen - 1));
}
-
- int asLen = cb.writerIndex() - iAsLenIndex;
- cb.setByte(iAsLenIndex, (byte) (asLen - 1));
} else {
cb.writeByte(0);
}