Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 91029 invoked from network); 22 May 2006 12:58:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 May 2006 12:58:14 -0000 Received: (qmail 175 invoked by uid 500); 22 May 2006 12:58:10 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 106 invoked by uid 500); 22 May 2006 12:58:10 -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 99927 invoked by uid 99); 22 May 2006 12:58:10 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 05:58:10 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 05:58:09 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0F40D410006 for ; Mon, 22 May 2006 12:57:32 +0000 (GMT) Message-ID: <25757123.1148302652059.JavaMail.jira@brutus> Date: Mon, 22 May 2006 12:57:32 +0000 (GMT+00:00) From: "Stefan Guggisberg (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Commented: (JCR-428) BLOBFileValue() might be discarded to early In-Reply-To: <17652417.1147101800964.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/JCR-428?page=comments#action_12412763 ] Stefan Guggisberg commented on JCR-428: --------------------------------------- ok, michael was right. in certain scenarios a BLOBFileValue instance could indeed get accidentaly discarded because of jackrabbit's copy-on-write implementation which does a shallow copy of the value(s) for efficiency and performance reasons. a blob read from the db was wrongly considered being 'transient' because it was internally created from a stream. if a copy thereof would be lateron discarded the underlying value would be discarded as well (because of the shallow copy-on-write). i added a specialized constructor for creating BLOBFileValue instances from a stream which won't get discarded: public BLOBFileValue(InputStream in, boolean temp) throws IOException fixed in svn r408647 > BLOBFileValue() might be discarded to early > ------------------------------------------- > > Key: JCR-428 > URL: http://issues.apache.org/jira/browse/JCR-428 > Project: Jackrabbit > Type: Bug > Components: core > Versions: 1.0 > Reporter: Michael Frericks > Assignee: Stefan Guggisberg > Fix For: 1.1 > > Situation: > if the internal value of a property of type binary is created by the constructor BLOBFileValue(InputStream in) and the content is not stored in an temp-file, then calling the methods > a) #setProperty(InputStream in) on this node and then > b) #refresh(false) on the node of this property > on the node of this property leads to an internal value of this property with an erased byte[]. > Solution: > Only if the spoolFile is created the field 'temp' should be set to true. > If the InputStream is stored in the byte[] the field 'temp' should be set to false. > Patch: > Index: BLOBFileValue.java > =================================================================== > retrieving revision 1.1 > diff -u -r1.1 BLOBFileValue.java > --- BLOBFileValue.java 8 May 2006 13:57:49 -0000 1.1 > +++ BLOBFileValue.java 8 May 2006 15:19:54 -0000 > @@ -142,6 +142,7 @@ > len += read; > } > } > + in.close(); > } finally { > if (out != null) { > out.close(); > @@ -151,8 +152,15 @@ > // init vars > file = spoolFile; > fsResource = null; > - // this instance is backed by a temporarily allocated resource/buffer > - temp = true; > + if (file != null) > + { > + // this instance is backed by a temporarily allocated resource > + temp = true; > + } > + else > + { > + temp = true; > + } > } > > /** -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira