• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help with NPE in EOCustomObject.willReadRelationship()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with NPE in EOCustomObject.willReadRelationship()


  • Subject: Re: Help with NPE in EOCustomObject.willReadRelationship()
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 28 Apr 2009 21:40:23 -0700

Hi Peter,


On Apr 28, 2009, at 9:20 PM, Peter Vandoros wrote:

Hi All,

I have an issue where a NullPointerException is thrown within EOCustomObject.willReadRelationship(). Before I log a radar, I want to see if anyone else has had a similar issue and if so, what you did to resolve it.

I believe the issue is that EOCustomObject.willReadRelationship() is called firing a fault on a deleted EO. The only way that EOCustomObject.willReadRelationship() will throw a NPE is if editingContext() returns null and 'object' is a fault (ie. EOFaultHandler.isFault(object) returns true).

What am I doing to cause this sequence of events you ask? it's relatively simple:

- I have a class (path.to.class.listening.to.editingcontext.notification.MyClass from stack trace below) that listens to EOEditingContext.EditingContextDidSaveChangesNotification notifications and does some processing.
- The NPE occurs in a debug statement that prints the NSNotification object passed to my MyClass.editingContextDidSaveChanges() method before any processing occurs.

That is not going to have happy results...


- I tracked down the culprits to be 3 of 10 deleted objects in the NSNotification's "deleted" userInfo key value, throwing NPE's in their EOCustomObject.toString() method.

See! :-) Yes, you should not do anything to a deleted object. It makes EOF rather cross.



Obviously deleted EO's shouldn't have editingContext()'s, but I believe that EOCustomObject.eoDescription() should not fire _any_ faults

I don't think that I would agree with that. The information from firing faults can be very useful. You can certainly re-implement it to not fire the faults or output something very limited if editingContext() == null. That is a reasonable suggestion to make in a bug report.




or EOCustomObject.willReadRelationship() should check to see if editingContext() is null when 'object' is a fault.

And throw an exception. That is a reasonable suggestion to make in a bug report.



I can override EOCustomObject.willReadRelationship() in my super class and return null when "editingContext() == null && EOFaultHandler.isFault(object)", but I want to know what other potential issues this will cause.

That would make me nervous. If this method is called when editingContext() == null, that indicates to me a coding mistake. An exception seems appropriate and the NPE is not exactly helpful.



Chuck




Model:

Entity1 ----> Entity2 <<----> Entity3

- There are 3 similar relationships between Entity2 & Entity3 (used for different purposes)

Stacktrace:

java.lang.NullPointerException
at com .webobjects .eocontrol.EOCustomObject.willReadRelationship(EOCustomObject.java: 1293)
at com.webobjects.eocontrol._EOMutableKnownKeyDictionary$Initializer $ _LazyGenericRecordBinding .valueInObject(_EOMutableKnownKeyDictionary.java:560)
at com .webobjects .eocontrol.EOCustomObject.storedValueForKey(EOCustomObject.java:1736)
at path .to .my.eo.class._Entity3.myToManyRelationshipToEntity2(_AnEntity.java: 492)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun .reflect .DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor $1.methodValue(NSKeyValueCoding.java:684)
at com.webobjects.foundation.NSKeyValueCoding $_MethodBinding.valueInObject(NSKeyValueCoding.java:1160)
at com .webobjects.eocontrol.EOCustomObject.valueForKey(EOCustomObject.java: 1559)
at com .webobjects .eocontrol.EOCustomObject.eoDescription(EOCustomObject.java:793)
at com.webobjects.eocontrol.EOCustomObject.toString(EOCustomObject.java: 239)
at com.webobjects.foundation.NSArray.toString(NSArray.java:920)
at java.lang.String.valueOf(String.java:2827)
at java.lang.StringBuffer.append(StringBuffer.java:219)
at com.webobjects.foundation.NSDictionary.toString(NSDictionary.java:541)
at java.lang.String.valueOf(String.java:2827)
at java.lang.StringBuffer.append(StringBuffer.java:219)
at com .webobjects.foundation.NSNotification.toString(NSNotification.java: 175)
at path .to .class .listening .to .editingcontext .notification .MyClass.editingContextDidSaveChanges(EOCacheChangeCollector.java:141)


Regards

Peter Vandoros
Software Engineer
Etech Group Pty Ltd
Level 3/21 Victoria St
Melbourne VIC 3000
Australia

Ph: +61 3 9639 9677
Fax: +61 3 9639 9577
----------------------------------
IMPORTANT: This e-mail message and any attachments are confidential and may be privileged. If received in error, please reply to this message and destroy all copies and any attachments. You should check this message and any attachments for viruses or defects. Our liability is limited to resupplying any affected message or attachments. For more information about Etech Group, please visit us at http://www.etechgroup.com.au.





_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


-- Chuck Hill Senior Consultant / VP Development

Come to WOWODC'09 in San Fran this June!
http://www.wocommunity.org/wowodc09/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Help with NPE in EOCustomObject.willReadRelationship()
      • From: Peter Vandoros <email@hidden>
References: 
 >Help with NPE in EOCustomObject.willReadRelationship() (From: Peter Vandoros <email@hidden>)

  • Prev by Date: Help with NPE in EOCustomObject.willReadRelationship()
  • Next by Date: Re: Help with NPE in EOCustomObject.willReadRelationship()
  • Previous by thread: Help with NPE in EOCustomObject.willReadRelationship()
  • Next by thread: Re: Help with NPE in EOCustomObject.willReadRelationship()
  • Index(es):
    • Date
    • Thread