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 230467 - Order of versions of JavaScript libraries is incorrect and does not match the order at cdnjs.com
Summary: Order of versions of JavaScript libraries is incorrect and does not match the...
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 7.4
Hardware: All All
: P4 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on: 235414
Blocks:
  Show dependency tree
 
Reported: 2013-05-29 15:27 UTC by Petr Jiricka
Modified: 2014-04-24 02:08 UTC (History)
1 user (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 Petr Jiricka 2013-05-29 15:27:33 UTC
1. Create a New HTML5 project; progress to the JavaScript files panel
2. Update the libraries to make sure you have the latest version from cdnjs.com

Some of the JavaScript files in this panel do not show the latest version of the library at the top. I would expect that the pre-selected version will match the default version that's offered by cdnjs.com. The panel displays e.g.:

angular.js 1.0.0rc6 instead of 1.1.5
backbone.js 0.9.9-amdjs instead of 1.0.0
ember.js 1.0pre instead of 1.0.0-rc.4
headjs 0.97a instead of 0.99
mustache.js 0.5.0-dev instead of 0.7.2
handlebars.js 1.0.rc.2 instead of 1.0.0-rc.4

Possibly there are more.
Comment 1 Tomas Mysik 2013-05-30 04:51:17 UTC
Thanks for catching that, will have a look at it.
Comment 2 Tomas Mysik 2013-05-31 09:16:38 UTC
The problem here are the "non-numeric" suffixes (e.g. "rc6") - even cdnjs.com is not corectly sorted. Our API class Version fails on it.

Adding PetrH to CC (at least he seems to be the @author of this class ;) - Petře, we use:

Version.fromDottedNotationWithFallback("1.0.0rc6");

For this Version, method Version.isBelowOrEqual(Version) always returns false if the other Version is "numeric only".

The question is what to do with it :) Version "1.0rc" is expected to be "older" than "1.0" but OTOH, "1.0u1" (or similarly) is expected to be "newer" than "1.0" - unfortunately I don't think we can correctly handle all cases.

I tried to "sanitize" library version passed to Version class, the result is:

> angular.js 1.0.0rc6 instead of 1.1.5

works

> backbone.js 0.9.9-amdjs instead of 1.0.0

works

> ember.js 1.0pre instead of 1.0.0-rc.4

does not work

> headjs 0.97a instead of 0.99

works

> mustache.js 0.5.0-dev instead of 0.7.2

works

> handlebars.js 1.0.rc.2 instead of 1.0.0-rc.4

does not work


Closing as FIXED but of course, feel free to reopen if anyone of you have a better idea.

Thanks.

http://hg.netbeans.org/web-main/rev/abfcb187fa93
Comment 3 Petr Jiricka 2013-05-31 09:55:12 UTC
Thanks a lot. So I assume when ember 1.0 and handlebars 1.0 are released, these cases will also work as expected, right?
Comment 4 Tomas Mysik 2013-05-31 09:59:42 UTC
Yes. The only thing I do now is that I simply remove everything after first "not-number-or-dot" ([^.0-9]) character. But I have also noticed that the version can be "latest" - here cannot be done anything...

Thanks.
Comment 5 Quality Engineering 2013-06-01 01:14:53 UTC
Integrated into 'main-golden', will be available in build *201305312301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/abfcb187fa93
User: Tomas Mysik <tmysik@netbeans.org>
Log: #230467 - Order of versions of JavaScript libraries is incorrect and does not match the order at cdnjs.com
Comment 6 Petr Jiricka 2013-09-02 12:54:01 UTC
I still found another minor problem, using the latest snapshot bundled with the IDE:
ember.js 1.0.0-rc.4 is at the top and preselected, when 1.0.0-rc.7 is also available in the snapshot. This should be doable, no? (The cdnjs shows the order correctly for these.)

Reopening as a P4.
Comment 7 Tomas Mysik 2013-09-02 13:20:53 UTC
Unfortunately not. See comment #c2 and comment #c4 for explanation (our API class Version need to support non-numeric versions - as "rc" etc. - as well).

Thanks.
Comment 8 Tomas Mysik 2013-09-02 13:30:43 UTC
Issue against Version class reported as issue #235414. Keeping this opened as a reminder (the changeset that fixes this issue can be reverted).

Thanks.
Comment 9 Petr Jiricka 2013-09-02 13:40:56 UTC
Ok, I understand we want to reuse the Version class and not reinvent the wheel for this. I can imagine that even without the implementation of enhancement 235414, a solution like this could work for this case:
Step 1: Compare the part before the first "not-number-or-dot"
Step 2: If they are equal, find a common prefix of the two strings
Step 3: If it's non-empty, remove this common prefix
Step 4: If the remainders of both strings start with number or dot, pass these remainders back to step 1

But it may not be worth the effort.
Comment 10 Tomas Mysik 2013-09-02 13:55:18 UTC
Yes, I was thinking about it first - but as you write, I think that this should be in Version so everyone can benefit from it. CDNJS is maybe even more complicated since authors can release any versions they like (e.g. "pre", "1.0a" or just "latest" etc.) and it is not possible to compare them always correctly (I can imagine that "1.0a" can be older but also newer than "1.0").

Thanks.
Comment 11 Tomas Mysik 2014-04-04 10:23:27 UTC
Basically fixed as part of issue #243494.

Thanks.

http://hg.netbeans.org/web-main/rev/a385faff0266
Comment 12 Quality Engineering 2014-04-05 03:30:36 UTC
Integrated into 'main-silver', will be available in build *201404050001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a385faff0266
User: Tomas Mysik <tmysik@netbeans.org>
Log: #243494 - IllegalArgumentException: Comparison method violates its general contract!

It fixes #230467 as well.
Comment 13 Quality Engineering 2014-04-24 02:08:28 UTC
Integrated into 'releases/release80', will be available in build *201404240045* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/d1b22ce758c2
User: Tomas Mysik <tmysik@netbeans.org>
Log: #243494 - IllegalArgumentException: Comparison method violates its general contract!

It fixes #230467 as well.
(transplanted from a385faff02663b79677c4b5bc23cf5ffb9acf08a)