#vulnerable code 
                                @Test
    public void checkWillMessageIsWiredOnClientKeepAliveExpiry() throws Exception {
        LOG.info("*** checkWillMessageIsWiredOnClientKeepAliveExpiry ***");
        String willTestamentTopic = "/will/test";
        String willTestamentMsg = "Bye bye";
        
        m_willSubscriber.connect();
        m_willSubscriber.subscribe(willTestamentTopic, 0);
        
        int keepAlive = 2; //secs
        ConnectMessage connectMessage = new ConnectMessage();
        connectMessage.setProtocolVersion((byte) 3);
        connectMessage.setClientID("FAKECLNT");
        connectMessage.setKeepAlive(keepAlive);
        connectMessage.setWillFlag(true);
        connectMessage.setWillMessage(willTestamentMsg.getBytes());
        connectMessage.setWillTopic(willTestamentTopic);
        connectMessage.setWillQos(QOSType.MOST_ONE.byteValue());
        
        //Execute
        m_client.sendMessage(connectMessage);
        long connectTime = System.currentTimeMillis();

        //but after the 2 KEEP ALIVE timeout expires it gets fired,
        //NB it's 1,5 * KEEP_ALIVE so 3 secs and some millis to propagate the message
        MqttMessage msg = m_messageCollector.getMessage(3300);
        long willMessageReceiveTime = System.currentTimeMillis();
        if (msg == null) {
            LOG.warn("testament message is null");
        }
        assertNotNull("the will message should be fired after keep alive!", msg);
        //the will message hasn't to be received before the elapsing of Keep Alive timeout
        assertTrue(willMessageReceiveTime - connectTime  > 3000);
        
        assertEquals(willTestamentMsg, new String(msg.getPayload()));
        m_willSubscriber.disconnect();
    } 
                            #location 35 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Test
    public void checkWillMessageIsWiredOnClientKeepAliveExpiry() throws Exception {
        LOG.info("*** checkWillMessageIsWiredOnClientKeepAliveExpiry ***");
        String willTestamentTopic = "/will/test";
        String willTestamentMsg = "Bye bye";
        
        m_willSubscriber.connect();
        m_willSubscriber.subscribe(willTestamentTopic, 0);
        
        connect(willTestamentTopic, willTestamentMsg);
        long connectTime = System.currentTimeMillis();

        //but after the 2 KEEP ALIVE timeout expires it gets fired,
        //NB it's 1,5 * KEEP_ALIVE so 3 secs and some millis to propagate the message
        MqttMessage msg = m_messageCollector.getMessage(3300);
        long willMessageReceiveTime = System.currentTimeMillis();
        assertNotNull("the will message should be fired after keep alive!", msg);
        //the will message hasn't to be received before the elapsing of Keep Alive timeout
        assertTrue(willMessageReceiveTime - connectTime  > 3000);
        
        assertEquals(willTestamentMsg, new String(msg.getPayload()));
        m_willSubscriber.disconnect();
    }