fix NullPointException cause by empty result of skipped request #409

This commit is contained in:
Francis Dong
2022-03-17 17:25:32 +08:00
committed by dxfeng10
parent e6a9814ad2
commit 2df96ab4d3
2 changed files with 8 additions and 2 deletions

View File

@@ -215,7 +215,10 @@ public class Pipeline {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<Mono> monos = step.run(); List<Mono> monos = step.run();
Mono<Map>[] monoArray = monos.stream().toArray(Mono[]::new); Mono<Map>[] monoArray = monos.stream().toArray(Mono[]::new);
Mono<StepResponse>result = Flux.merge(monoArray).reduce(new HashMap(), (item1, item2)-> { Mono<StepResponse>result = Flux.merge(monoArray).reduce(new HashMap(), (item1, item2) -> {
if (item2.isEmpty()) {
return item1;
}
Input input = (Input)item2.get("request"); Input input = (Input)item2.get("request");
item1.put(input.getName() , item2.get("data")); item1.put(input.getName() , item2.get("data"));
return item1; return item1;

View File

@@ -132,7 +132,10 @@ public class Step {
if (input.needRun(ctx)) { if (input.needRun(ctx)) {
return input.run(); return input.run();
} }
return Mono.just(new HashMap()); Map<String, Object> inputResult = new HashMap<String, Object>();
inputResult.put("data", new HashMap<String, Object>());
inputResult.put("request", input);
return Mono.just(inputResult);
}).flatMap(r -> { }).flatMap(r -> {
if (r instanceof ComponentResult) { if (r instanceof ComponentResult) {
Map<String, Object> inputResult = new HashMap<String, Object>(); Map<String, Object> inputResult = new HashMap<String, Object>();