#vulnerable code 
                                @Test
    public void testReadingXmlWithCustomNamespace() throws Exception {
        xmlRecordReader.close();
        xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml"));
        xmlRecordReader.open();

        XmlRecord record = xmlRecordReader.readRecord();
        assertThat(record.getPayload()).isXmlEqualTo("<bean id=\"foo\" class=\"java.lang.String\"><description>foo bean</description></bean>");

        record = xmlRecordReader.readRecord();
        assertThat(record.getPayload()).isXmlEqualTo("<bean id=\"bar\" class=\"java.lang.String\"/>");

        record = xmlRecordReader.readRecord();
        assertThat(record).isNull();

    } 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Test
    public void testReadingXmlWithCustomNamespace() throws Exception {
        // given
        xmlRecordReader = new XmlRecordReader("bean", getDataSource("/beans.xml"));
        xmlRecordReader.open();

        // when
        XmlRecord record1 = xmlRecordReader.readRecord();
        XmlRecord record2 = xmlRecordReader.readRecord();
        XmlRecord record3 = xmlRecordReader.readRecord();

        // then
        assertThat(record1.getPayload()).isXmlEqualTo("<bean id=\"foo\" class=\"java.lang.String\"><description>foo bean</description></bean>");
        assertThat(record2.getPayload()).isXmlEqualTo("<bean id=\"bar\" class=\"java.lang.String\"/>");
        assertThat(record3).isNull();

    }