#vulnerable code 
                                @Test
    public void testWriteBeyondFileSize() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"a"}, "US-ASCII");
        HttpParams params = new BasicHttpParams();

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

        File fileHandle = File.createTempFile("testFile", ".txt");

        RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
        FileChannel fchannel = testfile.getChannel();
        Assert.assertEquals(0, testfile.length());

        try {
            decoder.transfer(fchannel, 5, 10);
            Assert.fail("expected IOException");
        } catch(IOException iox) {}

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

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

        createTempFile();
        RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
        try {
            FileChannel fchannel = testfile.getChannel();
            Assert.assertEquals(0, testfile.length());
            try {
                decoder.transfer(fchannel, 5, 10);
                Assert.fail("IOException should have been thrown");
            } catch(IOException expected) {
            }
        } finally {
            testfile.close();
        }
    }