mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
fixed issues of accessing non-initialized checker registry
This commit is contained in:
parent
c2dfefd6ea
commit
5a8cf9f832
1 changed files with 5 additions and 1 deletions
|
@ -53,6 +53,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
private static final Object DEFAULT = "DEFAULT"; //$NON-NLS-1$
|
||||
private Collection<IChecker> checkers = new ArrayList<IChecker>();
|
||||
private static CheckersRegistry instance;
|
||||
private static boolean initialized = false;
|
||||
private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>();
|
||||
private HashMap<IChecker, Collection<IProblem>> problemList = new HashMap<IChecker, Collection<IProblem>>();
|
||||
|
||||
|
@ -60,6 +61,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
instance = this;
|
||||
profiles.put(DEFAULT, new ProblemProfile());
|
||||
readCheckersRegistry();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private void readCheckersRegistry() {
|
||||
|
@ -235,9 +237,11 @@ public class CheckersRegistry implements Iterable<IChecker>, 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue