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 23715 - SourceCookie.Editor.sourceToText() return violates javax.swing.text.Element contract
Summary: SourceCookie.Editor.sourceToText() return violates javax.swing.text.Element c...
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: -FFJ-
Hardware: Sun All
: P3 blocker (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-17 18:56 UTC by Chris Webster
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Source file to recreate the problem (867 bytes, text/plain)
2002-05-17 18:58 UTC, Chris Webster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Webster 2002-05-17 18:56:01 UTC
The attached source code attempts to obtain the
javax.swing.text.Document from the
SourceCookie.Editor returned from
org.openide.src.MethodElement. The document is
only successfully returned if the source file is
open in the editor. If the editor does not contain
the file, a null value is returned. The
java.swing.text.Element interface does not provide
for a null return value. The problematic behavior
is that the code works if the code is open in the
editor. The behavior should perform the
appropriate initialization if the source is not
currently open.

To reproduce the problem, Execute the attached
file as internal executor. You will notice that
the return value is null if the attached file is
not opened in the editor and non-null if the file
is opened (as expected).
Comment 1 Chris Webster 2002-05-17 18:58:08 UTC
Created attachment 5835 [details]
Source file to recreate the problem
Comment 2 Svata Dedic 2002-05-20 13:46:11 UTC
There are actually two options: either autload the document blocking
on the load finish, or return null instead of j.s.t.Element, when the
document was not loaded yet.
Comment 3 Svata Dedic 2002-06-10 17:00:20 UTC
The implementation tries to open the underlying document. Note that in
a really exceptional case (someone has erased the Element's document
between it was obtained and sourceToText was called), it may throw
IllegalStateException. But that's IMHO better than returning null
since SourceCookie.Editor's javadoc does not mention such possibility.

Fixed in trunk:
/cvs/java/src/org/netbeans/modules/java/JavaParserGlue.java,v  <-- 
JavaParserGlue.java
new revision: 1.36; previous revision: 1.35
Comment 4 Jan Becicka 2003-04-01 08:31:23 UTC
VERIFIED
Comment 5 Quality Engineering 2003-07-01 13:18:34 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.