Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2020-12-06 16:32:47 +0000
committerAlexander Kurtakov2021-07-21 06:01:11 +0000
commit20a4fc37fdd8b516966455ee83a98dcaac1dc936 (patch)
tree5f961e37cb974154e0fb307fcfa0e98537e9ba99
parentca8b91a686c34170c9ccb91f1f2a55d6c97748ff (diff)
downloadeclipse.platform.ua-20a4fc37fdd8b516966455ee83a98dcaac1dc936.tar.gz
eclipse.platform.ua-20a4fc37fdd8b516966455ee83a98dcaac1dc936.tar.xz
eclipse.platform.ua-20a4fc37fdd8b516966455ee83a98dcaac1dc936.zip
Bug: Incorrect lazy initialization of static field
org.eclipse.help.internal.criteria.CriteriaProviderRegistry.instance in org.eclipse.help.internal.criteria.CriteriaProviderRegistry.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: Ie3f80610a6bf944971c40108f7c5a0512c7550d4 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ua/+/173461 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaProviderRegistry.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaProviderRegistry.java b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaProviderRegistry.java
index cf318c908..7c85079c8 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaProviderRegistry.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaProviderRegistry.java
@@ -36,18 +36,17 @@ public class CriteriaProviderRegistry {
private static List<AbstractCriteriaProvider> providers = null;
- private static CriteriaProviderRegistry instance;
-
private boolean initialized = false;
+ private static class RegistryHolder {
+ static final CriteriaProviderRegistry instance = new CriteriaProviderRegistry();
+ }
+
private CriteriaProviderRegistry() {
}
public static CriteriaProviderRegistry getInstance() {
- if (instance == null) {
- instance = new CriteriaProviderRegistry();
- }
- return instance;
+ return RegistryHolder.instance;
}
synchronized private void readProviders() {

Back to the top