Fix IndexOutOfBoundsException caused by asynchronous init of MathRegistry
This commit is contained in:
parent
3c03f3948d
commit
07b989f00e
@ -170,7 +170,9 @@ public abstract class AbstractMathRegistry<T extends MathEntity> implements Math
|
|||||||
public List<String> getNames() {
|
public List<String> getNames() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!entityNames.isEmpty()) {
|
if (!entityNames.isEmpty()) {
|
||||||
return entityNames;
|
// if the registry is not initialized yet we expect entityNames to be updated on a
|
||||||
|
// background thread => return its copy
|
||||||
|
return !initialized ? new ArrayList<>(entityNames) : entityNames;
|
||||||
}
|
}
|
||||||
for (T entity : entities) {
|
for (T entity : entities) {
|
||||||
final String name = entity.getName();
|
final String name = entity.getName();
|
||||||
@ -178,7 +180,9 @@ public abstract class AbstractMathRegistry<T extends MathEntity> implements Math
|
|||||||
entityNames.add(name);
|
entityNames.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entityNames;
|
// if the registry is not initialized yet we expect entityNames to be updated on a
|
||||||
|
// background thread => return its copy
|
||||||
|
return !initialized ? new ArrayList<>(entityNames) : entityNames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user