You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ivan Pryvalov <i....@smiss.com.ua> on 2009/05/21 17:13:47 UTC

ZipFileObject does not release resources

Hello!


I use commons-vfs (1.1-SNAPSHOT branch) and found that ZipFileObject does not release resources correctly...


See code of test-class (File newFile = new File(...); it is any zip file with 1 or more file inside):

/////////////////////////////////////
		//code test
		
		FileSystemManager fsManager = VFS.getManager();		
		FileObject fileObject = fsManager.toFileObject(newFile);
		System.out.println("original file : "+fileObject.getURL());
		FileObject zipFileObject = fsManager.resolveFile("zip:"+fileObject.getURL());		
		FileObject[] fileObjects = zipFileObject.getChildren();		
		FileObject zipEntry = fileObjects[0];
		System.out.println("zip entry : "+zipEntry.getURL());
		
		// open stream!!!!
		zipEntry.getContent().getInputStream();
		
		//now try to close opened input stream...
		zipEntry.getContent().close();
		zipEntry.close();				
		
		//only this one works
		//VFS.getManager().closeFileSystem(zipFileObject.getFileSystem());
		
		
		//test to rename
		
		File newFile2 = new File(newFile.getParentFile(), newFile.getName()+"_2");
		
		System.out.println("newFile.exists() = "+newFile.exists());		
		System.out.println("newFile2.exists() = "+newFile2.exists());
		
		boolean result = newFile.renameTo(newFile2);
		System.out.println("newFile.renameTo(newFile2)="+result);
		
		assertTrue(result);
		
		
		/////end snippet test
		//////////////////////////////////////////

Truly yours,
Ivan Pryvalov.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org