Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 30712 invoked from network); 12 Mar 2007 07:06:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2007 07:06:31 -0000 Received: (qmail 25265 invoked by uid 500); 12 Mar 2007 07:06:39 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 25234 invoked by uid 500); 12 Mar 2007 07:06:38 -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 25221 invoked by uid 99); 12 Mar 2007 07:06:38 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Mar 2007 00:06:38 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Mar 2007 00:06:29 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6E8CF71406D for ; Mon, 12 Mar 2007 00:06:09 -0700 (PDT) Message-ID: <21208384.1173683169450.JavaMail.jira@brutus> Date: Mon, 12 Mar 2007 00:06:09 -0700 (PDT) From: "Eric Norman (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Updated: (JCR-784) NodeType.canAddProperty(key, BinaryValue) consumes the InputStream making it unusable for setting the property In-Reply-To: <31297112.1173647289642.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 [ https://issues.apache.org/jira/browse/JCR-784?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eric Norman updated JCR-784: ---------------------------- Affects Version/s: 1.2.3 > NodeType.canAddProperty(key, BinaryValue) consumes the InputStream making it unusable for setting the property > -------------------------------------------------------------------------------------------------------------- > > Key: JCR-784 > URL: https://issues.apache.org/jira/browse/JCR-784 > Project: Jackrabbit > Issue Type: Bug > Components: core > Affects Versions: 1.2.3 > Environment: Any > Reporter: Eric Norman > Priority: Minor > > When checking if a binary property can be added to a given node type, the input stream inside the BinaryValue object is consumed, making the subsequent call to setProperty(..) not work because the stream has been positioned at the end of the input stream. > The stream is consumed by the following line in NodeTypeImpl.canSetProperty(..) > // create InternalValue from Value and perform > // type conversion as necessary > InternalValue internalValue = InternalValue.create(value, targetType, > nsResolver); > The internalValue object becomes a BlobFileValue that consumes the input stream in it's constructor. > Expected: > The canAddProperty decision should be made without consuming the input stream in the Value object. > Example Code: > Node targetNode; //get node from somewhere > InputStream inStream; //get instream from somewhere > String key = "propName"; //property key > Value value = session.getValueFactory().createValue(inStream); > NodeType nodeType = revisionNode.getPrimaryNodeType(); > if (nodeType.canAddProperty(key, value)) { > targetNode.setProperty(key, value); > } > Workaround: > Create a dummy value to do the canAddProperty check. > Value dummyValue = session.getValueFactory().createValue(session, new ByteArrayInputStream(new byte[0])); > if (revisionNodeType.canSetProperty(key, dummyValue)) { > revisionNode.setProperty(key, (Value)value); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.