How could that be that session is awaken by one thread and action is
invoked by another within the same RRloop?
Are you sure that is what is happening? Could it be that you have a bug in your session's sleep() method that is sometimes causing the EC to NOT get unlocked?
public void sleep() {
if(!isTerminating())
ecLockManager.unlock();
super.sleep();
}
I can't find any bug here ))
Can you post the thread traces?
2011-05-23 22:17:33 INFO tX47k7Qn2z0d6CXNtlL4pw Attempting to lock editing context from WorkerThread14 that was previously locked in WorkerThread3
java.lang.Exception: null
[0] net.rujel.reusables.SessionedEditingContext.lock:118
[30] net.rujel.reusables.SessionedEditingContext.saveChanges:73 // here super.saveChanges() is called
[31] net.rujel.ui.LessonNoteEditor.save:412
[32] net.rujel.ui.LessonNoteEditor.save:352
[85] net.rujel.reusables.UTF8Application.dispatchRequest:46
{java.lang.Exception: null
[0] net.rujel.reusables.SessionedEditingContext.lock:118
[1] net.rujel.reusables.MultiECLockManager.lock:66
[2] net.rujel.Session.awake:118
[9] net.rujel.reusables.UTF8Application.dispatchRequest:46}
{}
traces are filtered to include only my classes and recently active one
My first guess is that your EOEditingContext has a bug in it, and the messages you are seeing are not valid.
Chuck
I have looked through it a lot of times. And could not find any.
private String _nameOfLockingThread = null;
private NSMutableArray _stackTraces = new NSMutableArray();
private NSMutableArray _prevTraces = new NSMutableArray();
public void lock() {
String nameOfCurrentThread = Thread.currentThread().getName();
// prepare filtered stack trace:
String trace = WOLogFormatter.formatTrowable(new Exception());
if (_stackTraces.count() == 0) {
_stackTraces.addObject(trace);
_nameOfLockingThread = nameOfCurrentThread;
} else {
if (nameOfCurrentThread.equals(_nameOfLockingThread)) {
_stackTraces.addObject(trace);
} else {
logger.log(WOLogLevel.INFO,
"Attempting to lock editing context from " + nameOfCurrentThread
+ " that was previously locked in " + _nameOfLockingThread,
new Object[] {session,trace,_stackTraces,_prevTraces});
}
}
super.lock();
}
public void unlock() {
super.unlock();
if (_stackTraces.count() > 0)
_prevTraces.addObject(_stackTraces.removeLastObject());
else
_stackTraces.count();
if (_stackTraces.count() == 0) {
_nameOfLockingThread = null;
_prevTraces.removeAllObjects();
}
}
I think those methods consist of really simple statements that should not cause problems.