[
https://issues.apache.org/jira/browse/JCRVLT-672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17647044#comment-17647044
]
Hans-Peter Stoerr edited comment on JCRVLT-672 at 12/14/22 11:11 AM:
---------------------------------------------------------------------
[~kwin] Thank you! You're certainly right that this would provide a much better
comparison for the purpose of sanity checking older vs. newer package versions.
Still, I if you're doing that check in a package manager, I think it'd be
rather risky to rely on an ordering on the suffixes at all, except perhaps for
deciding whether to warn the user in a manual installation, and just have him
re-confirm his action.
My gut feeling is that it'd be a good thing to provide a function with a
partial order based on the numeric prefix, and since the version ordering of
maven is rather important it could be a good thing to provide it's (full)
ordering as another function, too. The latter could conceivably also replace
the current compareTo , though that breaks backwards compatibility for
compareTo and would be somewhat risky there.
But I'd be happy either way - if you're changing Version.compareTo to maven
semantics, that'd even automatically fix AEM's behaviour, given time. :)
was (Author: hanspeterstoerr):
[~kwin] Thank you! You're certainly right that this would provide a much better
comparison for the purpose of sanity checking older vs. newer package versions.
Still, I if you're doing that check in a package manager, it'd be rather risky
to rely on an ordering on the suffixes at all, except perhaps for deciding
whether to warn the user in a manual installation, and just have him re-confirm
his action.
My gut feeling is that it'd be a good thing to provide a function with a
partial order based on the numeric prefix, and since the version ordering of
maven is rather important it could be a good thing to provide it's (full)
ordering as another function, too. The latter could conceivably also replace
the current compareTo , though that breaks backwards compatibility for
compareTo and would be somewhat risky there.
But I'd be happy either way - if you're changing Version.compareTo to maven
semantics, that'd even automatically fix AEM's behaviour, given time. :)
> Provide a Version comparison function for "is newer" checks
> -----------------------------------------------------------
>
> Key: JCRVLT-672
> URL: https://issues.apache.org/jira/browse/JCRVLT-672
> Project: Jackrabbit FileVault
> Issue Type: Improvement
> Affects Versions: 3.6.6
> Reporter: Hans-Peter Stoerr
> Priority: Minor
>
> I suggest to add a function to org.apache.jackrabbit.vault.packaging.Version
> that provides a sensible partial ordering for checking whether one package is
> newer than another.
> Background:
> [org.apache.jackrabbit.vault.packaging.Version#compareTo|https://github.com/apache/jackrabbit-filevault/blob/jackrabbit-filevault-3.6.6/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/Version.java#L157]
> provides a nice function to sort package versions e.g. for the purpose of
> displaying them in a predictable order that is close to the probable
> timeline. But sometimes you want an "is newer than" relationship - e.g. for a
> sanity check during package installation that you don't install an older over
> a newer package. As far as I know, Adobe AEM is actually (ab-)using that
> compareTo function for that purpose. That is a problem, because if you deploy
> e.g. 1.2.3-SNAPSHOT for a while on a server and then create a release 1.2.3,
> it'll refuse automatic installation because it wrongly thinks 1.2.3-SNAPSHOT
> is newer than 1.2.3.
> Now, obviously you cannot fix that AEM problem here, but you could provide a
> function at Version for future use, that would be a nicely useable "is newer
> than" relationship for that purpose, and add a comment warning people not to
> use Version.compareTo for such a sanity check. That'd be nice for AEM usage,
> but also for other package managers, like our [Composum package
> manager|https://www.composum.com/home/nodes/pckgmgr.html?pages.locale=de].
> While the ordering of the numerical prefix (which is also implemented by
> Version.compareTo) is pretty widely used, there is no widely used ordering
> for the suffixes - they could be anything like -SNAPSHOT, -SNAPSHOT-12, -rc1,
> -alpha, -testing and whatnot. So it's not possible to give a full order for
> that purpose. My suggestion is to provide a partial ordering based on the
> numerical prefix, but to ignore the suffix completely. Perhaps provide a
> function Version.compareNumericPrefix ?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)