• 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: Snapshot access NPE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Snapshot access NPE


  • Subject: Re: Snapshot access NPE
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 27 Feb 2015 04:51:26 +0000
  • Thread-topic: Snapshot access NPE

On 2015-02-26, 8:56 AM, "OC" wrote:

Hello there,

from the moment I've switched to using a new OSC for my background thread ECs, I am occassionally getting weird NPEs, like e.g., this one:

===
Caused by: java.lang.NullPointerException
at com.webobjects.eocontrol.EOCustomObject.changesFromSnapshot(EOCustomObject.java:595)
at com.webobjects.eocontrol.EOCustomObject$changesFromSnapshot$6.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at com.webobjects.eocontrol.EOCustomObject$changesFromSnapshot$6.callCurrent(Unknown Source)
at cz.ocs.model.OCSEnterpriseObject.fixArchivedButReallyUnchangedItemsFromSnapshot(OCSEnterpriseObject.groovy:938)
at cz.ocs.model.OCSEnterpriseObject.validateForSave(OCSEnterpriseObject.groovy:980)
at com.webobjects.eocontrol.EOCustomObject.validateForUpdate(EOCustomObject.java:1446)
at er.extensions.eof.ERXGenericRecord.validateForUpdate(ERXGenericRecord.java:1215)
at com.webobjects.eocontrol.EOEditingContext.validateTable(EOEditingContext.java:2271)
at com.webobjects.eocontrol.EOEditingContext.validateChangesForSave(EOEditingContext.java:3020)
at com.webobjects.eocontrol.EOEditingContext._prepareForPushChanges(EOEditingContext.java:3249)
at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3179)
at er.extensions.eof.ERXEC._saveChanges(ERXEC.java:1179)
at er.extensions.eof.ERXEC.saveChanges(ERXEC.java:1102)
at er.extensions.eof.ERXEC$saveChanges$7.call(Unknown Source)
...
===

where my “validateForSave” and “fixArchivedButReallyUnchangedItemsFromSnapshot” looks like this:

===
    void fixArchivedButReallyUnchangedItemsFromSnapshot {
        NSDictionary ss=this.editingContext().committedSnapshotForObject(this)
        NSDictionary d=this.changesFromSnapshot(ss) // <=== this is line 938 ===
        if (d.count) ... blah blah ...
    }
    void validateForSave {
        super.validateForSave()
        fixArchivedButReallyUnchangedItemsFromSnapshot() // <=== this is line 980 ===

“fix” sounds like “change EO object state”.  Note carefully that the name of the method is validateForSave, not validateForSaveAndChangeDataBehindEOFsBack.  EO state should not change during validation.



    }
===

and never ever used to NPE before, when I used simply “ERXEC.newEditingContext()” inside of my thread (but that, of course, did lock EOF stack while saving, and if there were thousands imported objects, it caused other threads to wait for way too long).

Now, I wonder -- might the reference the EC keeps its OSC in be actually weak one?

No.


For my particular code would indeed bring havoc if it is:

===
  class ImportCSVTask extends ERXLongResponseTask.DefaultImplementation {
    ...
    def editingContext
    ...
    def performAction {
       ...
       editingContext=ERXEC.newEditingContext(new EOObjectStoreCoordinator())
       ...
    }
  }
===

I must admit I considered it self-evident the reference would be strong; but now I'm starting to doubt. Might this be the culprit?

I doubt it.  It is more likely a race condition in saveChanges().  Are you doing anything with the EOs in Wonder’s did* or will* methods?


If not (of course I've meantime added a property to be triple-sure), what the H might cause that? (Actually I doubt this could be, for it does happen even when I pepper my code by System.gc()'s heavily.)

Note: alas I can't “simply test”, for the problems happen intermittently; namely, they never happened on my testing site here, they occur only on the production server :(

My best guess is that you are doing bad things in validateForSave

Chuck

 _______________________________________________
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: Snapshot access NPE
      • From: OC <email@hidden>
References: 
 >Snapshot access NPE (From: OC <email@hidden>)

  • Prev by Date: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Next by Date: Re: Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
  • Previous by thread: Snapshot access NPE
  • Next by thread: Re: Snapshot access NPE
  • Index(es):
    • Date
    • Thread