This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new a366894c00 copy sensor map for workflow
a366894c00 is described below
commit a366894c0024fb3e8f4f3efec647b9122b9a00db
Author: Alex Heneveld <[email protected]>
AuthorDate: Tue Jun 27 01:24:22 2023 +0100
copy sensor map for workflow
so that references are point in time, and copies of values are serializable
---
.../core/workflow/store/WorkflowStatePersistenceViaSensors.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git
a/core/src/main/java/org/apache/brooklyn/core/workflow/store/WorkflowStatePersistenceViaSensors.java
b/core/src/main/java/org/apache/brooklyn/core/workflow/store/WorkflowStatePersistenceViaSensors.java
index 716d3befce..51cb28a068 100644
---
a/core/src/main/java/org/apache/brooklyn/core/workflow/store/WorkflowStatePersistenceViaSensors.java
+++
b/core/src/main/java/org/apache/brooklyn/core/workflow/store/WorkflowStatePersistenceViaSensors.java
@@ -155,8 +155,8 @@ public class WorkflowStatePersistenceViaSensors {
int updateMap(Entity entity, boolean doExpiry, boolean persist,
Consumer<Map<String,WorkflowExecutionContext>> action) {
AtomicInteger delta = new AtomicInteger(0);
- entity.sensors().modify(INTERNAL_WORKFLOWS, v -> {
- if (v == null) v = MutableMap.of();
+ entity.sensors().modify(INTERNAL_WORKFLOWS, vo -> {
+ Map<String, WorkflowExecutionContext> v = MutableMap.copyOf(vo);
delta.set(-v.size());
if (action!=null) action.accept(v);
if (doExpiry) v =
WorkflowRetentionAndExpiration.recomputeExpiration(v, null);
@@ -174,10 +174,11 @@ public class WorkflowStatePersistenceViaSensors {
}
public void updateWithoutPersist(Entity entity,
List<WorkflowExecutionContext> workflows) {
- if (workflows!=null && !workflows.isEmpty())
entity.sensors().modify(INTERNAL_WORKFLOWS, v -> {
- if (v == null) {
+ if (workflows!=null && !workflows.isEmpty())
entity.sensors().modify(INTERNAL_WORKFLOWS, vo -> {
+ if (vo == null) {
throw new IllegalStateException("Update workflows requested
for "+workflows+" when none recorded against "+entity);
}
+ Map<String, WorkflowExecutionContext> v = MutableMap.copyOf(vo);
workflows.forEach(w -> v.put(w.getWorkflowId(), w));
return Maybe.of(v);
});