Skip to content

Commit

Permalink
runtime-v2: fix currentFlowName after restoring from a checkpoint (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Mar 6, 2022
1 parent 2a78b00 commit b70082d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -49,7 +49,7 @@ private static boolean containsStep(List<Step> steps, Step step) {
}

for (Step s : steps) {
if (s == step) {
if (s.getLocation().equals(step.getLocation())) {
return true;
} else if (s instanceof IfStep) {
boolean contains = containsStep(((IfStep) s).getThenSteps(), step)
Expand Down Expand Up @@ -78,4 +78,4 @@ private static boolean containsStep(List<Step> steps, Step step) {

private ProcessDefinitionUtils() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static Atom current(JsonParser p) throws IOException {
default:
value = null;
}
return new Atom(toLocation(p.getTokenLocation()), p.currentToken(), p.getCurrentName(), value);
return new Atom(toLocation(p.currentTokenLocation()), p.currentToken(), p.getCurrentName(), value);
}

public final Location location;
Expand Down Expand Up @@ -102,10 +102,6 @@ public String toString() {
}

private static Location toLocation(JsonLocation tokenLocation) {
if (tokenLocation == null) {
return Location.builder().build();
}

return Location.builder()
.lineNum(tokenLocation.getLineNr())
.column(tokenLocation.getColumnNr())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public void testProcessDefinition() throws Exception {

Trigger trigger = Trigger.builder()
.name("github")
.location(location())
.putConfiguration("entryPoint", "www")
.putConfiguration("useInitiator", true)
.putConditions("type", "push")
Expand Down Expand Up @@ -340,7 +341,9 @@ private void assertResult(String resource, String result) throws Exception {
}

private static Location location() {
return Location.builder().build();
return Location.builder()
.fileName("test.concord.yml")
.build();
}

private static SimpleOptions simpleOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,12 @@ public void testCurrentFlowName() throws Exception {
byte[] log = run();
assertLog(log, ".*default: default.*");
assertLog(log, ".*myFlow: myFlow.*");

checkpointService.restore("first", workDir);

run();

assertLogAtLeast(allLogs, 2, ".*after checkpoint: default.*");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ flows:
- log: "default: ${currentFlowName()}"
- call: myFlow

- checkpoint: "first"
- log: "after checkpoint: ${currentFlowName()}"

myFlow:
- log: "myFlow: ${currentFlowName()}"

0 comments on commit b70082d

Please sign in to comment.