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 80450 - model.findComponent(position) returns Component incorrectly
Summary: model.findComponent(position) returns Component incorrectly
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: XDM (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: bhate
URL:
Keywords:
Depends on:
Blocks: 80402
  Show dependency tree
 
Reported: 2006-07-18 06:31 UTC by Praveen Savur
Modified: 2007-04-10 22:19 UTC (History)
0 users

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 Praveen Savur 2006-07-18 06:31:05 UTC
To reproduce
1) Create a BPEL module and open a bpel file in the editor.
2) From the palette drag and drop a 'Receive' above the Empty activity.
3) Click Validate XML.
4) Notice that error messages that are associcated with a <receive> are attached
to its parent element ie., they are assoicated with <sequence>

I added console messages into XsdBasedvalidator and notice the following

In logValidationError(...)
              Component component = model.findComponent(position);

 I verified that the position number is correct. But the Component returned is
the parent of the Component where the actual position points to.


[Also if this helps:  If the source is edited directly at any place, then for
the same 'position' value model.findComponent(position) returns the correct
Component.]
Comment 1 Nam Nguyen 2006-07-19 02:05:23 UTC
Raised to P1.  What I got when follow exact this test case is OutOfBoundIndex
exception.  Somehow the jdk validation return wrong lineNumber:
java.lang.IndexOutOfBoundsException: Index: 77, Size: 17
	at java.util.ArrayList.RangeCheck(ArrayList.java:546)
	at java.util.ArrayList.get(ArrayList.java:321)
	at
org.netbeans.modules.xml.xam.spi.XsdBasedValidator$Handler.getPosition(XsdBasedValidator.java:204)
	at
org.netbeans.modules.xml.xam.spi.XsdBasedValidator$Handler.logValidationErrors(XsdBasedValidator.java:238)
	at
org.netbeans.modules.xml.xam.spi.XsdBasedValidator$Handler.error(XsdBasedValidator.java:208)
	at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:175)
Comment 2 Nam Nguyen 2006-07-19 02:09:43 UTC
Another stack traces when remove 'name' attribute from wsdl:message (source
view) and do validate are:

java.lang.NullPointerException
	at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.getAccess(AbstractDocumentComponent.java:414)
	at
org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent.findPosition(AbstractDocumentComponent.java:418)
	at
org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLMultiViewSupport.getLineNumber(WSDLMultiViewSupport.java:184)
	at
org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLMultiViewSupport.annotateSourceView(WSDLMultiViewSupport.java:171)
	at
org.netbeans.modules.xml.wsdl.ui.netbeans.module.WSDLMultiViewSupport.showComponent(WSDLMultiViewSupport.java:136)

and:

java.lang.NullPointerException
	at
org.netbeans.modules.xml.wsdl.model.visitor.FindReferencedVisitor.checkReference(FindReferencedVisitor.java:110)
	at
org.netbeans.modules.xml.wsdl.model.visitor.FindReferencedVisitor.visit(FindReferencedVisitor.java:66)
	at org.netbeans.modules.xml.wsdl.model.impl.MessageImpl.accept(MessageImpl.java:56)
	at
org.netbeans.modules.xml.wsdl.model.visitor.FindReferencedVisitor.visitChildren(FindReferencedVisitor.java:124)
	at
org.netbeans.modules.xml.wsdl.model.visitor.FindReferencedVisitor.find(FindReferencedVisitor.java:57)
	at
org.netbeans.modules.xml.wsdl.model.impl.GlobalReferenceImpl.get(GlobalReferenceImpl.java:66)
	at
org.netbeans.modules.xml.wsdl.model.impl.GlobalReferenceImpl.get(GlobalReferenceImpl.java:36)
	at
org.netbeans.modules.xml.wsdl.validator.visitor.WSDLSemanticsVisitor.visit(WSDLSemanticsVisitor.java:540)
Comment 3 Nam Nguyen 2006-07-19 02:12:20 UTC
Fixed in release55.

/cvs/xml/xam/src/org/netbeans/modules/xml/xam/dom/Attic/AbstractDocumentComponent.java,v
 <--  AbstractDocumentComponent.java
new revision: 1.1.2.20; previous revision: 1.1.2.19
/cvs/xml/xam/src/org/netbeans/modules/xml/xam/dom/Attic/AbstractDocumentModel.java,v
 <--  AbstractDocumentModel.java
new revision: 1.1.2.11; previous revision: 1.1.2.10
/cvs/xml/xam/src/org/netbeans/modules/xml/xam/spi/Attic/XsdBasedValidator.java,v
 <--  XsdBasedValidator.java
new revision: 1.1.2.11; previous revision: 1.1.2.10
/cvs/xml/wsdl/api/src/org/netbeans/modules/xml/wsdl/model/visitor/FindReferencedVisitor.java,v
 <--  FindReferencedVisitor.java
new revision: 1.2.2.8; previous revision: 1.2.2.7
Comment 4 Nam Nguyen 2006-07-19 02:35:59 UTC
Fix merged into release55_beta2:

/cvs/xml/xam/src/org/netbeans/modules/xml/xam/dom/Attic/AbstractDocumentComponent.java,v
 <--  AbstractDocumentComponent.java
new revision: 1.1.2.19.2.1; previous revision: 1.1.2.19
/cvs/xml/xam/src/org/netbeans/modules/xml/xam/dom/Attic/AbstractDocumentModel.java,v
 <--  AbstractDocumentModel.java
new revision: 1.1.2.9.2.2; previous revision: 1.1.2.9.2.1
/cvs/xml/xam/src/org/netbeans/modules/xml/xam/spi/Attic/XsdBasedValidator.java,v
 <--  XsdBasedValidator.java
new revision: 1.1.2.4.2.2; previous revision: 1.1.2.4.2.1
/cvs/xml/wsdl/api/src/org/netbeans/modules/xml/wsdl/model/visitor/FindReferencedVisitor.java,v
 <--  FindReferencedVisitor.java
new revision: 1.2.2.7.2.1; previous revision: 1.2.2.7
Comment 5 Praveen Savur 2006-07-21 01:38:11 UTC
Nam, Chris and I could still reproducible this bug. Both for bpel and schema.

So reopening this.
Comment 6 Nam Nguyen 2006-07-21 19:24:13 UTC
The issue seems to be in XDM NodeByPositionVisitor.
I verify the position calculation by XsdBasedValidator is accurate.  Note that
schema validator returns end position of the involved element.

Make P2 since there is no exceptions involved, no data corruption, visibility is
subtle, and work-around available (add-remove space in source view and then
validate again will make the reported line correct again).
Comment 7 Nam Nguyen 2006-07-25 01:03:41 UTC
Same cause as issue 80899, fixed by ajit in release55.
Work-around in editor client code by dynamically insert space into the document
after create new component (done by Praveen for bpel editor).
Verified Ajit fix actually fix this bpel test case.  Give Ajit credit and close
as duplicate.

Note, it would be best to have a unit test that actually fail w/o this fix.
Comment 8 Nam Nguyen 2006-07-25 01:05:33 UTC
correct Ajit user name.
Comment 9 Praveen Savur 2006-07-25 01:10:23 UTC
Work around of programmatically adding whitespece into swingdocument in 
ValidationOutputWindowController. Needs to be removed after beta.
Comment 10 bhate 2006-07-25 01:34:20 UTC
This issue is fixed in xdm and in branch release55.
can be verified with netbeans release55 daily build.
Praveen pl remove workaround, once beta2 is released.
Comment 11 tonybeckham 2007-04-10 22:19:40 UTC
Fix verified  in NetBeans IDE Dev (Build 200704091800)