#vulnerable code 
                                @Test
    public void testCodingBeyondContentLimitFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");
        HttpParams params = new BasicHttpParams();

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                channel, inbuf, metrics, 16);

        File fileHandle = File.createTempFile("testFile", ".txt");
        RandomAccessFile testfile  = new RandomAccessFile(fileHandle, "rw");
        FileChannel fchannel = testfile.getChannel();

        long bytesRead = decoder.transfer(fchannel, 0, 6);
        Assert.assertEquals(6, bytesRead);
        Assert.assertFalse(decoder.isCompleted());
        Assert.assertEquals(6, metrics.getBytesTransferred());

        bytesRead = decoder.transfer(fchannel,0 , 10);
        Assert.assertEquals(10, bytesRead);
        Assert.assertTrue(decoder.isCompleted());
        Assert.assertEquals(16, metrics.getBytesTransferred());

        bytesRead = decoder.transfer(fchannel, 0, 1);
        Assert.assertEquals(-1, bytesRead);
        Assert.assertTrue(decoder.isCompleted());
        Assert.assertEquals(16, metrics.getBytesTransferred());

        testfile.close();
        deleteWithCheck(fileHandle);
    } 
                            #location 25 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void testCodingBeyondContentLimitFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");
        HttpParams params = new BasicHttpParams();

        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                channel, inbuf, metrics, 16);

        File fileHandle = File.createTempFile("testFile", ".txt");
        RandomAccessFile testfile  = new RandomAccessFile(fileHandle, "rw");
        FileChannel fchannel = testfile.getChannel();

        long bytesRead = decoder.transfer(fchannel, 0, 6);
        Assert.assertEquals(6, bytesRead);
        Assert.assertFalse(decoder.isCompleted());
        Assert.assertEquals(6, metrics.getBytesTransferred());

        bytesRead = decoder.transfer(fchannel,0 , 10);
        Assert.assertEquals(10, bytesRead);
        Assert.assertTrue(decoder.isCompleted());
        Assert.assertEquals(16, metrics.getBytesTransferred());

        bytesRead = decoder.transfer(fchannel, 0, 1);
        Assert.assertEquals(-1, bytesRead);
        Assert.assertTrue(decoder.isCompleted());
        Assert.assertEquals(16, metrics.getBytesTransferred());

        testfile.close();
        deleteWithCheck(fileHandle);
    }