mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
refactor: optimize initialization of workflow context
This commit is contained in:
parent
da6eb3705b
commit
44ae97d6d8
@ -5,6 +5,7 @@ import com.github.kfcfans.powerjob.common.utils.JsonUtils;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -34,11 +35,14 @@ public class WorkflowContext {
|
|||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public WorkflowContext(Long instanceId, String data) {
|
public WorkflowContext(Long instanceId, String data) {
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
|
if (StringUtils.isBlank(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Map originMap = JsonUtils.parseObject(data, Map.class);
|
Map originMap = JsonUtils.parseObject(data, Map.class);
|
||||||
originMap.forEach((k, v) -> this.data.put(String.valueOf(k), v == null ? null : String.valueOf(v)));
|
originMap.forEach((k, v) -> this.data.put(String.valueOf(k), v == null ? null : String.valueOf(v)));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
log.warn("[WorkflowContext-{}] parse workflow context failed, {}", instanceId, exception);
|
log.warn("[WorkflowContext-{}] parse workflow context failed, {}", instanceId, exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user