commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Pryvalov <i.pryva...@smiss.com.ua>
Subject ZipFileObject does not release resources
Date Thu, 21 May 2009 15:13:47 GMT
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


Mime
View raw message