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 141277 - SAXParseException when trying to wrap more than one library into single library wrapper module.
Summary: SAXParseException when trying to wrap more than one library into single libra...
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: rmichalsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-23 08:35 UTC by rmichalsky
Modified: 2008-09-30 14:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stacktrace (4.94 KB, text/plain)
2008-07-23 08:39 UTC, rmichalsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rmichalsky 2008-07-23 08:35:52 UTC
Actual wrapping is ok, both jars appear correctly under Libraries node in project window, but when trying to publish
package from the 2nd jar, the exception is thrown.
Comment 1 rmichalsky 2008-07-23 08:39:35 UTC
Created attachment 65315 [details]
stacktrace
Comment 2 Jesse Glick 2008-07-24 00:25:35 UTC
Probably <public-packages> is being written too early in the document.
Comment 3 Jesse Glick 2008-07-29 23:12:55 UTC
This needs to be fixed for 6.5.
Comment 4 rmichalsky 2008-09-26 19:36:23 UTC
Fixed in core-main #1c292820cd93
Comment 5 Jesse Glick 2008-09-29 20:31:08 UTC
The patch looks wrong to me. findElement is intended to be used when exactly one (or either zero or one) elements of a
given name can be found beneath a given parent according to the schema. It should never be used for elements which can
have multiple occurrences.

It's not exactly clear from the changelog comment what the relationship of this is to the SAXParseException (whose
immediate cause is that apisupport.project code is trying to write invalid content), but I am guessing that some element
ordering logic is breaking when >1 <c-p-e> must be added. Fine, but if so, do not break findElement; use findSubElements.

In particular, I do not want findElement to have some special logic distinct from the general method which will be
introduced in issue #136595.

The patch is also missing a unit test.
Comment 6 Quality Engineering 2008-09-30 05:58:27 UTC
Integrated into 'main-golden', will be available in build *200809300201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/1c292820cd93
User: Richard Michalsky <rmichalsky@netbeans.org>
Log: #141277: fixed SAXParseException, caused by o.n.m.a.p.Util#findElement returning null when more than node of given name found. Semantics changed to return first found node. Seems it should not break other uses of the method.
Comment 7 rmichalsky 2008-09-30 10:02:52 UTC
The most direct cause of failed validation is that ProjectXMLManager#insertPublicOrFriend tries to insert
<public-packages> in front of any present <c-p-e> or <e-c-u> and it uses findElement to locate them. Since there are two
wrapped libraries, it returns null and inserts <p-p> at the wrong position.

I considered using findSubElements or the like, but since findElement is not a public API I searched all occurences and
AFAIK that particular feature (returning null on more than one found element) is never explicitly used - most searched
for elements can appear only once anyway, the only exception is search for <e-c-u> also in insertPublicOrFriend, where
it exhibited the same buggy behavior as described here. So I decided to change semantics of findElement instead. Javadoc
is updated.

Regarding issue #136595, I didn't notice you're making it an API, so let me know if I should revert this change and use
different approach or keep it there and add the test instead.
Comment 8 Jesse Glick 2008-09-30 14:23:45 UTC
Please add a test *and* restore the original findElement, perhaps adding a List<Element> findElements(...) to handle the
cases where multiple occurrences are expected.