You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Lon Varscsak <lo...@gmail.com> on 2019/02/26 17:54:09 UTC

Bug when serializing/deserializing objects

Hey all,

A few weeks ago I posted an email about a bug when serializing, and I never
really looked much more in to it.  However, I've now encountered a
different issue if I'm using Map based data objects.  If I have a data
object, access a relationship, then serialize the object (and it's
DataContext) then deserialize the object and then try to access the
relationship again, I get this exception:

java.lang.NullPointerException

at org.apache.cayenne.util.RelationshipFault.isTransientParent(
RelationshipFault.java:69)

at org.apache.cayenne.util.PersistentObjectList.isFault(
PersistentObjectList.java:76)

at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
PersistentObjectList.java:318)

at org.apache.cayenne.util.PersistentObjectList.iterator(
PersistentObjectList.java:221)

at com.smarthealth.cayennetest.App.main(App.java:53)


It appears that the relationshipOwner variable on the ToManyList object is
null (which is an invalid state).  If I switch to field based objects, I
have no exception and things work as expected.  Also if I don't access the
relationship before serialization, then there is no error on
deserialization.

You can download a test application here:
https://ds.varscsak.com:5001/d/f/473447192107950173

If you want to flip between Map based and Field based, you can update the
pom.xml file (you'll see that commented out in the build section) and
trigger a build which should trigger the cgen task (doesn't always work for
me, so sometimes I just delete the _ files and that's enough to trigger a
rebuild).

I'm pretty comfortable switching to field based objects, but feel like this
should be addressed (or at least understood).

Thanks for your time,

Lon

Re: Bug when serializing/deserializing objects

Posted by Lon Varscsak <lo...@gmail.com>.
Thanks for the quick fix!

On Thu, Feb 28, 2019 at 4:26 AM Nikita Timofeev <nt...@objectstyle.com>
wrote:

> Hi Lon,
>
> Thanks for example. This turned out to be a bug introduced in 4.1.
> Old Map based CayenneDataObject incorrectly serialized/deserialized
> HashMap with it's values. And that explains why you saw those values
> in your other case.
> I've pushed fix for this to 4.1 branch and tested it with your test
> application. Everything looks good now.
>
> On Thu, Feb 28, 2019 at 2:17 AM Lon Varscsak <lo...@gmail.com>
> wrote:
> >
> > Also wondering, would this be a more appropriate post for the "dev" list
> is
> > or the "user" list appropriate/acceptable?
> >
> > -Lon
> >
> > On Wed, Feb 27, 2019 at 2:02 PM Andrus Adamchik <an...@objectstyle.org>
> > wrote:
> >
> > > Hi Lon,
> > >
> > > We'll need to review this. All this used to worked before.
> > >
> > > Andrus
> > >
> > > > On Feb 26, 2019, at 1:00 PM, Lon Varscsak <lo...@gmail.com>
> > > wrote:
> > > >
> > > > I always forget this part, I'm working off of 4.1.M3-SNAPSHOT
> > > >
> > > > On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <
> lon.varscsak@gmail.com>
> > > > wrote:
> > > >
> > > >> Hey all,
> > > >>
> > > >> A few weeks ago I posted an email about a bug when serializing, and
> I
> > > >> never really looked much more in to it.  However, I've now
> encountered a
> > > >> different issue if I'm using Map based data objects.  If I have a
> data
> > > >> object, access a relationship, then serialize the object (and it's
> > > >> DataContext) then deserialize the object and then try to access the
> > > >> relationship again, I get this exception:
> > > >>
> > > >> java.lang.NullPointerException
> > > >>
> > > >> at org.apache.cayenne.util.RelationshipFault.isTransientParent(
> > > >> RelationshipFault.java:69)
> > > >>
> > > >> at org.apache.cayenne.util.PersistentObjectList.isFault(
> > > >> PersistentObjectList.java:76)
> > > >>
> > > >> at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
> > > >> PersistentObjectList.java:318)
> > > >>
> > > >> at org.apache.cayenne.util.PersistentObjectList.iterator(
> > > >> PersistentObjectList.java:221)
> > > >>
> > > >> at com.smarthealth.cayennetest.App.main(App.java:53)
> > > >>
> > > >>
> > > >> It appears that the relationshipOwner variable on the ToManyList
> object
> > > is
> > > >> null (which is an invalid state).  If I switch to field based
> objects, I
> > > >> have no exception and things work as expected.  Also if I don't
> access
> > > the
> > > >> relationship before serialization, then there is no error on
> > > >> deserialization.
> > > >>
> > > >> You can download a test application here:
> > > >> https://ds.varscsak.com:5001/d/f/473447192107950173
> > > >>
> > > >> If you want to flip between Map based and Field based, you can
> update
> > > the
> > > >> pom.xml file (you'll see that commented out in the build section)
> and
> > > >> trigger a build which should trigger the cgen task (doesn't always
> work
> > > for
> > > >> me, so sometimes I just delete the _ files and that's enough to
> trigger
> > > a
> > > >> rebuild).
> > > >>
> > > >> I'm pretty comfortable switching to field based objects, but feel
> like
> > > >> this should be addressed (or at least understood).
> > > >>
> > > >> Thanks for your time,
> > > >>
> > > >> Lon
> > > >>
> > >
> > >
>
>
>
> --
> Best regards,
> Nikita Timofeev
>

Re: Bug when serializing/deserializing objects

Posted by Nikita Timofeev <nt...@objectstyle.com>.
Hi Lon,

Thanks for example. This turned out to be a bug introduced in 4.1.
Old Map based CayenneDataObject incorrectly serialized/deserialized
HashMap with it's values. And that explains why you saw those values
in your other case.
I've pushed fix for this to 4.1 branch and tested it with your test
application. Everything looks good now.

On Thu, Feb 28, 2019 at 2:17 AM Lon Varscsak <lo...@gmail.com> wrote:
>
> Also wondering, would this be a more appropriate post for the "dev" list is
> or the "user" list appropriate/acceptable?
>
> -Lon
>
> On Wed, Feb 27, 2019 at 2:02 PM Andrus Adamchik <an...@objectstyle.org>
> wrote:
>
> > Hi Lon,
> >
> > We'll need to review this. All this used to worked before.
> >
> > Andrus
> >
> > > On Feb 26, 2019, at 1:00 PM, Lon Varscsak <lo...@gmail.com>
> > wrote:
> > >
> > > I always forget this part, I'm working off of 4.1.M3-SNAPSHOT
> > >
> > > On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <lo...@gmail.com>
> > > wrote:
> > >
> > >> Hey all,
> > >>
> > >> A few weeks ago I posted an email about a bug when serializing, and I
> > >> never really looked much more in to it.  However, I've now encountered a
> > >> different issue if I'm using Map based data objects.  If I have a data
> > >> object, access a relationship, then serialize the object (and it's
> > >> DataContext) then deserialize the object and then try to access the
> > >> relationship again, I get this exception:
> > >>
> > >> java.lang.NullPointerException
> > >>
> > >> at org.apache.cayenne.util.RelationshipFault.isTransientParent(
> > >> RelationshipFault.java:69)
> > >>
> > >> at org.apache.cayenne.util.PersistentObjectList.isFault(
> > >> PersistentObjectList.java:76)
> > >>
> > >> at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
> > >> PersistentObjectList.java:318)
> > >>
> > >> at org.apache.cayenne.util.PersistentObjectList.iterator(
> > >> PersistentObjectList.java:221)
> > >>
> > >> at com.smarthealth.cayennetest.App.main(App.java:53)
> > >>
> > >>
> > >> It appears that the relationshipOwner variable on the ToManyList object
> > is
> > >> null (which is an invalid state).  If I switch to field based objects, I
> > >> have no exception and things work as expected.  Also if I don't access
> > the
> > >> relationship before serialization, then there is no error on
> > >> deserialization.
> > >>
> > >> You can download a test application here:
> > >> https://ds.varscsak.com:5001/d/f/473447192107950173
> > >>
> > >> If you want to flip between Map based and Field based, you can update
> > the
> > >> pom.xml file (you'll see that commented out in the build section) and
> > >> trigger a build which should trigger the cgen task (doesn't always work
> > for
> > >> me, so sometimes I just delete the _ files and that's enough to trigger
> > a
> > >> rebuild).
> > >>
> > >> I'm pretty comfortable switching to field based objects, but feel like
> > >> this should be addressed (or at least understood).
> > >>
> > >> Thanks for your time,
> > >>
> > >> Lon
> > >>
> >
> >



-- 
Best regards,
Nikita Timofeev

Re: Bug when serializing/deserializing objects

Posted by Lon Varscsak <lo...@gmail.com>.
Also wondering, would this be a more appropriate post for the "dev" list is
or the "user" list appropriate/acceptable?

-Lon

On Wed, Feb 27, 2019 at 2:02 PM Andrus Adamchik <an...@objectstyle.org>
wrote:

> Hi Lon,
>
> We'll need to review this. All this used to worked before.
>
> Andrus
>
> > On Feb 26, 2019, at 1:00 PM, Lon Varscsak <lo...@gmail.com>
> wrote:
> >
> > I always forget this part, I'm working off of 4.1.M3-SNAPSHOT
> >
> > On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <lo...@gmail.com>
> > wrote:
> >
> >> Hey all,
> >>
> >> A few weeks ago I posted an email about a bug when serializing, and I
> >> never really looked much more in to it.  However, I've now encountered a
> >> different issue if I'm using Map based data objects.  If I have a data
> >> object, access a relationship, then serialize the object (and it's
> >> DataContext) then deserialize the object and then try to access the
> >> relationship again, I get this exception:
> >>
> >> java.lang.NullPointerException
> >>
> >> at org.apache.cayenne.util.RelationshipFault.isTransientParent(
> >> RelationshipFault.java:69)
> >>
> >> at org.apache.cayenne.util.PersistentObjectList.isFault(
> >> PersistentObjectList.java:76)
> >>
> >> at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
> >> PersistentObjectList.java:318)
> >>
> >> at org.apache.cayenne.util.PersistentObjectList.iterator(
> >> PersistentObjectList.java:221)
> >>
> >> at com.smarthealth.cayennetest.App.main(App.java:53)
> >>
> >>
> >> It appears that the relationshipOwner variable on the ToManyList object
> is
> >> null (which is an invalid state).  If I switch to field based objects, I
> >> have no exception and things work as expected.  Also if I don't access
> the
> >> relationship before serialization, then there is no error on
> >> deserialization.
> >>
> >> You can download a test application here:
> >> https://ds.varscsak.com:5001/d/f/473447192107950173
> >>
> >> If you want to flip between Map based and Field based, you can update
> the
> >> pom.xml file (you'll see that commented out in the build section) and
> >> trigger a build which should trigger the cgen task (doesn't always work
> for
> >> me, so sometimes I just delete the _ files and that's enough to trigger
> a
> >> rebuild).
> >>
> >> I'm pretty comfortable switching to field based objects, but feel like
> >> this should be addressed (or at least understood).
> >>
> >> Thanks for your time,
> >>
> >> Lon
> >>
>
>

Re: Bug when serializing/deserializing objects

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi Lon,

We'll need to review this. All this used to worked before.

Andrus

> On Feb 26, 2019, at 1:00 PM, Lon Varscsak <lo...@gmail.com> wrote:
> 
> I always forget this part, I'm working off of 4.1.M3-SNAPSHOT
> 
> On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <lo...@gmail.com>
> wrote:
> 
>> Hey all,
>> 
>> A few weeks ago I posted an email about a bug when serializing, and I
>> never really looked much more in to it.  However, I've now encountered a
>> different issue if I'm using Map based data objects.  If I have a data
>> object, access a relationship, then serialize the object (and it's
>> DataContext) then deserialize the object and then try to access the
>> relationship again, I get this exception:
>> 
>> java.lang.NullPointerException
>> 
>> at org.apache.cayenne.util.RelationshipFault.isTransientParent(
>> RelationshipFault.java:69)
>> 
>> at org.apache.cayenne.util.PersistentObjectList.isFault(
>> PersistentObjectList.java:76)
>> 
>> at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
>> PersistentObjectList.java:318)
>> 
>> at org.apache.cayenne.util.PersistentObjectList.iterator(
>> PersistentObjectList.java:221)
>> 
>> at com.smarthealth.cayennetest.App.main(App.java:53)
>> 
>> 
>> It appears that the relationshipOwner variable on the ToManyList object is
>> null (which is an invalid state).  If I switch to field based objects, I
>> have no exception and things work as expected.  Also if I don't access the
>> relationship before serialization, then there is no error on
>> deserialization.
>> 
>> You can download a test application here:
>> https://ds.varscsak.com:5001/d/f/473447192107950173
>> 
>> If you want to flip between Map based and Field based, you can update the
>> pom.xml file (you'll see that commented out in the build section) and
>> trigger a build which should trigger the cgen task (doesn't always work for
>> me, so sometimes I just delete the _ files and that's enough to trigger a
>> rebuild).
>> 
>> I'm pretty comfortable switching to field based objects, but feel like
>> this should be addressed (or at least understood).
>> 
>> Thanks for your time,
>> 
>> Lon
>> 


Re: Bug when serializing/deserializing objects

Posted by Lon Varscsak <lo...@gmail.com>.
I always forget this part, I'm working off of 4.1.M3-SNAPSHOT

On Tue, Feb 26, 2019 at 10:54 AM Lon Varscsak <lo...@gmail.com>
wrote:

> Hey all,
>
> A few weeks ago I posted an email about a bug when serializing, and I
> never really looked much more in to it.  However, I've now encountered a
> different issue if I'm using Map based data objects.  If I have a data
> object, access a relationship, then serialize the object (and it's
> DataContext) then deserialize the object and then try to access the
> relationship again, I get this exception:
>
> java.lang.NullPointerException
>
> at org.apache.cayenne.util.RelationshipFault.isTransientParent(
> RelationshipFault.java:69)
>
> at org.apache.cayenne.util.PersistentObjectList.isFault(
> PersistentObjectList.java:76)
>
> at org.apache.cayenne.util.PersistentObjectList.resolvedObjectList(
> PersistentObjectList.java:318)
>
> at org.apache.cayenne.util.PersistentObjectList.iterator(
> PersistentObjectList.java:221)
>
> at com.smarthealth.cayennetest.App.main(App.java:53)
>
>
> It appears that the relationshipOwner variable on the ToManyList object is
> null (which is an invalid state).  If I switch to field based objects, I
> have no exception and things work as expected.  Also if I don't access the
> relationship before serialization, then there is no error on
> deserialization.
>
> You can download a test application here:
> https://ds.varscsak.com:5001/d/f/473447192107950173
>
> If you want to flip between Map based and Field based, you can update the
> pom.xml file (you'll see that commented out in the build section) and
> trigger a build which should trigger the cgen task (doesn't always work for
> me, so sometimes I just delete the _ files and that's enough to trigger a
> rebuild).
>
> I'm pretty comfortable switching to field based objects, but feel like
> this should be addressed (or at least understood).
>
> Thanks for your time,
>
> Lon
>