jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JCR-3568) Property.getBinary().getStream() files in tempDir not removed by InputStream.close() nor by Binary.dispose()
Date Thu, 18 Apr 2013 09:25:17 GMT

    [ https://issues.apache.org/jira/browse/JCR-3568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13635016#comment-13635016
] 

Jukka Zitting commented on JCR-3568:
------------------------------------

> But the resulting Class javax.jcr.Binary does not offer any means to maintain the created
file to the caller.

See Binary.dispose() [1]. I guess what you're reporting here is that the dispose() method
as implemented by the WebDAV client layer doesn't work properly. What specific version of
Jackrabbit libraries are you using when running the test case?

[1] http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/Binary.html#dispose()
                
> Property.getBinary().getStream() files in tempDir not removed by InputStream.close()
nor by Binary.dispose() 
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: JCR-3568
>                 URL: https://issues.apache.org/jira/browse/JCR-3568
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-webdav
>    Affects Versions: 2.6
>         Environment: Windows 7 Pro, Java 6.0.39, WebDAV, JCR 2.0
>            Reporter: Ulrich Schmidt
>
> I need to inspect the the files stored to the jcr:data-Property in Node jcr:content which
is a subnode of a nt:fille-Node. Access mode is WebDAV using JCR 2.0-API.
> Jackrabbit does not drop the tempfiles created by the command Property.getBinary().getStream()
by the closing instruchtions InputStream.close() nor Binary.dispose(). I get a RepositoryException
"No space left on device" when der tempsace becomes full.
> The executed code is;
> public class DownloadLoopMain {
> 	private final static Logger LOGGER = LoggerFactory.getLogger("Test.DownloadLoopMain");
> 	String repository = "http://localhost:8080/server";
> 	String user="admin";
> 	String password="admin";
> 	Session session;
> 	File temp = new File(System.getProperty("java.io.tmpdir"));
> 	List<String> nodeList = new ArrayList<String>();
> 	public DownloadLoopMain() throws Exception {
> 		LOGGER.info("TempDir=" + temp.getPath());
> 		long totalsize=0;
> 		
> 		connectRepository();
> 		buildNodeList();
> 		List<String[]> tempfiles = getTempFiles(temp.listFiles());
> 		LOGGER.info("Start with number of files in Tempdir:" + tempfiles.size());
> 		for (String node : nodeList) {			
> 			LOGGER.info("Retrieve node " + node);
> 			Node currentNode=session.getNode(node);
> 			Node fileNode = currentNode.getNode("jcr:content");
> 			Property jcrdata = fileNode.getProperty("jcr:data");
> 			Binary fileBin=jcrdata.getBinary();
> 			long filesize=fileBin.getSize();
> 			totalsize+=filesize;
> 			InputStream file = fileBin.getStream();
> 			
> 			LOGGER.info("Now we have number of files in Tempdir:" + tempfiles.size());		
> 			
> 			List<String[]> newTempfiles = getTempFiles(temp.listFiles());
> 			// Display new files in temp-directory
> 			compareTempfiles("new", newTempfiles, tempfiles);
> 			
> 			// Display files gone from temp-directory
> 			compareTempfiles("gone", tempfiles, newTempfiles);
> 			
> 			tempfiles=newTempfiles;
> 			
> 			file.close();
> 			fileBin.dispose();
> 		}
> 	}
> 	
> 	
> 	/**
> 	 * Compare List of tempfiles.
> 	 * @param intend
> 	 * @param list1
> 	 * @param list2
> 	 */
> 	public void compareTempfiles(String intend, List<String[]> list1, List<String[]>
list2 ) {
> 		for (String[] list1file : list1) {
> 			boolean known=false;
> 			for (int i=0; i< list2.size(); i++) {
> 				String[] list2file=list2.get(i);
> 				if (list1file[0].equals(list2file[0])) {
> 					known=true;
> 					break;
> 				}
> 			}
> 			if (!known) {
> 				LOGGER.info(intend + " tempfile=" + list1file[0]+ " " + list1file[1]);
> 			}
> 		}
> 	}
> 	public List<String[]> getTempFiles(File[] files) {
> 		List<String[]> filesList = new ArrayList<String[]>();
> 		for (File file : files) {
> 			String[] filedesc = new String[2];
> 			filedesc[0]=file.getName();
> 			filedesc[1]=file.length()+"";
> 			filesList.add(filedesc);
> 		}
> 		return filesList;
> 	}
> 	
> 	public void buildNodeList() throws IOException {
> 		String path ="E:/Jackrabbit/logs/Populate-Files.log";
> 		File file = new File(path);
> 		BufferedReader br = new BufferedReader(new FileReader(file));
> 		String line;
> 		while ((line=br.readLine())!=null) {
> 			nodeList.add(line);
> 		}
> 		br.close();
> 		String knownPath="/content/dam/ebase/privatebase/en/media/franz/2012/11_november/1211_VV-Interview_en_640x320_VP8.webm/jcr:content/renditions/original";
	
> 	}
> 	private void connectRepository() throws Exception {
> 		LOGGER.info("About ot connect to " + this.repository);
> 		Repository repository = org.apache.jackrabbit.commons.JcrUtils.getRepository(this.repository);
> 		char[] password=this.password.toCharArray();
> 		Credentials cred= new SimpleCredentials(this.user, password);
> 		session = repository.login(cred);
> 		LOGGER.info("connected");
> 		LOGGER.info("Workspace: " + 
> 				session.getWorkspace().getName());
> 		boolean writeable = repository.getDescriptorValue(Repository.WRITE_SUPPORTED).getBoolean();
> 		LOGGER.info("Write supported=" + writeable);
> 	}
> 	public static void main(String[] args) throws Exception {
> 		LOGGER.info("Program-Start"); 
> 		DownloadLoopMain dlm = new  DownloadLoopMain();
> 	}
> }
> Based on a list of repository nodes it retrieves node by node from the repository an
inspects the temp-directory. After every step it displays the number of files in the tempdir,
the name and size of the files which are new and those which are gone since last inspection.
> This proofs, that for each Property.getBinary().getStream() jackrabbit creates six identical
files from the jcr:data-property in the temdir and it proofs that these files are not deleted
by the instructions:
> InputStream.close();
> Binary.dispose();
> I tested this by installing the latest jackrabbit-jar "org.apache.sling.launchpad-6-standalone.jar"
from the Sling-Webpage and populating the repository with several files.
> Please provide a patch to make sure deletion of the temporary files is done in time when
issuing the close and/or dispose instruction.
> Please rreduce the number of identical temporary files created by the  Property.getBinary().getStream()
instruction. In the test, each of the files was 90MB in size. For each of the instructions
I need 550MB storage in the tempdir.
> Thanks in advance,
> Ulrich

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message