#vulnerable code 
                                public void testBasicDecodingFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII"); 
        HttpParams params = new BasicHttpParams();
        
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params); 
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        IdentityDecoder decoder = new IdentityDecoder(channel, inbuf, metrics); 
        
        File tmpFile = File.createTempFile("testFile", ".txt");
        FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
            
        long bytesRead = decoder.transfer(fchannel, 0, 6);
        assertEquals(6, bytesRead);
        assertEquals("stuff;", readFromFile(tmpFile, 6));
        assertFalse(decoder.isCompleted());
        
        bytesRead = decoder.transfer(fchannel,0 , 10);
        assertEquals(10, bytesRead);
        assertEquals("more stuff", readFromFile(tmpFile, 10));
        assertFalse(decoder.isCompleted());
        
        bytesRead = decoder.transfer(fchannel, 0, 1);
        assertEquals(0, bytesRead);
        assertTrue(decoder.isCompleted());
        
        bytesRead = decoder.transfer(fchannel, 0, 1);
        assertEquals(0, bytesRead);
        assertTrue(decoder.isCompleted());
        
        tmpFile.delete();
    } 
                            #location 32 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void testBasicDecodingFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff; ", "more stuff; ", "a lot more stuff!"}, "US-ASCII"); 
        HttpParams params = new BasicHttpParams();
        
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params); 
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        IdentityDecoder decoder = new IdentityDecoder(
                channel, inbuf, metrics); 
        
        File fileHandle = File.createTempFile("testFile", ".txt");

        RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw"); 
        FileChannel fchannel = testfile.getChannel();
            
        long pos = 0;
        while (!decoder.isCompleted()) {
            long bytesRead = decoder.transfer(fchannel, pos, 10);
            if (bytesRead > 0) {
                pos += bytesRead;
            }
        }
        
        fchannel.close();
        
        assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
        
        fileHandle.delete();
    }