Hi,

This bug had actually already been fixed in the main branch, but that only 
applied to 1.1.0-SNAPSHOT. I’ve backported the fix and staged a 1.0.1 release 
candidate which will eliminate this issue in the 1.0.x stream.

In case anyone is interested the fix was simply to directly copy to a HashMap, 
as records are permitted to have null component values and we should reflect 
this in the Map (rather than omitting the component entirely).

Please review the release and vote on the 1.0.1 release if you are able.

All the best,

Tim

On 29 Apr 2025, at 18:30, Dominik Przybysz <alien11...@apache.org> wrote:

Hi,
The error happens in Java >= 16 specific implemnetation in 
https://github.com/apache/aries-typedevent/blob/f56ca7ccd24cf8760a1c64a18e6ec5fffa63bd84/org.apache.aries.typedevent.bus/src/main/java16/org/apache/aries/typedevent/bus/impl/RecordConverter.java#L63-L64
because collector toMap is not able to create Map with nullable fields.

Maybe the workaround could be:
a) to have Optional<Sth> type for nullable fields in the event?
b) to have some marker value in the event instead of null value?

In the code:
a) toMap call could be replaced with custom implementation creating Map or
b) null values could be excluded before final call to collect.

Thomas, would you like to provide a test in a PR to 
https://github.com/apache/aries-typedevent showing the problem?
You can create a Jira issue in https://issues.apache.org/jira/projects/ARIES/


wt., 29 kwi 2025 o 16:51 Thomas Calmant 
<thomas.calm...@gmail.com<mailto:thomas.calm...@gmail.com>> napisał(a):
Hi,

I'm working on Eclipse sensiNact, which uses Apache Aries Typed Event 1.0.0.

I've encountered a problem where events containing beans with null field values 
trigger ConversionException errors when sent to the Typed Event Bus. The 
exception occurs during the conversion process from a custom type to a map.

Is there a known workaround for this issue?

Here is a sample stack trace:
ERROR org.apache.aries.typedevent.bus.impl.EventTask -- The event delivery 
failed for task type.
org.osgi.util.converter.ConversionException: Cannot convert 
ResourceDataNotification[modelPackageUri=https://eclipse.org/sensinact/default, 
model=sensinact, provider=sensiNact, service=admin, resource=model, 
oldValue=null, newValue=sensinact, timestamp=2025-04-29T13:31:22.984828100Z, 
type=class java.lang.String, metadata={value=sensinact, 
timestamp=2025-04-29T13:31:22.984828100Z}] to java.util.Map<java.lang.String, 
java.lang.Object>
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:177)
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:151)
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:146)
at 
org.apache.aries.typedevent.bus.impl.EventConverter.toUntypedEvent(EventConverter.java:292)
at 
org.apache.aries.typedevent.bus.impl.MonitorEventTask.unsafeNotify(MonitorEventTask.java:43)
at 
org.apache.aries.typedevent.bus.impl.EventTask.notifyListener(EventTask.java:29)
at 
org.apache.aries.typedevent.bus.impl.TypedEventBusImpl$EventThread.run(TypedEventBusImpl.java:648)
Caused by: java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at 
java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at 
java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
at 
java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at 
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at 
java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at 
java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at 
java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at 
org.apache.aries.typedevent.bus.impl.RecordConverter.convert(RecordConverter.java:64)
at 
org.apache.aries.typedevent.bus.impl.EventConverter.convertRecord(EventConverter.java:116)
at 
org.osgi.util.converter.CustomConverterImpl$ConvertingWrapper.to(CustomConverterImpl.java:169)
... 6 common frames omitted


Thanks for the help
Thomas



--
Regards,
Dominik Przybysz

Reply via email to