From 5a8cf9f832b0e936f24ca6c1943acd425912a840 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Fri, 11 Mar 2011 03:17:38 +0000 Subject: [PATCH] fixed issues of accessing non-initialized checker registry --- .../eclipse/cdt/codan/internal/core/CheckersRegistry.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java index 206937f6e70..4e13cce130b 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java @@ -53,6 +53,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { private static final Object DEFAULT = "DEFAULT"; //$NON-NLS-1$ private Collection checkers = new ArrayList(); private static CheckersRegistry instance; + private static boolean initialized = false; private HashMap profiles = new HashMap(); private HashMap> problemList = new HashMap>(); @@ -60,6 +61,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { instance = this; profiles.put(DEFAULT, new ProblemProfile()); readCheckersRegistry(); + initialized = true; } private void readCheckersRegistry() { @@ -235,9 +237,11 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /** * @return the singleton checkers registry */ - public static CheckersRegistry getInstance() { + public static synchronized CheckersRegistry getInstance() { if (instance == null) return new CheckersRegistry(); + if (initialized == false) + throw new IllegalStateException("Registry is not initialized"); //$NON-NLS-1$ return instance; }