#vulnerable code 
                                protected void testRawNoBomInvalid(final String encoding) throws Exception {
        final InputStream is = getXmlStream("no-bom", XML3, encoding, encoding);
        try {
            final XmlReader xmlReader = new XmlReader(is, false);
            fail("It should have failed");
        } catch (final IOException ex) {
            assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
        }
    } 
                            #location 4 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                protected void testRawNoBomInvalid(final String encoding) throws Exception {
        InputStream is = null;
        XmlReader xmlReader = null;
        try {
            is = getXmlStream("no-bom", XML3, encoding, encoding);
            xmlReader = new XmlReader(is, false);
            fail("It should have failed");
        } catch (final IOException ex) {
            assertTrue(ex.getMessage().indexOf("Invalid encoding,") > -1);
        } finally {
            if (xmlReader != null) {
                xmlReader.close();
            }
            if (is != null) {
                is.close();
            }
        }
    }