#vulnerable code 
                                @Test
    public void testBasicDecodingFile() throws Exception {
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final IdentityDecoder decoder = new IdentityDecoder(
                channel, inbuf, metrics);

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

        final RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
        final FileChannel fchannel = testfile.getChannel();

        long pos = 0;
        while (!decoder.isCompleted()) {
            final long bytesRead = decoder.transfer(fchannel, pos, 10);
            if (bytesRead > 0) {
                pos += bytesRead;
            }
        }

        Assert.assertEquals(testfile.length(), metrics.getBytesTransferred());
        fchannel.close();

        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));

        deleteWithCheck(fileHandle);
    } 
                            #location 21 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void testBasicDecodingFile() throws Exception {
        final ReadableByteChannel channel = new ReadableByteChannelMock(
                new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII");

        final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, Consts.ASCII);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final IdentityDecoder decoder = new IdentityDecoder(
                channel, inbuf, metrics);

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

        final RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
        final FileChannel fchannel = testfile.getChannel();

        long pos = 0;
        while (!decoder.isCompleted()) {
            final long bytesRead = decoder.transfer(fchannel, pos, 10);
            if (bytesRead > 0) {
                pos += bytesRead;
            }
        }

        Assert.assertEquals(testfile.length(), metrics.getBytesTransferred());
        fchannel.close();

        Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));

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