Re: Trying to clear a dead-lock of some type
Re: Trying to clear a dead-lock of some type
- Subject: Re: Trying to clear a dead-lock of some type
- From: WebObjects <email@hidden>
- Date: Thu, 19 May 2005 13:24:29 -0700
I'm having trouble where the "ec.unlock()" in a "finally block" is outside
the scope of the method.
on 5/19/05 12:58, Sacha Mallais at email@hidden wrote:
> On May 19, 2005, at 12:22 pm, WebObjects wrote:
>
>> The following function works consistently, unless there is some
>> contention
>> (I'm sharing a datasource with other applications). There is the
>> expected
>> issue of saving to a locked row - but even if I trap the exception,
>> then
>> repeat this function some time later (after I'm certain the other apps
>> are
>> not locking the same rows) I still get the same contention.
>>
> What exception are you seeing? Can you post it?
>
>> First, do you see anything in this method that is out of place or
>> sequence?
>> (it occurs in a TimerTask within Application)
>>
> One thing I noticed is that you should wrap ec.unlock() in a finally
> clause.
>
> Also, this is inefficient:
>> NSMutableArray foundTasks = new NSMutableArray(array);
> Use array.mutableClone() instead.
>
>> I'm not 100% certain that my ec.refreshAllObjects is place in the
>> proper place.
>
> If you're trying to make sure that you have fresh data from the
> databse, this will not work -- it will only refresh from the local
> cache. This link may help
> http://developer.apple.com/documentation/WebObjects/Reference/API5.2.3/
> com/webobjects/eocontrol/concepts/
> EOEditingContextConcepts.html#MANAGINGOBJECTGRAPH
>
> HTH,
>
> sacha
>
>> Advice is greatly appreciated!
>>
>> -Bill
>>
>>
>> public void SearchForSixAMTasks() {
>>
>> try{
>>
>> TimeZone tz = TimeZone.getTimeZone("Etc/GMT");
>> NSTimestamp SixAM = new NSTimestamp(1899, 12, 30, 14, 2, 0,
>> tz);
>> NSMutableArray args = new NSMutableArray();
>> args.addObject(SixAM);
>> args.addObject("0");
>> EOQualifier qualifier =
>> EOQualifier.qualifierWithQualifierFormat("starttime = %@ AND
>> taskcompletedindicator = %@", args);
>>
>>
>> EOFetchSpecification spec = new
>> EOFetchSpecification("Tbltasks",
>> qualifier, null);
>>
>>
>> EOEditingContext ec = new EOEditingContext();
>> ec.refreshAllObjects();
>>
>> //lock EC
>> ec.lock();
>>
>> //Fetch
>> NSArray array = ec.objectsWithFetchSpecification(spec);
>> NSMutableArray foundTasks = new NSMutableArray(array);
>>
>>
>> Enumeration e = foundTasks.objectEnumerator();
>>
>> while(e.hasMoreElements()) {
>>
>> Tbltasks currentTask = (Tbltasks)e.nextElement();
>> TaskReview review = new TaskReview();
>>
>> System.out.println(currentTask.taskcomment() + " -
>> before
>> change.");
>>
>> review.GetRepsData(currentTask); //data is
>> read,modified,etc. in this method
>>
>>
>> System.out.println(currentTask.taskcompletedindicator());
>>
>> System.out.println(currentTask.alarmindicator());
>>
>> }
>>
>> ec.saveChanges();
>>
>> //-- unlock EC
>> ec.unlock();
>> ec.refreshAllObjects();
>>
>>
>> } catch (Exception e) {
>>
>> // - Definite potential for locking issues with
>> TPE, but
>> only when intentionally trying to break it
>> System.out.println("RepeatingTask: exception in
>> SearchForSixAMTasks()");
>>
>> }
>>
>> }
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> village.net
>>
>> This email sent to email@hidden
>>
_______________________________________________
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