mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +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 static final Object DEFAULT = "DEFAULT"; //$NON-NLS-1$
|
||||||
private Collection<IChecker> checkers = new ArrayList<IChecker>();
|
private Collection<IChecker> checkers = new ArrayList<IChecker>();
|
||||||
private static CheckersRegistry instance;
|
private static CheckersRegistry instance;
|
||||||
|
private static boolean initialized = false;
|
||||||
private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>();
|
private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>();
|
||||||
private HashMap<IChecker, Collection<IProblem>> problemList = new HashMap<IChecker, Collection<IProblem>>();
|
private HashMap<IChecker, Collection<IProblem>> problemList = new HashMap<IChecker, Collection<IProblem>>();
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
instance = this;
|
instance = this;
|
||||||
profiles.put(DEFAULT, new ProblemProfile());
|
profiles.put(DEFAULT, new ProblemProfile());
|
||||||
readCheckersRegistry();
|
readCheckersRegistry();
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCheckersRegistry() {
|
private void readCheckersRegistry() {
|
||||||
|
@ -235,9 +237,11 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
/**
|
/**
|
||||||
* @return the singleton checkers registry
|
* @return the singleton checkers registry
|
||||||
*/
|
*/
|
||||||
public static CheckersRegistry getInstance() {
|
public static synchronized CheckersRegistry getInstance() {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
return new CheckersRegistry();
|
return new CheckersRegistry();
|
||||||
|
if (initialized == false)
|
||||||
|
throw new IllegalStateException("Registry is not initialized"); //$NON-NLS-1$
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue