jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-2238) Binary throws NullPointerException
Date Tue, 04 Aug 2009 11:50:15 GMT

    [ https://issues.apache.org/jira/browse/JCR-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12738932#action_12738932

Thomas Mueller commented on JCR-2238:

> 1) Does Value return a new instance of Binary on Value.getBinary()?
> we need to change our Binary implementations that are not immutable, otherwise a call
to getBinary() will become potentially expensive

I think whether Value.getBinary() returns a new object should be implementation defined (not
part of the spec). For Jackrabbit, we could do that always if that's easier (even if using
the data store). I know creating new objects is slow if the class has a finalize method, but
I think it's not such an important performance problem because most applications will not
call Value.getBinary() multiple times I guess. Even creating a new temporary file each time
it is called is probably OK - or is there an important use case where getBinary() needs to
be called multiple times for the same value?

> Value v;
> try {
>    v = vf.createValue(bin);
> } finally {
>     bin.dispose();
> }
> n.setProperty("foo", v); 

I think that should be valid.

With the data store:
a) getBinary() could always return the same Binary object
b) dispose() would be a noop

Without the data store (when using a temp file)
c) getBinary() could always create a new temp file (or use a shared file, if we find an important
use case)
c) I think dispose() should close the stream and make the Binary object unusable (delete the
temp file, maybe using a reference count)
d) finalize() should call dispose() for such Binary objects if needed
e) Maybe closing the session should call Binary.dispose() (session would need a weak reference
to all Binary objects)

> Binary throws NullPointerException 
> -----------------------------------
>                 Key: JCR-2238
>                 URL: https://issues.apache.org/jira/browse/JCR-2238
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Marcel Reutegger
>         Attachments: BinaryValueTest.patch
> Precondition: repository with datastore disabled!
> Steps to reproduce:
> 1) create binary from stream
> 2) set binary on property
> 3) dispose binary
> 4) get binary from property and dispose it immediately
> 5) go to 4)
> Binary.dispose() will throw a NullPointerException when 4) is executed the second time.
> The exception is not thrown if the property is saved after 2).
> See also attached test.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message