diff --git a/jscl/src/main/java/org/solovyev/common/math/AbstractMathRegistry.java b/jscl/src/main/java/org/solovyev/common/math/AbstractMathRegistry.java index 97797e9c..862a571b 100644 --- a/jscl/src/main/java/org/solovyev/common/math/AbstractMathRegistry.java +++ b/jscl/src/main/java/org/solovyev/common/math/AbstractMathRegistry.java @@ -170,7 +170,9 @@ public abstract class AbstractMathRegistry implements Math public List getNames() { synchronized (this) { 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) { final String name = entity.getName(); @@ -178,7 +180,9 @@ public abstract class AbstractMathRegistry implements Math 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; } }