jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ulrich Schmidt (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JCR-3568) Property.getBinary().getStream() files in tempDir not removed by InputStream.close() nor by Binary.dispose()
Date Sun, 14 Apr 2013 19:42:15 GMT
Ulrich Schmidt created JCR-3568:

             Summary: 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-api
    Affects Versions: 2.6
         Environment: Windows 7 Pro, Java 6.0.39, WebDAV, JCR 2.0
            Reporter: Ulrich Schmidt
            Priority: Blocker

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;

		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();
			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);
	 * 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])) {
			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];
		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) {
		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("Workspace: " + 
		boolean writeable = repository.getDescriptorValue(Repository.WRITE_SUPPORTED).getBoolean();
		LOGGER.info("Write supported=" + writeable);

	public static void main(String[] args) throws Exception {
		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:

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,

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

View raw message