[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-17 Thread Jira


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17345924#comment-17345924
 ] 

Björn Michael commented on COMPRESS-552:


{{OsgiUtils.isRunningInOsgiEnvironment()}} returns {{true}} with given 
{{commons-compress-1.21-SNAPSHOT.jar}}. Thank you.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
> Attachments: commons-compress-1.21-SNAPSHOT.jar
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-16 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17345773#comment-17345773
 ] 

Stefan Bodewig commented on COMPRESS-552:
-

TBH I have no idea which job publishes the snapshots and how often it runs - 
and whether it actually still does (it doesn't look that way). I was hoping you 
could build the master branch of Commons Compress yourself. I'll attach a 
SNAPSHOT here in a few minutes.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-16 Thread Jira


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17345727#comment-17345727
 ] 

Björn Michael commented on COMPRESS-552:


[~bodewig] Where is the location of the snapshots artifacts? 
https://repository.apache.org/content/groups/snapshots/org/apache/commons/commons-compress/1.21-SNAPSHOT/
 are outdated.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-16 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17345664#comment-17345664
 ] 

Stefan Bodewig commented on COMPRESS-552:
-

[~mtomcat_daobi] could you give commit 23b758fb a try please?

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-14 Thread Jira


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344967#comment-17344967
 ] 

Björn Michael commented on COMPRESS-552:


Revised version if {{BundleReference}} is inherited by an intermediate interface
{code:java}
private static boolean isBundleReference(Class clazz) {
Class c = clazz;
while (c != null) {
for (Class ifc : c.getInterfaces()) {
if (ifc.getName().equals("org.osgi.framework.BundleReference")) {
return true;
}
if (isBundleReference(ifc)){
return true;
}
}
c = c.getSuperclass();
}
return false;
}
{code}


> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-05-14 Thread Jira


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344551#comment-17344551
 ] 

Björn Michael commented on COMPRESS-552:


Since {{org.osgi.framework.BundleReference}} is an interface I'll recommend 
this version at {{OsgiUtils}}
{code:java}
private static boolean isBundleReference(Class clazz) {
Class c = clazz;
while (c != null) {
for (Class ifc : c.getInterfaces()) {
if (ifc.getName().equals("org.osgi.framework.BundleReference")) {
return true;
}
}
c = c.getSuperclass();
}
return false;
}{code}
Because Eclipse classloader 
({{org.eclipse.osgi.internal.loader.EquinoxClassLoader}})  has following class 
hierarchy
{noformat}
class ModuleClassLoader extends java.lang.ClassLoader implements BundleReference
class EquinoxClassLoader extends ModuleClassLoader
{noformat}
current implementation evaluates to *false*.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
> Fix For: 1.21
>
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-03-07 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17296837#comment-17296837
 ] 

Stefan Bodewig commented on COMPRESS-552:
-

Commits 30a77505 seems to work, it would be good if you could test it with a 
real OSGi setup. 

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-03-07 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17296822#comment-17296822
 ] 

Stefan Bodewig commented on COMPRESS-552:
-

I'd prefer a solution that doesn't require a compile time dependency on OSGi. 
Checking the classloader looks good, we could iterate the super interfaces and 
classes until the classname matches without performing an instanceof check.

We've already got a single PAX Exam test which only asserts Compress can be 
loaded as a bundle (this is easier to break, than I would have thought). I'll 
try to figure out whether this can be used to verify a certain check works when 
run inside of the bundle. We'll see.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approaches 
> ([https://stackoverflow.com/q/5879040/1061929]).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-03-06 Thread Jira


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17296739#comment-17296739
 ] 

Björn Michael commented on COMPRESS-552:


{quote}Could you provide some test to reproduce this problem?
{quote}
I'm afraid that I don't know how to write a narrow-scoped small osgi env. unit 
test.

 
{quote}So the only way out would be a Bundle-Activator?
{quote}
The easiest way would be to add
{code:java}
Import-Package: org.osgi.framework;resolution:=optional
{code}
to {{MANIFEST.MF}}.
 I also like the "classloader implements 
{{org.osgi.framework.BundleReference"}} check 
([https://stackoverflow.com/a/5884211/1061929]).
 But instead of an {{instanceof}} check that requires the class object of 
{{BundleReference}} at compile and runtime, one could compare the classloaders 
interface (and super interface) names to {{org.osgi.framework.BundleReference}} 
by {{java.lang.Class.getName()}}.

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approach 
> (https://stackoverflow.com/q/5879040/1061929).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2021-03-06 Thread Stefan Bodewig (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17296638#comment-17296638
 ] 

Stefan Bodewig commented on COMPRESS-552:
-

I'm afraid the accepted answer of the StackOverflow question would suffer from 
the same problem ({{FrameworkUtil}} probably isn't available either). So the 
only way out would be a Bundle-Activator?

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approach 
> (https://stackoverflow.com/q/5879040/1061929).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (COMPRESS-552) OSGI check broken - try to load class BundleEvent always fails

2020-09-02 Thread Peter Lee (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17189186#comment-17189186
 ] 

Peter Lee commented on COMPRESS-552:


Hi [~mtomcat_daobi]

Could you provide some test to reproduce this problem? And a PR in github is 
welcome. :)

> OSGI check broken - try to load class BundleEvent always fails
> --
>
> Key: COMPRESS-552
> URL: https://issues.apache.org/jira/browse/COMPRESS-552
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.20
>Reporter: Björn Michael
>Priority: Major
>
> There is a check for running in OSGI env. in {{ZstdUtils}}, {{BrotliUtils}}, 
> {{LZMAUtils}} and {{XZUtils}} like this:
> {code:java}
> static {
> cachedZstdAvailability = CachedAvailability.DONT_CACHE;
> try {
> Class.forName("org.osgi.framework.BundleEvent");
> } catch (final Exception ex) { // NOSONAR
> setCacheZstdAvailablity(true);
> }
> }
> {code}
> Loading the class {{org.osgi.framework.BundleEvent}} always fails because 
> {{Import-Package}} directive for {{org.osgi.framework}} is missing in 
> _MANIFEST.MF_. Or it requires another more sophisticated approach 
> (https://stackoverflow.com/q/5879040/1061929).
> Tested with Eclipse 4.14 (org.eclipse.osgi_3.15.100.v20191114-1701.jar)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)