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 179532 - Editor detect wrong Editor Kit in cnd tests
Summary: Editor detect wrong Editor Kit in cnd tests
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Settings (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: issues@editor
URL:
Keywords: TEST
Depends on:
Blocks:
 
Reported: 2010-01-15 03:24 UTC by Alexander Simon
Modified: 2010-02-03 21:56 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Simon 2010-01-15 03:24:48 UTC
Editor support detect wrong MIME type for first test in each test case.
For example run test:
org.netbeans.modules.cnd.highlight.semantic.TypedefTest

The method that gets Base Documet is:
org.netbeans.modules.cnd.completion.impl.xref.ReferencesSupport.getBaseDocument()
Comment 1 Jaroslav Tulach 2010-01-16 12:08:25 UTC
Why you think this is Lookup related? The description of the bug is pretty weak, but it seems to me the problem is editor related.
Comment 2 Alexander Simon 2010-01-17 01:41:27 UTC
When I debugged I saw that lookup did not found C/C++ editor kit.
As result plain text editor kit was found for C/C++ document and document was not BaseDocument.
It is a root of problem.
Comment 3 Alexander Simon 2010-01-17 01:59:28 UTC
Exactly where is created wrong kit:
CloneableEditorSupport.getEditorKit("text/x-c++") returns PlainEditorKit
Stack:
org.openide.text.CloneableEditorSupport.getEditorKit(CloneableEditorSupport.java:1827)
org.openide.text.CloneableEditorSupport.createEditorKit(CloneableEditorSupport.java:1842)
org.openide.text.CloneableEditorSupport.prepareDocument(CloneableEditorSupport.java:629)
org.openide.text.CloneableEditorSupport.openDocumentImpl(CloneableEditorSupport.java:854)
org.openide.text.CloneableEditorSupport.openDocumentCheckIOE(CloneableEditorSupport.java:836)
org.openide.text.CloneableEditorSupport.openDocument(CloneableEditorSupport.java:818)
org.openide.text.DataEditorSupport.openDocument(DataEditorSupport.java:493)
org.netbeans.modules.cnd.completion.impl.xref.ReferencesSupport.getBaseDocument(ReferencesSupport.java:163)
org.netbeans.modules.cnd.completion.impl.xref.ReferencesSupport.getDocument(ReferencesSupport.java:539)
org.netbeans.modules.cnd.completion.impl.xref.FileReferencesImpl._accept(FileReferencesImpl.java:118)
org.netbeans.modules.cnd.completion.impl.xref.FileReferencesImpl.accept(FileReferencesImpl.java:98)
org.netbeans.modules.cnd.completion.impl.xref.FileReferencesImpl.accept(FileReferencesImpl.java:92)
org.netbeans.modules.cnd.highlight.semantic.ModelUtils.collect(ModelUtils.java:100)
org.netbeans.modules.cnd.highlight.semantic.TypedefTest.getBlocks(TypedefTest.java:62)
org.netbeans.modules.cnd.highlight.semantic.TypedefTest.getBlocks(TypedefTest.java:51)
org.netbeans.modules.cnd.highlight.semantic.SemanticHighlightingTestBase.performTest(SemanticHighlightingTestBase.java:72)
org.netbeans.modules.cnd.highlight.semantic.SemanticHighlightingTestBase.performTest(SemanticHighlightingTestBase.java:62)
org.netbeans.modules.cnd.highlight.semantic.TypedefTest.testTypedefs(TypedefTest.java:58)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
junit.framework.TestCase.runTest(TestCase.java:168)
org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:89)
org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:337)
org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:274)
org.netbeans.junit.NbTestCase.runBare(NbTestCase.java:356)
junit.framework.TestResult$1.protect(TestResult.java:110)
junit.framework.TestResult.runProtected(TestResult.java:128)
junit.framework.TestResult.run(TestResult.java:113)
junit.framework.TestCase.run(TestCase.java:124)
org.netbeans.junit.NbTestCase.run(NbTestCase.java:214)
junit.framework.TestSuite.runTest(TestSuite.java:232)
junit.framework.TestSuite.run(TestSuite.java:227)
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)
Comment 4 Alexander Simon 2010-01-17 02:02:06 UTC
Bug is reproduced on other platforms(for example Windows).
Comment 5 Alexander Simon 2010-01-18 01:42:04 UTC
It seems problem is:
MockMimeLookup.setInstances(MimePath.parse(MIMENames.CPLUSPLUS_MIME_TYPE), new CCKit());

Method set weak entry for mime path that can be removed by JVM.
Comment 6 Vitezslav Stejskal 2010-01-18 08:24:32 UTC
(In reply to comment #5)
> It seems problem is:
> MockMimeLookup.setInstances(MimePath.parse(MIMENames.CPLUSPLUS_MIME_TYPE), new
> CCKit());
> 
> Method set weak entry for mime path that can be removed by JVM.

Jardo, MockMimeLookup's MAP was changed from HashMap to WeakHashMap by you in http://hg.netbeans.org/main-golden/rev/4653c12d45ce. What exactly was the reason for that? IMO, the map should be HashMap otherwise MockMimeLookup can't work reliably.
Comment 7 Alexander Simon 2010-01-18 11:19:43 UTC
I fixed cnd tests by creating hard reference on MimePath.parse(MIMENames.CPLUSPLUS_MIME_TYPE) in cnd base test case.
So you can downgrade (or close) issue.
Comment 8 Quality Engineering 2010-01-18 23:37:45 UTC
Integrated into 'main-golden', will be available in build *201001190201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/666720362798
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixing BZ#179532 Editor detect wrong Editor Kit in cnd tests on MAC
Comment 9 Vitezslav Stejskal 2010-02-02 07:11:14 UTC
http://hg.netbeans.org/jet-main/rev/a9b20512efe6
Comment 10 Quality Engineering 2010-02-03 21:56:03 UTC
Integrated into 'main-golden', will be available in build *201002040200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a9b20512efe6
User: Vita Stejskal <vstejskal@netbeans.org>
Log: #179532: use HashMap to keep the contents of MockMimeLookup available wihout requiring callers to explicitely hold a reference to the MimePath instance