Fixing bug causing potential NPE
Change-Id: Idb2eb4b6f91300cff603b35f0357046f8e5edd3f
diff --git a/ecord/carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetManager.java b/ecord/carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetManager.java
index e1002cb..47e494f 100644
--- a/ecord/carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetManager.java
+++ b/ecord/carrierethernet/src/main/java/org/onosproject/ecord/carrierethernet/app/CarrierEthernetManager.java
@@ -405,9 +405,6 @@
uniIt1.remove();
}
- // Increment the global UNI reference count
- usedUniSet.forEach(uni -> uniMap.get(uni.id()).refCount().incrementAndGet());
-
// Update the EVC UNI set, based on the UNIs actually used
evc.setUniSet(usedUniSet);
@@ -417,6 +414,8 @@
cePktProvisioner.applyBandwidthProfiles(evc);
// Apply the BWPs of the EVC UNI to the global UNIs, creating them if needed
applyBandwidthProfiles(evc.uniSet());
+ // Increment the global UNI reference count
+ usedUniSet.forEach(uni -> uniMap.get(uni.id()).refCount().incrementAndGet());
}
if (evc.state().equals(CarrierEthernetVirtualConnection.State.ACTIVE)) {
@@ -692,9 +691,6 @@
});
fc.setLtpSet(usedLtpSet);
- // Increment the global LTP and corresponding NI refCount
- usedLtpSet.forEach(ltp -> ltpMap.get(ltp.id()).refCount().incrementAndGet());
-
// If no pair was connected, do not register the FC
if (fc.state().equals(CarrierEthernetForwardingConstruct.State.ACTIVE)) {
fcMap.put(fc.id(), fc);
@@ -702,6 +698,8 @@
cePktProvisioner.applyBandwidthProfiles(fc.evcLite());
// Apply the BWPs of the EVC UNI to the global UNIs, creating them if needed
applyBandwidthProfiles(fc.evcLite().uniSet());
+ // Increment the global LTP and corresponding NI refCount
+ usedLtpSet.forEach(ltp -> ltpMap.get(ltp.id()).refCount().incrementAndGet());
}
if (fc.state().equals(CarrierEthernetForwardingConstruct.State.ACTIVE)) {
@@ -923,14 +921,14 @@
return null;
}
if (!deviceService.getDevice(cp.deviceId()).type().equals(Device.Type.SWITCH)) {
- log.error("Could not generate UNI {}: Device {} is not a switch", uniId, cp.deviceId());
+ log.debug("Could not generate UNI {}: Device {} is not a switch", uniId, cp.deviceId());
return null;
}
Port port = deviceService.getPort(cp.deviceId(), cp.port());
if (!port.isEnabled()) {
- log.warn("Could not generate UNI {}: Port {} is not enabled", uniId, port.number().toString());
+ log.debug("Could not generate UNI {}: Port {} is not enabled", uniId, port.number().toString());
return null;
}