[Bug Fix]Check NullPointer Exception at driver pipeliner
Change-Id: I6aac0e2f7844e03f4e833cd165fa74d9904b04e8
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/AristaPipeliner.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/AristaPipeliner.java
index a1d67c9..644d804 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/AristaPipeliner.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/AristaPipeliner.java
@@ -38,21 +38,22 @@
private final Logger log = getLogger(getClass());
private ServiceDirectory serviceDirectory;
private DeviceId deviceId;
+ protected DeviceService deviceService;
- protected DeviceService deviceSetvice;
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
+ super.init(deviceId, context);
this.deviceId = deviceId;
this.serviceDirectory = context.directory();
- this.deviceSetvice = serviceDirectory.get(DeviceService.class);
+ deviceService = serviceDirectory.get(DeviceService.class);
}
@Override
public void forward(ForwardingObjective forwardObjective) {
ForwardingObjective newFwd = forwardObjective;
+ Device device = deviceService.getDevice(deviceId);
- Device device = deviceSetvice.getDevice(deviceId);
if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) {
log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch"
+ " removing the clear deferred from the forwarding objective",
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/CiscoN9kPipeliner.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/CiscoN9kPipeliner.java
index 60f27ca..8ac7473 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/CiscoN9kPipeliner.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/CiscoN9kPipeliner.java
@@ -38,16 +38,16 @@
private final Logger log = getLogger(getClass());
private ServiceDirectory serviceDirectory;
private DeviceId deviceId;
-
protected DeviceService deviceService;
+
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
+ super.init(deviceId, context);
this.deviceId = deviceId;
this.serviceDirectory = context.directory();
- this.deviceService = serviceDirectory.get(DeviceService.class);
+ deviceService = serviceDirectory.get(DeviceService.class);
}
-
@Override
public void forward(ForwardingObjective forwardObjective) {
ForwardingObjective newFwd = forwardObjective;
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/JuniperQfx5100Pipeliner.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/JuniperQfx5100Pipeliner.java
index 76a717d..549dbfe 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/JuniperQfx5100Pipeliner.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/JuniperQfx5100Pipeliner.java
@@ -58,14 +58,15 @@
private ServiceDirectory serviceDirectory;
private DeviceId deviceId;
private FlowRuleService flowRuleService;
-
protected DeviceService deviceService;
+
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
+ super.init(deviceId, context);
this.deviceId = deviceId;
this.serviceDirectory = context.directory();
this.flowRuleService = serviceDirectory.get(FlowRuleService.class);
- this.deviceService = serviceDirectory.get(DeviceService.class);
+ deviceService = serviceDirectory.get(DeviceService.class);
}
@Override
@@ -80,8 +81,8 @@
FlowRuleOperations.Builder flowOpsBuilder = FlowRuleOperations.builder();
ForwardingObjective newFwd = forwardObjective;
-
Device device = deviceService.getDevice(deviceId);
+
if (forwardObjective.treatment() != null && forwardObjective.treatment().clearedDeferred()) {
log.warn("Using 'clear actions' instruction which is not supported by {} {} {} Switch",
device.id(), device.manufacturer(), device.hwVersion());