From f07ed76097f4b0cf274fc936525e29f350ab9f9d Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 24 Jan 2024 10:05:08 -0800 Subject: [PATCH] Fixing workbench init context implementation Init context add timer could cause null pointer exception if model instances didn't exist. --- .../digitaltwin/development/TwinExecutionEngine.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Development/src/main/java/com/scaleoutsoftware/digitaltwin/development/TwinExecutionEngine.java b/Development/src/main/java/com/scaleoutsoftware/digitaltwin/development/TwinExecutionEngine.java index 385049a..fc55d30 100644 --- a/Development/src/main/java/com/scaleoutsoftware/digitaltwin/development/TwinExecutionEngine.java +++ b/Development/src/main/java/com/scaleoutsoftware/digitaltwin/development/TwinExecutionEngine.java @@ -75,8 +75,10 @@ void addDigitalTwin(String digitalTwinModelName, MessageProcessor digitalTwinMes } void addTimer(String modelName, String id, String timerName, TimerType type, Duration interval, TimerHandler handler) { - ConcurrentHashMap modelInstances = _modelInstances.get(modelName); + if(modelInstances == null) { + modelInstances = new ConcurrentHashMap<>(); + } TwinProxy proxy = modelInstances.get(id); SimulationScheduler scheduler = _simulationSchedulers.get(modelName); if (scheduler != null) {