Fix class cast exception when deserielize getRemoteEvent() by any ServiceEvent (#2593)

Co-authored-by: vasilchev <vasil.ilchev@bosch.com>
This commit is contained in:
Vasil Ilchev
2025-08-06 09:46:19 +03:00
committed by GitHub
parent e2805fd386
commit a55d5cd517
2 changed files with 13 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.event.ApplicationEventFilter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.AbstractRemoteEvent;
import org.eclipse.hawkbit.repository.event.remote.RemoteTenantAwareEvent;
import org.eclipse.hawkbit.repository.event.remote.service.AbstractServiceRemoteEvent;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -101,6 +102,15 @@ public class EventPublisherConfiguration {
return;
}
if (event instanceof final AbstractServiceRemoteEvent<?> serviceRemoteEvent
&& serviceRemoteEvent.getRemoteEvent() instanceof RemoteTenantAwareEvent tenantAwareEvent) {
systemSecurityContext.runAsSystemAsTenant(() -> {
super.multicastEvent(event, eventType);
return null;
}, tenantAwareEvent.getTenant());
return;
}
super.multicastEvent(event, eventType);
}
}