#vulnerable code 
                                public void produce( final DataConsumer pReceiver ) throws IOException {

        TarInputStream archiveInputStream = null;
        try {
            archiveInputStream = new TarInputStream(getCompressedInputStream(new FileInputStream(archive)));

            while(true) {
                
                TarEntry entry = archiveInputStream.getNextEntry();

                if (entry == null) {
                    break;
                }

                if (!isIncluded(entry.getName())) {
                    continue;                   
                }               

                entry = map(entry);
                
                if (entry.isDirectory()) {
                    pReceiver.onEachDir(entry.getName(), entry.getLinkName(), entry.getUserName(), entry.getUserId(), entry.getGroupName(), entry.getGroupId(), entry.getMode(), entry.getSize());
                    continue;
                }
                pReceiver.onEachFile(archiveInputStream, entry.getName(), entry.getLinkName(), entry.getUserName(), entry.getUserId(), entry.getGroupName(), entry.getGroupId(), entry.getMode(), entry.getSize());                      
            }

        } finally {
            if (archiveInputStream != null) {
                archiveInputStream.close();
            }
        }       
    } 
                            #location 5 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void produce( final DataConsumer pReceiver ) throws IOException {

    	InputStream is = new BufferedInputStream(new FileInputStream(archive));
    	
    	CompressorInputStream compressorInputStream = null; 
    		
    	try {
    		// FIXME remove once commons 1.1 is out
    		
    		final String fn = archive.getName();
    		if (fn.endsWith("gz")) {
    			compressorInputStream = new CompressorStreamFactory().createCompressorInputStream("gz", is);
    		} else if (fn.endsWith("bz2")){
    			compressorInputStream = new CompressorStreamFactory().createCompressorInputStream("bzip2", is);
    		}

    		// compressorInputStream = new CompressorStreamFactory().createCompressorInputStream(is);    		
    	
    	} catch(CompressorException e) {
    	}
    	
    	if (compressorInputStream != null) {
    		is = new BufferedInputStream(compressorInputStream);
    	}
    	
    	ArchiveInputStream archiveInputStream = null;
    	
    	try {
    		archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(is);
    	} catch(ArchiveException e) {
            throw new IOException("Unsupported archive format : " + archive, e);    		
    	}

    	EntryConverter converter = null;
    	
    	if (archiveInputStream instanceof TarArchiveInputStream) {

    		converter = new EntryConverter() {
    	        public TarEntry convert(ArchiveEntry entry) {
    	        	TarArchiveEntry src = (TarArchiveEntry)entry;
	        		TarEntry dst = new TarEntry(entry.getName());

	        		dst.setSize(src.getSize());
	        		dst.setGroupName(src.getGroupName());
	        		dst.setGroupId(src.getGroupId());
	        		dst.setUserId(src.getUserId());
	        		dst.setMode(src.getMode());
	        		dst.setModTime(src.getModTime());

	        		return dst;
    	        }
            };    	
    	
    	} else {
            throw new IOException("Unsupported archive format : " + archive);    		
    	}
    	
    	
        try {
            while(true) {
                
            	ArchiveEntry archiveEntry = archiveInputStream.getNextEntry();

                if (archiveEntry == null) {
                    break;
                }

                if (!isIncluded(archiveEntry.getName())) {
                    continue;                   
                }               

                TarEntry entry = converter.convert(archiveEntry);
                
                entry = map(entry);
                
                if (entry.isDirectory()) {
                    pReceiver.onEachDir(entry.getName(), entry.getLinkName(), entry.getUserName(), entry.getUserId(), entry.getGroupName(), entry.getGroupId(), entry.getMode(), entry.getSize());
                    continue;
                }
                pReceiver.onEachFile(archiveInputStream, entry.getName(), entry.getLinkName(), entry.getUserName(), entry.getUserId(), entry.getGroupName(), entry.getGroupId(), entry.getMode(), entry.getSize());                      
            }

        } finally {
            if (archiveInputStream != null) {
                archiveInputStream.close();
            }
        }       
    }