Document.addDocumentListener() causes an ERROR

Hi, all.

I created an DocumentListener instance and tried to add the listener to a Document object for a VirtualFile. Then I got the following exception:

-



ERROR - enapi.editor.impl.DocumentImpl - Assertion failed: org.intellij.resourceeditor.model.VirtualResourceFile@125ee71
ERROR - enapi.editor.impl.DocumentImpl - IntelliJ IDEA 4.0 Build #1179
ERROR - enapi.editor.impl.DocumentImpl - JDK: 1.4.2
ERROR - enapi.editor.impl.DocumentImpl - VM: Java HotSpot(TM) Client VM
ERROR - enapi.editor.impl.DocumentImpl - Vendor: Sun Microsystems Inc.
ERROR - enapi.editor.impl.DocumentImpl - OS: Linux
ERROR - enapi.editor.impl.DocumentImpl - Last Action:
ERROR - enapi.editor.impl.DocumentImpl - Current Command:
ERROR - enapi.editor.impl.DocumentImpl - Assertion failed: org.intellij.resourceeditor.model.VirtualResourceFile@125ee71
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:69)
at com.intellij.openapi.editor.c.k.addDocumentListener(k.java:197)
at org.intellij.resourceeditor.model.VirtualResourceFile.loadProperties(VirtualResourceFile.java:280)
...

-



The listener gets DocumentEvents when the document gets changed, but I want to know what the exception is all about. Does anyone have any idea what is going on?

Thanks

---
Kenji

2 comments
Comment actions Permalink

It looks like your listener is already contained by this document

--
Olesya Smirnova
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

"Kenji Yamasaki" <no_mail@jetbrains.com> wrote in message
news:20060984.1084882012980.JavaMail.itn@is.intellij.net...

Hi, all.

>

I created an DocumentListener instance and tried to add the listener to a

Document object for a VirtualFile. Then I got the following exception:
>

-----

>

ERROR - enapi.editor.impl.DocumentImpl - Assertion failed:

org.intellij.resourceeditor.model.VirtualResourceFile@125ee71

ERROR - enapi.editor.impl.DocumentImpl - IntelliJ IDEA 4.0

Build #1179

ERROR - enapi.editor.impl.DocumentImpl - JDK: 1.4.2
ERROR - enapi.editor.impl.DocumentImpl - VM: Java HotSpot(TM)

Client VM

ERROR - enapi.editor.impl.DocumentImpl - Vendor: Sun

Microsystems Inc.

ERROR - enapi.editor.impl.DocumentImpl - OS: Linux
ERROR - enapi.editor.impl.DocumentImpl - Last Action:
ERROR - enapi.editor.impl.DocumentImpl - Current Command:
ERROR - enapi.editor.impl.DocumentImpl - Assertion failed:

org.intellij.resourceeditor.model.VirtualResourceFile@125ee71

java.lang.Throwable
at

com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:69)

at com.intellij.openapi.editor.c.k.addDocumentListener(k.java:197)
at

org.intellij.resourceeditor.model.VirtualResourceFile.loadProperties(Virtual
ResourceFile.java:280)

..

>

-----

>

The listener gets DocumentEvents when the document gets changed, but I

want to know what the exception is all about. Does anyone have any idea what
is going on?
>

Thanks

>

---
Kenji

>
>


0
Comment actions Permalink


Thanks Olesya,

The problem was that the listener had a back reference to a VirtualFile for the Document and the listener class's equals method uses the VirtualFile. So if the Document implementation's equals method uses its listener list, it recursively calls equals method of my DocumentListener.

I think this is what's happening. I changed the listener implementation to an annonimous class, and the exception dissapeared.

Thanks

---
Kenji Yamasaki

0

Please sign in to leave a comment.