From 8c2e85ceaab560d6f0b3e741eba43a5f6e4f0006 Mon Sep 17 00:00:00 2001 From: Amartya Parijat Date: Wed, 5 Feb 2025 13:22:30 +0100 Subject: [PATCH] Make DPIZoomChangeHandlers concurrent R/W able #62 This commit changes the type of DPIZoomChangeRegistry::dpiZoomChangeHandlers from TreeMap to ConcurrentSkipListMap as at times there can be classes which can register their handlers amidst a DPI change event leading to concurrent read and write which can lead to ConcurrentModificationException contributes to https://github.com/eclipse-platform/eclipse.platform.swt/issues/62 and https://github.com/eclipse-platform/eclipse.platform.swt/issues/127 --- .../win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java index 8432d1e220b..3ba6d4adc37 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DPIZoomChangeRegistry.java @@ -15,13 +15,14 @@ import java.util.*; import java.util.Map.*; +import java.util.concurrent.*; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class DPIZoomChangeRegistry { - private static Map, DPIZoomChangeHandler> dpiZoomChangeHandlers = new TreeMap<>( + private static Map, DPIZoomChangeHandler> dpiZoomChangeHandlers = new ConcurrentSkipListMap<>( (o1, o2) -> { if(o1.isAssignableFrom(o2)) { return -1;