Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 2850 invoked from network); 11 Mar 2007 21:08:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Mar 2007 21:08:31 -0000 Received: (qmail 80698 invoked by uid 500); 11 Mar 2007 21:08:39 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 80589 invoked by uid 500); 11 Mar 2007 21:08: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 80580 invoked by uid 99); 11 Mar 2007 21:08:38 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Mar 2007 14:08: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; Sun, 11 Mar 2007 13:08:29 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 9D77471406C for ; Sun, 11 Mar 2007 14:08:09 -0700 (PDT) Message-ID: <31297112.1173647289642.JavaMail.jira@brutus> Date: Sun, 11 Mar 2007 14:08:09 -0700 (PDT) From: "Eric Norman (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Created: (JCR-784) NodeType.canAddProperty(key, BinaryValue) consumes the InputStream making it unusable for setting the property MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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 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.