Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D4A2FFF4 for ; Fri, 19 Apr 2013 20:17:19 +0000 (UTC) Received: (qmail 84620 invoked by uid 500); 19 Apr 2013 20:17:19 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 84541 invoked by uid 500); 19 Apr 2013 20:17:19 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 83985 invoked by uid 99); 19 Apr 2013 20:17:18 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Apr 2013 20:17:18 +0000 Date: Fri, 19 Apr 2013 20:17:18 +0000 (UTC) From: "Ulrich Schmidt (JIRA)" To: dev@jackrabbit.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JCR-3568) Property.getBinary().getStream() files in tempDir not removed by InputStream.close() nor by Binary.dispose() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JCR-3568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13636828#comment-13636828 ] Ulrich Schmidt commented on JCR-3568: ------------------------------------- fileBin.getClass().getName() displays: org.apache.jackrabbit.spi.commons.value.AbstractQValue$1 (thank you, Julian) > 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 nodeList = new ArrayList(); > public DownloadLoopMain() throws Exception { > LOGGER.info("TempDir=" + temp.getPath()); > long totalsize=0; > > connectRepository(); > buildNodeList(); > List 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 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 list1, List 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 getTempFiles(File[] files) { > List filesList = new ArrayList(); > 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