Hmm OK I have put together a test case to exercise the RMI stream issue and
it is passing!! Looks like this problem has already been resolved for the
1.1.1 release which is what I am currently using.

Please see the attached JUnit TestCase that I have been using and let me
know if it fails for you.

The only thing I can think of which is different from when I experienced the
problem before is the size of the binary data. As in the real app we are
storing image data as a property on the node.

Shane.

On 29/01/07, Stefan Guggisberg <[EMAIL PROTECTED]> wrote:

On 1/29/07, Shane Preater <[EMAIL PROTECTED]> wrote:
> 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 :(

np, thanks for the feedback.

>
> 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?

i'd prefer you create the issue. if possible please include a small test
case
that demonstrates the issue. and don't forget to mention that the problem
occurs when using rmi.

thanks!
stefan

>
> 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.
> > >
> > >
> >
>
>

Reply via email to