Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2020-12-06 16:12:49 +0000
committerAlexander Kurtakov2021-07-21 12:04:37 +0000
commita5ebd39f8583016398b6a5cd84e803c3f90035dc (patch)
treea5e40950e1bd69e36ae48af8c2084310434e1f4f
parent6106c97ef442846155e07a86908df1a6e14a0172 (diff)
downloadeclipse.platform.ua-I20210724-1800.tar.gz
eclipse.platform.ua-I20210724-1800.tar.xz
eclipse.platform.ua-I20210724-1800.zip
org.eclipse.help.internal.base.scope.ScopeRegistry.instance in org.eclipse.help.internal.base.scope.ScopeRegistry.getInstance() This method contains an unsynchronized lazy initialization of a non-volatile static field. Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, if the method can be called by multiple threads. You can make the field volatile to correct the problem. For more information, see the Java Memory Model web site. Rank: Troubling (14), confidence: Normal Pattern: LI_LAZY_INIT_STATIC Type: LI, Category: MT_CORRECTNESS (Multithreaded correctness) Change-Id: I232f050bbbc83403c4b7346cb411ec47b74f19fd Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ua/+/173454 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java
index 255738d2f..cfbe9e9fb 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java
@@ -39,17 +39,17 @@ public class ScopeRegistry {
private static List<IScopeHandle> scopes = null;
- private static ScopeRegistry instance;
-
private boolean initialized = false;
+ private static class RegistryHolder {
+ static final ScopeRegistry instance = new ScopeRegistry();
+ }
+
private ScopeRegistry() {
}
public static ScopeRegistry getInstance() {
- if (instance == null)
- instance = new ScopeRegistry();
- return instance;
+ return RegistryHolder.instance;
}
public AbstractHelpScope getScope(String id) {

Back to the top