Hi there,
Yeah there was an issue but I did not get a chance to add the JIRA at the
time and then totally forgot about it.
Sorry about that :(
The work around is, as suggested, use a bufferedInputStream around the one
from the property and all is good.
Are you going to raise the JIRA or would you like me to do so now?
On 29/01/07, Stefan Guggisberg <[EMAIL PROTECTED]> wrote:
On 1/26/07, JavaJ <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> Were you ever able to resolve this problem?
i am not convinced whether there *was* a problem. at least shane did not
create
a jira issue as suggested.
>
> I having the same problem and I am not using RMI. Basically, I am
using
> almost the exact same code to persist the binary property. I can verify
> that the property is persisted properly because if I retrieve the node
back
> (in another thread), the property looks fine. However, after the
initial
> call of save() on the node, if I try to retrieve the property from the
same
> instance of the node, the stream has 0 bytes.
please create a jira issue if you're able to reproduce the issue. please
inlcude a simple test case that demonstrates the issue.
however i'm pretty confident that there's an issue with your test code.
i did a quick test with the following code, everything worked as expected.
byte[] data = new byte[100000];
ValueFactory factory = session.getValueFactory();
Value value = factory.createValue(new
ByteArrayInputStream(data));
Node node = root.addNode("foo");
node.setProperty("bin", new ByteArrayInputStream(data));
root.save();
InputStream in = node.getProperty("bin").getStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
int read = 0;
while ((read = in.read()) >= 0) {
baos.write(read);
}
} finally {
in.close();
}
byte[] data1 = baos.toByteArray();
System.out.println(Arrays.equals(data, data1));
>
> Perhaps it's a bug with using ByteArrayInputStream?
rather unlikely ;-)
cheers
stefan
>
>
>
>
> zagarol wrote:
> >
> > Hi,
> >
> > I have a property on a node called 'blobData' this property has been
> > loaded
> > using the following snippet:
> >
> > ValueFactory factory = session.getValueFactory();
> > Value value = factory.createValue(new ByteArrayInputStream(data));
> > node.setProperty(propertyName, value);
> >
> > Then obviously further on a call to session.save(); is used to persist
> > this.
> >
> > I am now trying to get this binary information back from the property
> > using:
> >
> > InputStream inputStream = node.getProperty(property)
> > .getStream();
> > int readInt = 0;
> > while ((readInt = inputStream.read()) >= 0) {
> > outputStream.write(readInt);
> > }
> > return outputStream.toByteArray();
> >
> > However this always returns an empty byte array as the first call to
> > inputStream.read() returns -1 indicating the end of the stream.
> >
> > Could someone point me in the direction of my error.
> >
> > Thanks,
> > Shane.
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/Pulling-binary-data-from-a-property-tf2423182.html#a8657674
> Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.
>
>