Re: [osgi-dev] Help with the OSGi Converter

2019-05-17 Thread Clément Delgrange via osgi-dev
Thanks Ray,

Indeed, it works now and the method I pointed out was changed. Maybe an EnRoute 
index poms should be added to include the current best quality bundles?! It 
could help new newcomers to get bundles with less bugs.

Clément.

‐‐‐ Original Message ‐‐‐
On Friday 17 May 2019 19:52, Raymond Auge  wrote:

> I don't have a concrete answer since I'd have to also debug. However, I can 
> make a suggestion to perhaps try:
>
> 
>   org.apache.felix
>   org.apache.felix.converter
>   1.0.8
> 
> which is Apache Felix implementation of the osgi converter spec. What you'll 
> find is that it's moving along a little faster with bug fixes. It's a drop in 
> replacement.
>
> It also means that Apache Felix mail list may have a few more bodies 
> monitoring it that have deep knowledge of the implementation details.
>
> Also note that Apache Felix converter implementation was the seed code for 
> the official OSGi artifact.
>
> - Ray
>
> On Fri, May 17, 2019 at 12:43 PM Clément Delgrange via osgi-dev 
>  wrote:
>
>> Hi,
>>
>> I use the OSGi Converter to convert a proxy of an Interface to a Map and I 
>> get an exception:
>>
>> org.osgi.util.converter.ConversionException: Cannot convert null to 
>> interface java.util.Map
>> at 
>> org.osgi.util.converter.ConvertingImpl.convertToMapType(ConvertingImpl.java:650)
>> at org.osgi.util.converter.ConvertingImpl.to(ConvertingImpl.java:187)
>> at 
>> org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:176)
>> at 
>> org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:144)
>> ...
>>
>> I don't know if it is a bug or not? Here is what I am doing:
>>
>> 1- I have two interfaces:
>> public interface ParentType
>> {
>>   String test();
>> }
>>
>> public interface ChildType extends ParentType
>> {
>>   // Marker interface
>> }
>>
>> 2- I instantiate my proxy:
>> ChildType proxy = createProxy(); // My proxy return a constant "test" when 
>> test() is invoked.
>>
>> 3- I try to convert and get the exception: 
>> converter.convert(proxy).sourceAs(ChildType.class).to(new 
>> TypeReference>() {/**/}));
>>
>> If I add a method to ChildType ('String qq();') the conversion works.
>>
>> Here is what I have found while debugging:
>> 1- The converter tries to determine if my source is a map type 
>> (ConvertingImpl.isMapType)
>> 2- For this, it calls the method ConvertingImpl.getInterfaces0(Class< ? > 
>> cls) with cls=ChildType.class. For ChildType be considered as a map type, 
>> this method should return a set of interfaces that contains ParentType.class 
>> (which has public method) but it doesn't. Indeed, implemented/extended 
>> interfaces are added to the result only if `cls` is not an interface, I 
>> don't really understand why?
>>
>> Sorry if this mail is a bit obscure and specific, I didn't find an other 
>> place to ask...
>>
>> You can find a repository demonstrating the issue here: 
>> https://github.com/cdelg/demo-converter-bug-or-not
>>
>> Thanks for help.
>>
>> Clément.
>>
>> ___
>> OSGi Developer Mail List
>> osgi-dev@mail.osgi.org
>> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
> --
> [Raymond Augé](http://www.liferay.com/web/raymond.auge/profile) (@rotty3000)
> Senior Software Architect [Liferay, Inc.](http://www.liferay.com) (@Liferay)
> Board Member & EEG Co-Chair, [OSGi Alliance](http://osgi.org) (@OSGiAlliance)___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Help with the OSGi Converter

2019-05-17 Thread Raymond Auge via osgi-dev
I don't have a concrete answer since I'd have to also debug. However, I can
make a suggestion to perhaps try:


  org.apache.felix
  org.apache.felix.converter
  1.0.8


which is Apache Felix implementation of the osgi converter spec. What
you'll find is that it's moving along a little faster with bug fixes. It's
a drop in replacement.

It also means that Apache Felix mail list may have a few more bodies
monitoring it that have deep knowledge of the implementation details.

Also note that Apache Felix converter implementation was the seed code for
the official OSGi artifact.

- Ray

On Fri, May 17, 2019 at 12:43 PM Clément Delgrange via osgi-dev <
osgi-dev@mail.osgi.org> wrote:

> Hi,
>
> I use the OSGi Converter to convert a proxy of an Interface to a Map and I
> get an exception:
>
>
>
> org.osgi.util.converter.ConversionException: Cannot convert null to
> interface java.util.Map
> at
> org.osgi.util.converter.ConvertingImpl.convertToMapType(ConvertingImpl.java:650)
> at org.osgi.util.converter.ConvertingImpl.to(ConvertingImpl.java:187)
> at
> org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:176)
> at
> org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:144)
> ...
>
> I don't know if it is a bug or not? Here is what I am doing:
>
> 1- I have two interfaces:
> public interface ParentType
> {
>   String test();
> }
>
> public interface ChildType extends ParentType
> {
>   // Marker interface
> }
>
> 2- I instantiate my proxy:
> ChildType proxy = createProxy(); // My proxy return a constant "test" when
> test() is invoked.
>
> 3- I try to convert and get the exception:
> converter.convert(proxy).sourceAs(ChildType.class).to(new
> TypeReference>() {/**/}));
>
> If I add a method to ChildType ('String qq();') the conversion works.
>
> Here is what I have found while debugging:
> 1- The converter tries to determine if my source is a map type
> (ConvertingImpl.isMapType)
> 2- For this, it calls the method ConvertingImpl.getInterfaces0(Class< ? >
> cls) with cls=ChildType.class. For ChildType be considered as a map type,
> this method should return a set of interfaces that contains
> ParentType.class (which has public method) but it doesn't. Indeed,
> implemented/extended interfaces are added to the result only if `cls` is
> not an interface, I don't really understand why?
>
> Sorry if this mail is a bit obscure and specific, I didn't find an other
> place to ask...
>
> You can find a repository demonstrating the issue here:
> https://github.com/cdelg/demo-converter-bug-or-not
>
> Thanks for help.
>
> Clément.
>
>
>
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev



-- 
*Raymond Augé* 
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* 
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance  (@OSGiAlliance)
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

[osgi-dev] Help with the OSGi Converter

2019-05-17 Thread Clément Delgrange via osgi-dev
Hi,

I use the OSGi Converter to convert a proxy of an Interface to a Map and I get 
an exception:

org.osgi.util.converter.ConversionException: Cannot convert null to interface 
java.util.Map
at 
org.osgi.util.converter.ConvertingImpl.convertToMapType(ConvertingImpl.java:650)
at org.osgi.util.converter.ConvertingImpl.to(ConvertingImpl.java:187)
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:176)
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:144)
...

I don't know if it is a bug or not? Here is what I am doing:

1- I have two interfaces:
public interface ParentType
{
  String test();
}

public interface ChildType extends ParentType
{
  // Marker interface
}

2- I instantiate my proxy:
ChildType proxy = createProxy(); // My proxy return a constant "test" when 
test() is invoked.

3- I try to convert and get the exception: 
converter.convert(proxy).sourceAs(ChildType.class).to(new 
TypeReference>() {/**/}));

If I add a method to ChildType ('String qq();') the conversion works.

Here is what I have found while debugging:
1- The converter tries to determine if my source is a map type 
(ConvertingImpl.isMapType)
2- For this, it calls the method ConvertingImpl.getInterfaces0(Class< ? > cls) 
with cls=ChildType.class. For ChildType be considered as a map type, this 
method should return a set of interfaces that contains ParentType.class (which 
has public method) but it doesn't. Indeed, implemented/extended interfaces are 
added to the result only if `cls` is not an interface, I don't really 
understand why?

Sorry if this mail is a bit obscure and specific, I didn't find an other place 
to ask...

You can find a repository demonstrating the issue here: 
https://github.com/cdelg/demo-converter-bug-or-not

Thanks for help.

Clément.___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev