OC, FYI - best practices are:
create EC lock EC try { // operations } catch (Exception e) { // exception handling } finally { unlock EC } In your code, if an exception is thrown creating the EC, your finally block will try to unlock it and generate an NPE. Ken > On Feb 27, 2015, at 2:48 AM, OC <o...@ocs.cz> wrote: > > Chuck, > > On 27. 2. 2015, at 5:44, Chuck Hill <ch...@gevityinc.com > <mailto:ch...@gevityinc.com>> wrote: > >> I am not. Again I might be missing something, but I understand ERXEC does >> autolock -- even in a background thread -- as needed, albeit possibly not in >> the most efficient manner (e.g., >> http://lists.apple.com/archives/Webobjects-dev/2007/May/msg00578.html >> <http://lists.apple.com/archives/Webobjects-dev/2007/May/msg00578.html>). >> >> Assuming you have the properties set properly. > > Based on what I have found on the Web, I have this in my Properties: > > === > er.extensions.ERXEC.safeLocking=true > er.extensions.ERXEC.useSharedEditingContext=false > er.extensions.ERXApplication.useEditingContextUnlocker=true > er.extensions.ERXEC.defaultAutomaticLockUnlock=true > er.extensions.ERXEC.defaultCoalesceAutoLocks=true > === > >> >> (Besides frankly, I don't really see the need to lock an EC at all, given >> the EC is created, used and released in one separate thread and never shared >> anyhow with other threads; but then, superfluous locking does not harm >> anything but efficiency, and efficiency is not paramount with background >> threads.) >> >> You not seeing the need, does not mean the need is not there. :-) EOF >> sends out a lot of notifications, an unlocked EC will process those >> notifications immediately and that can mutate the EO state (attributes, >> relationships). You won’t have a consistent view of the world in an >> unlocked EC. The object state can change on you at any time, without >> warning. Have fun with that! :-) > > Anyway, just to be triple sure, I have changed my task code to > > === > class ImportCSVTask extends ERXLongResponseTask.DefaultImplementation { > ... > def editingContext > ... > def performAction { > ... > try { > editingContext=ERXEC.newEditingContext(objectStore=new > EOObjectStoreCoordinator()) > editingContext.lock() > ... all the processing here, actually imports CSV, stores objects > to editingContext and saves it ... > } finally { > editingContext.unlock() > } > } > } > === > > I hope there's no problem with that? > > Thanks again, > OC >
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com