[jira] [Comment Edited] (TEXT-233) Missing OSGi import-package commons-lang3 version can make commons-text unusable in OSGi

2024-02-14 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/TEXT-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17817498#comment-17817498
 ] 

Gary D. Gregory edited comment on TEXT-233 at 2/14/24 10:23 PM:


See also
 * [https://github.com/bndtools/bnd/issues/544]
 * https://issues.apache.org/jira/browse/FELIX-4626

Reproducer:
{noformat}
git clone https://gitbox.apache.org/repos/asf/commons-text.git
git checkout 1001fb35902e52f1c19442a197a5ff914f7d8432
mvn clean verify
unzip -p target/commons-text-1.11.1-SNAPSHOT.jar META-INF/MANIFEST.MF
{noformat}


was (Author: garydgregory):
See also
 * [https://github.com/bndtools/bnd/issues/544]
 * https://issues.apache.org/jira/browse/FELIX-4626

Reproducer:

{noformat}
git clone  [https://gitbox.apache.org/repos/asf/commons-text.git]
git checkout 1001fb35902e52f1c19442a197a5ff914f7d8432
mvn clean verify
unzip -p target/commons-text-1.11.1-SNAPSHOT.jar META-INF/MANIFEST.MF
{noformat}

> Missing OSGi import-package commons-lang3 version can make commons-text 
> unusable in OSGi
> 
>
> Key: TEXT-233
> URL: https://issues.apache.org/jira/browse/TEXT-233
> Project: Commons Text
>  Issue Type: Bug
>Affects Versions: 1.11.0
>Reporter: K P
>Priority: Major
>
> Since commons-text 1.11.0, there's commons-text codes that requires the 
> presence of commons-lang3 3.13.0 or higher. However, in an OSGi environment, 
> this requirement is not enforced due to shortcoming an the commons-text 
> 1.11.0 MANIFEST.MF, which may lead to unpredictable, uncontrollable failure 
> when trying to use commons-text 1.11.0.
> Some more detail:
> Since commons-text 1.11.0, the NumericEntityEscaper makes uses of the method 
> *Range.{_}+of+{_}(...)* in commons-lang3 :
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
> this.range = Range.of(below, above);
>     this.between = between;
> }{code}
>  
> Method Range.of(...) was added in *commons-lang3 3.13.0* :
>  
> {code:java}
>  * @since 3.13.0
>  */
> public static > Range of(final T 
> fromInclusive, final T toInclusive) {{code}
>  
> Previously, in commons-text 1.10.0 or earlier, NumericEntityEscaper made use 
> of the the commons-lang3 method *Range.{_}+between+{_}(...)*  (which is now 
> marked as deprecated since commons-lang3 3.13.0)
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
>     this.range = Range.between(below, above);
>     this.between = between;
> }{code}
>  
> This is all fine in a non-OSGi environment.
>  
> However, to always resolve this correctly in an OSGi environment, some 
> essential information is missing in the commons-text 1.11.0 {*}MANIFEST.MF{*}.
> The commons-text 1.11.0 declares the following *Import-Package* in its 
> manifest:
>  
> {noformat}
> Import-Package: javax.script,javax.xml.xpath,org.apache.commons.lang3,or
>  g.apache.commons.lang3.time,org.xml.sax
> {noformat}
> Notice how this indeed imports the required package 
> "{_}org.apache.commons.lang3{_}", but this import {+}is not qualified with a 
> version number{+}.
> When an OSGi package is not qualified by a version number or version range, 
> then during package resolution, OSGi may resolve this import against whatever 
> version of commons-lang3 it can find and that exports this package.
> In other words, because there's no version restriction in this import as far 
> as OSGi is concerned : if you have an OSGi environment where also an older 
> version older version of commons-lang3 is already present, e.g. commons-lang 
> "3.12.0", then the import-package of commons-text 1.11.0 will happily be 
> satisfied by that package and resolve and link its import-package requirement 
> against the 3.12.0 version.
> So when loading these OSGi bundles, all will look fine. The OSGi will nicely 
> resolve everything without complaining at this point.
> However in the above example environment, maybe much much later, when at a 
> given moment a user of the 1.11.0 commons-text NumericEntityEscaper (e.g. 
> some of the StringEscapeUtils method being called by user code) is invoked,
> then that commons-text 1.11.0 NumericEntityEscaper will see the 3.12.0 
> version of the Range class in its classpath. It will try to invoke the method 
> Range.of(...) ... but this method didn't exist yet in this 3.12.0 version of 
> the Range class.
> Which will fail with a NoSuchMethodError:
>  
> {noformat}
> java.lang.NoSuchMethodError: 
> org.apache.commons.lang3.Range.of(Ljava/lang/Comparable;Ljava/lang/Comparable;)Lorg/apache/commons/lang3/Range;
>     at 
> org.apache.commons.text.translate.NumericEntityEscaper.(NumericEntityEscaper.java:97)
>  ~[?:?]{noformat}
>  
> To avoid this, it is +required+ that 

[jira] [Comment Edited] (TEXT-233) Missing OSGi import-package commons-lang3 version can make commons-text unusable in OSGi

2024-02-14 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/TEXT-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17817498#comment-17817498
 ] 

Gary D. Gregory edited comment on TEXT-233 at 2/14/24 10:23 PM:


See also
 * [https://github.com/bndtools/bnd/issues/544]
 * https://issues.apache.org/jira/browse/FELIX-4626

Reproducer:

{noformat}
git clone  [https://gitbox.apache.org/repos/asf/commons-text.git]
git checkout 1001fb35902e52f1c19442a197a5ff914f7d8432
mvn clean verify
unzip -p target/commons-text-1.11.1-SNAPSHOT.jar META-INF/MANIFEST.MF
{noformat}


was (Author: garydgregory):
See also
 * https://github.com/bndtools/bnd/issues/544
 * https://issues.apache.org/jira/browse/FELIX-4626

> Missing OSGi import-package commons-lang3 version can make commons-text 
> unusable in OSGi
> 
>
> Key: TEXT-233
> URL: https://issues.apache.org/jira/browse/TEXT-233
> Project: Commons Text
>  Issue Type: Bug
>Affects Versions: 1.11.0
>Reporter: K P
>Priority: Major
>
> Since commons-text 1.11.0, there's commons-text codes that requires the 
> presence of commons-lang3 3.13.0 or higher. However, in an OSGi environment, 
> this requirement is not enforced due to shortcoming an the commons-text 
> 1.11.0 MANIFEST.MF, which may lead to unpredictable, uncontrollable failure 
> when trying to use commons-text 1.11.0.
> Some more detail:
> Since commons-text 1.11.0, the NumericEntityEscaper makes uses of the method 
> *Range.{_}+of+{_}(...)* in commons-lang3 :
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
> this.range = Range.of(below, above);
>     this.between = between;
> }{code}
>  
> Method Range.of(...) was added in *commons-lang3 3.13.0* :
>  
> {code:java}
>  * @since 3.13.0
>  */
> public static > Range of(final T 
> fromInclusive, final T toInclusive) {{code}
>  
> Previously, in commons-text 1.10.0 or earlier, NumericEntityEscaper made use 
> of the the commons-lang3 method *Range.{_}+between+{_}(...)*  (which is now 
> marked as deprecated since commons-lang3 3.13.0)
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
>     this.range = Range.between(below, above);
>     this.between = between;
> }{code}
>  
> This is all fine in a non-OSGi environment.
>  
> However, to always resolve this correctly in an OSGi environment, some 
> essential information is missing in the commons-text 1.11.0 {*}MANIFEST.MF{*}.
> The commons-text 1.11.0 declares the following *Import-Package* in its 
> manifest:
>  
> {noformat}
> Import-Package: javax.script,javax.xml.xpath,org.apache.commons.lang3,or
>  g.apache.commons.lang3.time,org.xml.sax
> {noformat}
> Notice how this indeed imports the required package 
> "{_}org.apache.commons.lang3{_}", but this import {+}is not qualified with a 
> version number{+}.
> When an OSGi package is not qualified by a version number or version range, 
> then during package resolution, OSGi may resolve this import against whatever 
> version of commons-lang3 it can find and that exports this package.
> In other words, because there's no version restriction in this import as far 
> as OSGi is concerned : if you have an OSGi environment where also an older 
> version older version of commons-lang3 is already present, e.g. commons-lang 
> "3.12.0", then the import-package of commons-text 1.11.0 will happily be 
> satisfied by that package and resolve and link its import-package requirement 
> against the 3.12.0 version.
> So when loading these OSGi bundles, all will look fine. The OSGi will nicely 
> resolve everything without complaining at this point.
> However in the above example environment, maybe much much later, when at a 
> given moment a user of the 1.11.0 commons-text NumericEntityEscaper (e.g. 
> some of the StringEscapeUtils method being called by user code) is invoked,
> then that commons-text 1.11.0 NumericEntityEscaper will see the 3.12.0 
> version of the Range class in its classpath. It will try to invoke the method 
> Range.of(...) ... but this method didn't exist yet in this 3.12.0 version of 
> the Range class.
> Which will fail with a NoSuchMethodError:
>  
> {noformat}
> java.lang.NoSuchMethodError: 
> org.apache.commons.lang3.Range.of(Ljava/lang/Comparable;Ljava/lang/Comparable;)Lorg/apache/commons/lang3/Range;
>     at 
> org.apache.commons.text.translate.NumericEntityEscaper.(NumericEntityEscaper.java:97)
>  ~[?:?]{noformat}
>  
> To avoid this, it is +required+ that the commons-text 1.11.0 *MANIFEST.MF* 
> correctly specifies the minimally required version of the commons-lang3 
> package in its Import-Package:
> E.g. by adding a version directive: *{{;version="3.13"}}* : in OSGi, 1 single 
> version 

[jira] [Comment Edited] (TEXT-233) Missing OSGi import-package commons-lang3 version can make commons-text unusable in OSGi

2024-02-14 Thread K P (Jira)


[ 
https://issues.apache.org/jira/browse/TEXT-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17817445#comment-17817445
 ] 

K P edited comment on TEXT-233 at 2/14/24 4:40 PM:
---

I've been searching around a bit more:

[https://cwiki.apache.org/confluence/display/commons/commonsosgi]

The above page explains the possibility for a component (e.g. commons-text, I 
guess) to override certain directives, by overruling the Maven pom property 
"commons.osgi.import"  (which default to *)

I've found an override example in commons-configuration2, 
[https://github.com/apache/commons-configuration/blob/master/pom.xml,] where 
the pom.xml overrides the wildcard with some explicit manual imports (in the 
case of configuration2 with the intention to add an optional resolution 
directive to some imports, not to add a version number), but I think it would 
be a similar approach to fix commons-text3, specifying something like:
{code:java}
org.apache.commons.lang3;version="3.13",
org.apache.commons.lang3.time;version="3.13",
*{code}
as customized commons.osgi.import property? (I couldn't verify this yet...)

 


was (Author: belpk):
I've been search around a bit more:

 

[https://cwiki.apache.org/confluence/display/commons/commonsosgi]

The above page explains the possibility for a component (e.g. commons-text, I 
guess) to override certain directives, by overruling the Maven pom property 
"commons.osgi.import"  (which default to *)

I've found an override example in commons-configuration2, 
[https://github.com/apache/commons-configuration/blob/master/pom.xml,] where 
the pom.xml overrides the wildcard with some explicit manual imports (in the 
case of configuration2 with the intention to add an optional resolution 
directive to some imports, not to add a version number), but I think it would 
be a similar approach to fix commons-text3, specifying something like:
{code:java}
org.apache.commons.lang3;version="3.13",
org.apache.commons.lang3.time;version="3.13",
*{code}
as customized commons.osgi.import property?

 

> Missing OSGi import-package commons-lang3 version can make commons-text 
> unusable in OSGi
> 
>
> Key: TEXT-233
> URL: https://issues.apache.org/jira/browse/TEXT-233
> Project: Commons Text
>  Issue Type: Bug
>Affects Versions: 1.11.0
>Reporter: K P
>Priority: Major
>
> Since commons-text 1.11.0, there's commons-text codes that requires the 
> presence of commons-lang3 3.13.0 or higher. However, in an OSGi environment, 
> this requirement is not enforced due to shortcoming an the commons-text 
> 1.11.0 MANIFEST.MF, which may lead to unpredictable, uncontrollable failure 
> when trying to use commons-text 1.11.0.
> Some more detail:
> Since commons-text 1.11.0, the NumericEntityEscaper makes uses of the method 
> *Range.{_}+of+{_}(...)* in commons-lang3 :
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
> this.range = Range.of(below, above);
>     this.between = between;
> }{code}
>  
> Method Range.of(...) was added in *commons-lang3 3.13.0* :
>  
> {code:java}
>  * @since 3.13.0
>  */
> public static > Range of(final T 
> fromInclusive, final T toInclusive) {{code}
>  
> Previously, in commons-text 1.10.0 or earlier, NumericEntityEscaper made use 
> of the the commons-lang3 method *Range.{_}+between+{_}(...)*  (which is now 
> marked as deprecated since commons-lang3 3.13.0)
>  
> {code:java}
> private NumericEntityEscaper(final int below, final int above, final boolean 
> between) {
>     this.range = Range.between(below, above);
>     this.between = between;
> }{code}
>  
> This is all fine in a non-OSGi environment.
>  
> However, to always resolve this correctly in an OSGi environment, some 
> essential information is missing in the commons-text 1.11.0 {*}MANIFEST.MF{*}.
> The commons-text 1.11.0 declares the following *Import-Package* in its 
> manifest:
>  
> {noformat}
> Import-Package: javax.script,javax.xml.xpath,org.apache.commons.lang3,or
>  g.apache.commons.lang3.time,org.xml.sax
> {noformat}
> Notice how this indeed imports the required package 
> "{_}org.apache.commons.lang3{_}", but this import {+}is not qualified with a 
> version number{+}.
> When an OSGi package is not qualified by a version number or version range, 
> then during package resolution, OSGi may resolve this import against whatever 
> version of commons-lang3 it can find and that exports this package.
> In other words, because there's no version restriction in this import as far 
> as OSGi is concerned : if you have an OSGi environment where also an older 
> version older version of commons-lang3 is already present, e.g. commons-lang 
> "3.12.0", then the import-package of commons-text 1.11.0 will happily be 
>