Buggy code:
public class RSMThread implements Runnable { private static final Logger LOG = LoggerFactory . getLogger ( RSMThread . class ) ; private LacpNodeExtn lacpNode ; private LacpPDUQueue pduQueue ; private LacpTimerQueue timerQueue ; private static final int MAX_PDU_ELM_CNT = 5 ; private static final int MAX_TMR_ELM_CNT = 3 ; private Thread rsm ; private RSMManager rsmMgrRef ; private static final int INT_PRIORITY = - 1 ; public RSMThread ( ) { } public boolean setLacpNode ( LacpNodeExtn lacpNode ) { } public void startRSM ( ) { } public void interruptRSM ( ) { } private LacpBond findLacpBondByPartnerMacKey ( byte [ ] sysId , short key ) { } public void handleLacpBpdu ( LacpBpduInfo lacpBpdu ) { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>Entry<seq2seq4repair_space>-<seq2seq4repair_space>New<seq2seq4repair_space>LacpBpdu<seq2seq4repair_space>received<seq2seq4repair_space>for<seq2seq4repair_space>processing..." ) ; LacpBond bond = null ; long swId = lacpBpdu . getSwId ( ) ; short portId = lacpBpdu . getPortId ( ) ; bond = lacpNode . findLacpBondByPort ( portId ) ; boolean newEntry = false ; LacpSysKeyInfo sysKeyInfo = null ; if ( bond == null ) { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>Entry<seq2seq4repair_space>-<seq2seq4repair_space>bond<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>based<seq2seq4repair_space>on<seq2seq4repair_space>portId={}" , portId ) ; byte [ ] sysId = lacpBpdu . getActorSystemInfo ( ) . getNodeSysAddr ( ) ; short key = lacpBpdu . getActorSystemInfo ( ) . getNodeKey ( ) ; sysKeyInfo = new LacpSysKeyInfo ( sysId , key ) ; bond = findLacpBondByPartnerMacKey ( sysId , key ) ; if ( bond == null ) { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>couldn't<seq2seq4repair_space>find<seq2seq4repair_space>lacpBond<seq2seq4repair_space>for<seq2seq4repair_space>partner<seq2seq4repair_space>with<seq2seq4repair_space>sysId={}<seq2seq4repair_space>key={}" , sysId , key ) ; bond = lacpNode . findLacpBondBySystemKey ( sysKeyInfo ) ; } else { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>bond<seq2seq4repair_space>found<seq2seq4repair_space>by<seq2seq4repair_space>partner<seq2seq4repair_space>mac<seq2seq4repair_space>key<seq2seq4repair_space>partner<seq2seq4repair_space>with<seq2seq4repair_space>sysId={}<seq2seq4repair_space>key={}" , sysId , key ) ; } if ( bond != null ) { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>LACP<seq2seq4repair_space>Bond<seq2seq4repair_space>is<seq2seq4repair_space>found<seq2seq4repair_space>sysId={},<seq2seq4repair_space>key={}" , LacpConst . toHex ( sysId ) , String . format ( "0x%04x" , key ) ) ; bond . bondAddSlave ( swId , portId , 255 , lacpBpdu ) ; bond . bondUpdateLinkUpSlave ( swId , portId ) ; if ( ( lacpNode . addLacpBondToPortList ( portId , bond ) ) == null ) { newEntry = true ; RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>bond={}<seq2seq4repair_space>added<seq2seq4repair_space>for<seq2seq4repair_space>given<seq2seq4repair_space>port={}" , bond , String . format ( "0x%04x" , portId ) ) ; } } else { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>LACP<seq2seq4repair_space>Bond<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>sysId={},<seq2seq4repair_space>key={}" , LacpConst . toHex ( sysId ) , String . format ( "0x%04x" , key ) ) ; RSMThread . LOG . debug ( "LACP<seq2seq4repair_space>Bond<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>for<seq2seq4repair_space>portId={}<seq2seq4repair_space>" , portId ) ; <START_BUG> int bondPriority = ( rsmMgrRef . getMidSysPriority ( ) ) & ( RSMThread . INT_PRIORITY ) ; <END_BUG> bond = LacpBond . newInstance ( bondPriority , ( ( short ) ( rsmMgrRef . getGlobalLacpkey ( ) ) ) , lacpNode ) ; rsmMgrRef . incGlobalLacpKey ( ) ; newEntry = true ; bond . bondAddSlave ( swId , portId , 255 , lacpBpdu ) ; RSMThread . LOG . debug ( "LacpBond<seq2seq4repair_space>with<seq2seq4repair_space>key={}<seq2seq4repair_space>is<seq2seq4repair_space>created<seq2seq4repair_space>with<seq2seq4repair_space>system<seq2seq4repair_space>priority={}<seq2seq4repair_space>" , ( ( rsmMgrRef . getGlobalLacpkey ( ) ) - 1 ) , String . format ( "%04x" , bondPriority ) ) ; bond . setLacpEnabled ( true ) ; bond . bondUpdateLinkUpSlave ( swId , portId ) ; lacpNode . addLacpBondToPortList ( portId , bond ) ; sysKeyInfo = new LacpSysKeyInfo ( sysId , key ) ; LacpBond lacpBond = lacpNode . addLacpBondToSysKeyList ( sysKeyInfo , bond ) ; if ( lacpBond != null ) { RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>Exception:<seq2seq4repair_space>bond<seq2seq4repair_space>{}<seq2seq4repair_space>with<seq2seq4repair_space>sysKey<seq2seq4repair_space>{}<seq2seq4repair_space>already<seq2seq4repair_space>exist" , bond . toString ( ) , sysKeyInfo . toString ( ) ) ; } } } if ( bond != null ) { doRxPktProcess ( swId , portId , lacpBpdu , bond ) ; } RSMThread . LOG . debug ( "handleLacpBpdu<seq2seq4repair_space>-<seq2seq4repair_space>Exit..." ) ; } public void doRxPktProcess ( long switchId , short portId , LacpBpduInfo bpduInfo , LacpBond bond ) { } public void handlePortTimeout ( TimerExpiryMessage tmExpiryMsg ) { } public void handleLacpPortState ( LacpPortStatus portState ) { } public void portCleanupInDefaultedState ( long switchId , short portId ) { } public void handleLacpNodeDeletion ( ) { } @ Override public void run ( ) { } public LacpPort getLacpPortForPortId ( short portId ) { } }

Fix:
int bondPriority = ( lacpNode . getLacpSystemPriority ( ) ) & ( RSMThread . INT_PRIORITY ) ;