From 12a264b1ea3754dd661151fa6407aaa3c43334a5 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Sun, 11 Oct 2020 15:12:26 +0300 Subject: [PATCH] Made API Services volatile to avoid thread visibility issues --- .../com/djrapitops/plan/capability/CapabilityService.java | 4 ++-- .../com/djrapitops/plan/delivery/web/ResolverService.java | 2 +- .../com/djrapitops/plan/delivery/web/ResourceService.java | 2 +- .../java/com/djrapitops/plan/extension/ExtensionService.java | 2 +- .../src/main/java/com/djrapitops/plan/query/QueryService.java | 2 +- .../java/com/djrapitops/plan/settings/SettingsService.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java b/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java index e75b04be9..0bcff2f3f 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java @@ -16,8 +16,8 @@ */ package com.djrapitops.plan.capability; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; /** @@ -64,6 +64,6 @@ public interface CapabilityService { } class ListHolder { - static List> ENABLE_LISTENERS = new ArrayList<>(); + volatile static List> ENABLE_LISTENERS = new CopyOnWriteArrayList<>(); } } diff --git a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java index 096c95df3..eda3288ce 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java @@ -88,7 +88,7 @@ public interface ResolverService { List getResolvers(String target); class Holder { - static ResolverService service; + volatile static ResolverService service; private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java index 914a4a688..78eb7d330 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java @@ -102,7 +102,7 @@ public interface ResourceService { } class Holder { - static ResourceService service; + volatile static ResourceService service; private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java b/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java index 8946fc387..99f33a47b 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java @@ -70,7 +70,7 @@ public interface ExtensionService { void unregister(DataExtension extension); class Holder { - static ExtensionService service; + volatile static ExtensionService service; private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java b/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java index 1bb3255ce..43fd4bbed 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java @@ -149,7 +149,7 @@ public interface QueryService { } class Holder { - static QueryService service; + volatile static QueryService service; private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java b/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java index 911f8453e..8a5fce3f7 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java @@ -65,7 +65,7 @@ public interface SettingsService { List getStringList(String path, Supplier> defaultValue); class Holder { - static SettingsService service; + volatile static SettingsService service; private Holder() { /* Static variable holder */