Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345326 - Wrong null-handling in StaticNameResolver
Summary: Wrong null-handling in StaticNameResolver
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xpath (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Jesper Moller CLA
QA Contact: Jesper Moller CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-10 15:33 EDT by Jesper Moller CLA
Modified: 2011-05-11 23:43 EDT (History)
2 users (show)

See Also:
jesper: pmc_approved? (david_williams)
jesper: pmc_approved? (raghunathan.srinivasan)
jesper: pmc_approved? (naci.dai)
jesper: pmc_approved? (deboer)
neil.hauge: pmc_approved+
jesper: pmc_approved? (kaloyan)
jesper: pmc_approved? (cbridgha)
d_a_carver: review+


Attachments
Patch for this issue (10.55 KB, patch)
2011-05-10 15:35 EDT, Jesper Moller CLA
no flags Details | Diff
Tests (6.24 KB, patch)
2011-05-10 17:29 EDT, Jesper Moller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesper Moller CLA 2011-05-10 15:33:40 EDT
During testing of M7, I discovered that the XPath2 processor now calls getNamespaceURI() with  a null prefix when looking up function names. This is a regression and API violation.

The NamespaceContext provided by the StaticContextBuilder doesn't object to this, but in the UI (the XPath view), this causes an error whenever resolving a function without a prefix.
Comment 1 Jesper Moller CLA 2011-05-10 15:35:48 EDT
Created attachment 195266 [details]
Patch for this issue

This patch cleans up the calls into StaticContext re. namespace contexts
Comment 2 Jesper Moller CLA 2011-05-10 17:29:18 EDT
Created attachment 195280 [details]
Tests

The new test in TestBugs addresses this feature.
The other changes clean up the test preconditions which were not quite right,
Comment 3 Jesper Moller CLA 2011-05-10 17:32:05 EDT
Could you review this, I'm trying to get this into RC1, since it breaks the XPath view for some common cases?

The description is slightly wrong, since it's local scopes ("for each a$ in ...") which causes the NPE, not function names.
Comment 4 Jesper Moller CLA 2011-05-11 17:09:53 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.

It's a regression, and it gives an ugly NPE in the error log

* Is there a work-around? If so, why do you believe the work-around is insufficient?

Only workaround is to qualify variable names in the XPath editor and set up a namespace, which is cumbersome.

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?

Tested manually by me (Mac + WinXP), tested by the 8000+ test cases, plus a new one I added especially for this

* Give a brief technical overview. Who has reviewed this fix?
The current code resolved the namespace prefix for variables in several different places, and one place forgot to guard or missing namespaces, which is marked internally by null.

David Carver is reviewing this currently.

* What is the risk associated with this fix?

Quite low - it's a single class, and the new code is clearer and has less duplicated logic.
Comment 5 David Carver CLA 2011-05-11 17:21:01 EDT
Looks good.
Comment 6 Jesper Moller CLA 2011-05-11 23:43:08 EDT
Committed, tagged and released