diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java
index bf897567280040891f82cf0997dd793a33b1af6b..fb7cd7d44d2167386a78534725956737adffdaad 100644
--- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java
+++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java
@@ -374,6 +374,16 @@ public interface IOFSwitch {
      * @return value for name
      */
     Object getAttribute(String name);
+    
+    /**
+     * Check if the given attribute is present and if so whether it is equal
+     * to "other"
+     * @param name the name of the attribute to check
+     * @param other the object to compare the attribute against.
+     * @return true iff the specified attribute is set and equals() the given
+     * other object.
+     */
+    boolean attributeEquals(String name, Object other);
 
     /**
      * Set properties for switch specific behavior
diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
index 95f20f424e1a8e9b698067ab64a711a9be0a3f09..8998472cfc808bbcf5dac4e8b4f1c08f953626d4 100644
--- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
+++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
@@ -147,13 +147,20 @@ public abstract class OFSwitchBase implements IOFSwitch {
         this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, new Boolean(true));
     }
     
+    
+    @Override
+    public boolean attributeEquals(String name, Object other) {
+        Object attr = this.attributes.get(name);
+        if (attr == null)
+            return false;
+        return attr.equals(other);
+    }
+    
 
     @Override
     public Object getAttribute(String name) {
-        if (this.attributes.containsKey(name)) {
-            return this.attributes.get(name);
-        }
-        return null;
+        // returns null if key doesn't exist
+        return this.attributes.get(name);
     }
     
     @Override
@@ -172,6 +179,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
         return this.attributes.containsKey(name);
     }
         
+    @Override
     @JsonIgnore
     public void setChannel(Channel channel) {
         this.channel = channel;
@@ -452,6 +460,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
         this.floodlightProvider = floodlightProvider;
     }
     
+    @Override
     @JsonIgnore
     public void setThreadPoolService(IThreadPoolService tp) {
         this.threadPool = tp;
@@ -560,6 +569,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
      * switch list from being modified out from under the listeners.
      * @return 
      */
+    @Override
     @JsonIgnore
     public Lock getListenerReadLock() {
         return listenerLock.readLock();
@@ -572,6 +582,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
      * message from the switch.
      * @return
      */
+    @Override
     @JsonIgnore
     public Lock getListenerWriteLock() {
         return listenerLock.writeLock();
@@ -581,6 +592,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
      * Get the IP Address for the switch
      * @return the inet address
      */
+    @Override
     @JsonSerialize(using=ToStringSerializer.class)
     public SocketAddress getInetAddress() {
         return channel.getRemoteAddress();
diff --git a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
index f9ec793b3ba9797ec06912dc5579772fccd15fb1..a65b28f6c1788ee351726038193b11999d045dcc 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/RoleChanger.java
@@ -187,7 +187,7 @@ public class RoleChanger {
     @LogMessageDoc(level="ERROR",
                    message="RoleRequestWorker task had an uncaught exception.",
                    explanation="An unknown occured while processing an HA " +
-                   		"role change event.",
+                               "role change event.",
                    recommendation=LogMessageDoc.GENERIC_ACTION)                              
     protected class RoleRequestWorker extends Thread  {
         @Override
@@ -278,7 +278,7 @@ public class RoleChanger {
             message="Failed to send role request message " + 
                     "to switch {switch}: {message}. Disconnecting",
             explanation="An I/O error occurred while attempting to change " +
-            		"the switch HA role.",
+                        "the switch HA role.",
             recommendation=LogMessageDoc.CHECK_SWITCH)                              
     protected void sendRoleRequest(Collection<IOFSwitch> switches,
                                    Role role, long cookie) {
@@ -331,7 +331,7 @@ public class RoleChanger {
             message="Timeout while waiting for role reply from switch {switch}."
                     + " Disconnecting",
             explanation="Timed out waiting for the switch to respond to " +
-            		"a request to change the HA role.",
+                        "a request to change the HA role.",
             recommendation=LogMessageDoc.CHECK_SWITCH)                              
     protected void verifyRoleReplyReceived(Collection<IOFSwitch> switches,
                                    long cookie) {
@@ -425,8 +425,11 @@ public class RoleChanger {
      * @return 
      */
     public boolean checkFirstPendingRoleRequestXid (IOFSwitch sw, int xid) {
-        LinkedList<PendingRoleRequestEntry> pendingRoleRequests =
-                pendingRequestMap.get(sw);
+        LinkedList<PendingRoleRequestEntry> pendingRoleRequests;
+        if (sw == null) {
+            return false;
+        }
+        pendingRoleRequests = pendingRequestMap.get(sw);
         if (pendingRoleRequests == null) {
             return false;
         }
diff --git a/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java b/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java
index cb446b2a9ec19cd46d59620e8b160e5e1ef3f4a7..037e816897b7a080212a89803cadf6485d4da659 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/RoleChangerTest.java
@@ -390,6 +390,19 @@ public class RoleChangerTest {
                 roleChanger.checkFirstPendingRoleRequestXid(sw, xid));
     }
     
+    @Test
+    public void testCheckFirstPendingRoleRequestNullSw() {
+        int xid = 54321;
+        long cookie = 232323;
+        Role role = Role.MASTER;
+        OFSwitchImpl sw = new OFSwitchImpl();
+        setupPendingRoleRequest(sw, xid, role, cookie);
+        // pass null as sw object, which is true during handshake
+        assertEquals(false,
+                roleChanger.checkFirstPendingRoleRequestXid(null, xid));
+        roleChanger.pendingRequestMap.get(sw).clear();
+    }
+    
     @Test
     public void testCheckFirstPendingRoleRequestCookie() {
         int xid = 54321;
diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
index 95fc5acedea46df21d8c9b0476dbbc3ee33a7ce3..6fd8e092226b8cebd4988bc0073b4ed9a912d2e6 100644
--- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
+++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java
@@ -398,4 +398,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch {
         return null;
     }
 
+    @Override
+    public boolean attributeEquals(String name, Object other) {
+        fail("Unexpected method call");
+        return false;
+    }
+
 }
\ No newline at end of file