I don't have a concrete answer since I'd have to also debug. However, I can make a suggestion to perhaps try:
<dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.converter</artifactId> <version>1.0.8</version> </dependency> 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<Map<String, Object>>() {/**/})); > > 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