Problem
!MESSAGE java.lang.NullPointerException: Cannot invoke
"org.osgi.service.event.Event.getProperty(String)" because "event" is null
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException: ...
Caused by: java.lang.NullPointerException
at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher.handleLabelEvent(PerspectiveSwitcher.java:197)
EventObjectSupplier.get(...) reads its currentEvents map (keyed by topic only) via an unsynchronized check-then-act:
if (!currentEvents.containsKey(topic)) {
return IInjector.NOT_A_VALUE;
}
return currentEvents.get(topic).getProperty(DATA); // entry may have been removed meanwhile -> NPE
Steps to reproduce
DIEventHandler.handleEvent adds/removes that entry non-atomically around every delivery, so two concurrent deliveries on the same topic race. The attached JUnit test drives the production EventObjectSupplier directly (no OSGi, no injector) — one thread repeatedly does addCurrentEvent/removeCurrentEvent, the main thread repeatedly calls get(...) for a non-Event parameter type, which hits the branch that dereferences the (possibly just-removed) map entry:
EventObjectSupplierRaceTest.java
Problem
EventObjectSupplier.get(...)reads itscurrentEventsmap (keyed by topic only) via an unsynchronized check-then-act:Steps to reproduce
DIEventHandler.handleEvent adds/removes that entry non-atomically around every delivery, so two concurrent deliveries on the same topic race. The attached JUnit test drives the production EventObjectSupplier directly (no OSGi, no injector) — one thread repeatedly does addCurrentEvent/removeCurrentEvent, the main thread repeatedly calls get(...) for a non-Event parameter type, which hits the branch that dereferences the (possibly just-removed) map entry:
EventObjectSupplierRaceTest.java