This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 51872 - AssertionError: Document was locked before starting the MDR transaction.
Summary: AssertionError: Document was locked before starting the MDR transaction.
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P1 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW_FAST, T9Y
: 54222 54587 54739 56181 56366 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-26 15:04 UTC by cezariusz
Modified: 2008-12-22 23:38 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
messages.log (262.93 KB, text/plain)
2004-11-26 15:07 UTC, cezariusz
Details
Proposed changes to fix the problem (15.70 KB, patch)
2005-01-06 15:58 UTC, Jaroslav Tulach
Details | Diff
Exception said to happen after applying the previous patch (24.10 KB, text/plain)
2005-02-14 12:45 UTC, Jaroslav Tulach
Details
Added fix for runAtomic & saveDocument (21.91 KB, patch)
2005-02-14 14:54 UTC, Jaroslav Tulach
Details | Diff
Another stacktrace of firing events under a document lock leading to this AssertionError. (16.44 KB, text/plain)
2005-03-04 09:28 UTC, Martin Matula
Details
New stack trace - created several beans, tried second rename on local interface of session bean (6.83 KB, text/plain)
2005-03-04 14:10 UTC, Martin Grebac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2004-11-26 15:04:28 UTC
Build 200411231900, JDK 1.5

1. I used Timestamp in the code.
2. I called fix imports.
3. Imported java.sql.Timestamp.
4. Changed to import java.sql.*
5. Saved the java file:

java.lang.AssertionError: Document was locked 
before starting the MDR transaction.
	at 
org.netbeans.modules.javacore.ExclusiveMutex.ente
r(ExclusiveMutex.java:116)
	at 
org.netbeans.mdr.NBMDRepositoryImpl.beginTrans
(NBMDRepositoryImpl.java:227)
Comment 1 cezariusz 2004-11-26 15:07:00 UTC
Created attachment 19055 [details]
messages.log
Comment 2 Jan Becicka 2004-12-01 09:48:35 UTC
Honzo, please evaluate. Thanks.
Comment 3 Jan Pokorsky 2004-12-01 14:34:02 UTC
According to the attached stacktrace
EditorSupport.EntryEnv.removeSaveCookie manipulates cookies of data
object still under a document lock which is wrong IMO.

Reassigning to openide/editor ...
Comment 4 Jaroslav Tulach 2005-01-05 15:33:11 UTC
I'll handle this together with issue 52493
Comment 5 Jaroslav Tulach 2005-01-06 15:58:03 UTC
Adding Document.putProperty contract between openide/text and NetBeans
aware editors. Mila, I will need you to implement this in your editor.
Comment 6 Jaroslav Tulach 2005-01-06 15:58:46 UTC
Created attachment 19530 [details]
Proposed changes to fix the problem
Comment 7 Miloslav Metelka 2005-01-13 10:49:07 UTC
Yardo, I've found a problem which I did not realize when we've talked
about solution for this issue. If the document is first locked with
atomic-lock and then the actual modifications are made i.e.

atomic-lock-start
insert/remove
...
atomic-lock-end

then we will still get the assertion because at the time when I notify
the beforeModificationListener the document will already be locked :(

So actually I would have to notify the listener before the
atomic-lock-start will take effect as well (possibly with different
property e.g. "locked"). However I don't know what should be done in
such case on the listener side. IMHO we should not actually call
notifyModified() as the document was in fact not modified yet and it
could just happen:

atomic-lock-start
atomic-lock-end

without any modification. Or we would have to call notifyModified()
and call notifyUnmodified() after atomic-lock-end. But this is IMHO
sort of ugly.
Do you have any ideas regarding this?
Comment 8 Jaroslav Tulach 2005-01-25 07:42:15 UTC
The only possible fix I can imagine is to call notifyModified and then
notifyUnmodified. Otherwise there is no way to make the call to
notifyModified outside of document's lock, I am affraid.

I nobody objects, we will implement the fix this way.
Comment 9 Miloslav Metelka 2005-01-25 08:55:42 UTC
OK, I agree.
Comment 10 Daniel Prusa 2005-02-14 09:47:53 UTC
*** Issue 54222 has been marked as a duplicate of this issue. ***
Comment 11 Jaroslav Tulach 2005-02-14 12:45:04 UTC
Created attachment 20329 [details]
Exception said to happen after applying the previous patch
Comment 12 Jaroslav Tulach 2005-02-14 14:54:37 UTC
Created attachment 20332 [details]
Added fix for runAtomic & saveDocument
Comment 13 Jaroslav Tulach 2005-02-14 14:57:29 UTC
Mila, now you should:
1. review my patch
2. make changes in your document to emulate the behaviour of
NbLikeEditorKit
3. reuse the test NotifyModifiedOnNbEditorLikeKitTest in editor so we
know that behaviour of your editor is correct.

After that we can integrate. I'll stop by to help with #3. 
Comment 14 Martin Grebac 2005-02-16 11:15:20 UTC
*** Issue 54739 has been marked as a duplicate of this issue. ***
Comment 15 Miloslav Metelka 2005-02-16 12:20:06 UTC
I'm working on the fix since tomorrow. I hope to have it ready today COB.
Comment 16 Miloslav Metelka 2005-02-16 12:20:53 UTC
Since yesterday, sorry ;)
Comment 17 Martin Grebac 2005-02-21 12:55:28 UTC
The bug I closed as a duplicate was P2. This is very visible and
annoying exception while working with WS.
Comment 18 Miloslav Metelka 2005-02-21 17:46:02 UTC
Unfortunately further complications appeared that prevent us from
integration of the fix. I need to enhance the openide's tests to do
runAtomic() during UndoManager.canUndo() because in that case the
notifyModified() will be followed by notifyUnmodified() as there are
no  actual modifications during the runAtomic() section.
I'll start a branch and cooperate with Yarda on the final fix. 
Unfortunately I'm currently unable to say whether we will be able to
integrate the fix into Beta1 but hopefully yes.
Starting the branch assert_51872 on openide and editor based on tag
assert_51872_050221.
Comment 19 Miloslav Metelka 2005-03-02 20:53:46 UTC
The branch should now be satisfying the requirements. The tests are
passing so I'm going to commit the branch into the main trunk:

Checking in editor/libsrc/org/netbeans/editor/BaseDocument.java;
/cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v  <-- 
BaseDocument.java
new revision: 1.111; previous revision: 1.110
done
Processing log script arguments...
More commits to come...
Checking in editor/nbproject/project.properties;
/cvs/editor/nbproject/project.properties,v  <--  project.properties
new revision: 1.6; previous revision: 1.5
done
Processing log script arguments...
More commits to come...
Checking in editor/test/build-unit.xml;
/cvs/editor/test/build-unit.xml,v  <--  build-unit.xml
new revision: 1.10; previous revision: 1.9
done
Checking in editor/test/cfg-unit.xml;
/cvs/editor/test/cfg-unit.xml,v  <--  cfg-unit.xml
new revision: 1.7; previous revision: 1.6
done
Processing log script arguments...
More commits to come...
Checking in
editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedNotifyModifiedTest.java;
/cvs/editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedNotifyModifiedTest.java,v
 <--  InheritedNotifyModifiedTest.java
new revision: 1.2; previous revision: 1.1
done
Checking in
editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedUndoRedoTest.java;
/cvs/editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedUndoRedoTest.java,v
 <--  InheritedUndoRedoTest.java
new revision: 1.2; previous revision: 1.1
done
cvs diff: InheritedNotifyModifiedTest.java is a new entry, no
comparison available
cvs diff: InheritedUndoRedoTest.java is a new entry, no comparison
available
Processing log script arguments...
More commits to come...
Checking in openide/arch/arch-openide-editor.xml;
/cvs/openide/arch/arch-openide-editor.xml,v  <--  arch-openide-editor.xml
new revision: 1.19; previous revision: 1.18
done
Processing log script arguments...
More commits to come...
Checking in openide/src/org/openide/text/CloneableEditorSupport.java;
/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.142; previous revision: 1.141
done
Processing log script arguments...
More commits to come...
Checking in openide/test/unit/src/org/openide/text/NbLikeEditorKit.java;
/cvs/openide/test/unit/src/org/openide/text/NbLikeEditorKit.java,v 
<--  NbLikeEditorKit.java
new revision: 1.2; previous revision: 1.1
done
Checking in
openide/test/unit/src/org/openide/text/NotifyModifiedOnNbEditorLikeKitTest.java;
/cvs/openide/test/unit/src/org/openide/text/NotifyModifiedOnNbEditorLikeKitTest.java,v
 <--  NotifyModifiedOnNbEditorLikeKitTest.java
new revision: 1.2; previous revision: 1.1
done
Checking in
openide/test/unit/src/org/openide/text/NotifyModifiedTest.java;
/cvs/openide/test/unit/src/org/openide/text/NotifyModifiedTest.java,v
 <--  NotifyModifiedTest.java
new revision: 1.2; previous revision: 1.1
done
Checking in
openide/test/unit/src/org/openide/text/UndoRedoCooperationTest.java;
/cvs/openide/test/unit/src/org/openide/text/UndoRedoCooperationTest.java,v
 <--  UndoRedoCooperationTest.java
new revision: 1.6; previous revision: 1.5
done
cvs diff: NotifyModifiedOnNbEditorLikeKitTest.java is a new entry, no
comparison available
Processing log script arguments...
Comment 20 Miloslav Metelka 2005-03-03 16:24:07 UTC
Unfortunately this seems to cause regressions: issue 55848 and
probably issue 55818 as well.
Yardo, I will probably roll back the change until we verify that it's
not causing any regressions.
Comment 21 Miloslav Metelka 2005-03-03 20:40:51 UTC
I've rolled back this integration. We will continue to work and test
in assert_51872 branch.
Comment 22 Jaroslav Tulach 2005-03-04 07:43:22 UTC
*** Issue 54587 has been marked as a duplicate of this issue. ***
Comment 23 Martin Matula 2005-03-04 09:28:44 UTC
Created attachment 20674 [details]
Another stacktrace of firing events under a document lock leading to this AssertionError.
Comment 24 Miloslav Metelka 2005-03-04 09:43:01 UTC
Reassigning to Yarda.
Comment 25 Martin Grebac 2005-03-04 14:06:17 UTC
 Well, after rollback of the patch, I'm still getting sometimes
symptoms of 54587 - e.g. after second or third refactoring rename on
Session bean local interface I get the 'document modified externally'
message. So I'm not sure if it's just a plain duplicate. 
 Anyway, this is pretty visible and annoying behaviour, mainly in j2ee
part of the IDE. There's no workaround so that you don't see this
every other time trying to do something. It's also blocking our work
on tests (j2ee/refactoring e.g.) as they fail always but on random
places. Please consider this as a priority. Thanks.
Comment 26 Martin Grebac 2005-03-04 14:10:01 UTC
Created attachment 20687 [details]
New stack trace - created several beans, tried second rename on local interface of session bean
Comment 27 Jaroslav Tulach 2005-03-10 09:23:12 UTC
> Unfortunately this seems to cause regressions: 
> issue 55848 and
> probably issue 55818 as well.

I managed to simulate issue 55818 without changes made as part of this issue.
That is why I believe it is independent and not caused by fix of this issue.

Comment 28 Jaroslav Tulach 2005-03-10 09:31:14 UTC
> Unfortunately this seems to cause regressions: 
> issue 55848 and
> probably issue 55818 as well.

I managed to simulate issue 55818 without changes made as part of this issue.
That is why I believe it is independent and not caused by fix of this issue.

Comment 29 Petr Blaha 2005-03-11 12:07:10 UTC
*** Issue 56181 has been marked as a duplicate of this issue. ***
Comment 30 Jaroslav Tulach 2005-03-11 18:04:07 UTC
New version is in the branch and it does not seem to suffer from the problem 
described in issue 55848 
Comment 31 Martin Matula 2005-03-14 15:23:38 UTC
*** Issue 56366 has been marked as a duplicate of this issue. ***
Comment 32 Jaroslav Tulach 2005-03-16 06:23:00 UTC
"#51872: documentListener property to talk between org.openide.text and NetBeans
editor"
Checking in openide/arch/arch-openide-editor.xml;
/cvs/openide/arch/arch-openide-editor.xml,v  <--  arch-openide-editor.xml
new revision: 1.21; previous revision: 1.20
done
Checking in openide/src/org/openide/text/CloneableEditorSupport.java;
/cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v  <-- 
CloneableEditorSupport.java
new revision: 1.145; previous revision: 1.144
done
Checking in openide/test/unit/src/org/openide/text/NbLikeEditorKit.java;
/cvs/openide/test/unit/src/org/openide/text/NbLikeEditorKit.java,v  <-- 
NbLikeEditorKit.java
new revision: 1.4; previous revision: 1.3
done
Checking in
openide/test/unit/src/org/openide/text/NotifyModifiedOnNbEditorLikeKitTest.java;
/cvs/openide/test/unit/src/org/openide/text/NotifyModifiedOnNbEditorLikeKitTest.java,v
 <--  NotifyModifiedOnNbEditorLikeKitTest.java
new revision: 1.4; previous revision: 1.3
done
Checking in openide/test/unit/src/org/openide/text/NotifyModifiedTest.java;
/cvs/openide/test/unit/src/org/openide/text/NotifyModifiedTest.java,v  <-- 
NotifyModifiedTest.java
new revision: 1.4; previous revision: 1.3
done
Checking in openide/test/unit/src/org/openide/text/UndoRedoCooperationTest.java;
/cvs/openide/test/unit/src/org/openide/text/UndoRedoCooperationTest.java,v  <--
 UndoRedoCooperationTest.java
new revision: 1.8; previous revision: 1.7
done
Checking in editor/libsrc/org/netbeans/editor/BaseDocument.java;
/cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v  <--  BaseDocument.java
new revision: 1.115; previous revision: 1.114
done
Checking in editor/nbproject/project.properties;
/cvs/editor/nbproject/project.properties,v  <--  project.properties
new revision: 1.9; previous revision: 1.8
done
Checking in editor/test/build-unit.xml;
/cvs/editor/test/build-unit.xml,v  <--  build-unit.xml
new revision: 1.12; previous revision: 1.11
done
Checking in editor/test/cfg-unit.xml;
/cvs/editor/test/cfg-unit.xml,v  <--  cfg-unit.xml
new revision: 1.11; previous revision: 1.10
done
Checking in
editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedNotifyModifiedTest.java;
/cvs/editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedNotifyModifiedTest.java,v
 <--  InheritedNotifyModifiedTest.java
new revision: 1.4; previous revision: 1.3
done
Checking in
editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedUndoRedoTest.java;
/cvs/editor/test/unit/src/org/netbeans/modules/editor/openide/InheritedUndoRedoTest.java,v
 <--  InheritedUndoRedoTest.java
new revision: 1.4; previous revision: 1.3
Comment 33 cezariusz 2005-04-20 15:59:05 UTC
Ver. 200504101930.