Skip to content

Commit 6e31800

Browse files
authored
Include scan-only changes when a recipe times out (#5172)
1 parent e84018e commit 6e31800

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

rewrite-core/src/main/java/org/openrewrite/table/RecipeRunStats.java

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public RecipeRunStats(Recipe recipe) {
4444
}
4545

4646
public void recordSourceFileChanged(@Nullable SourceFile before, @Nullable SourceFile after) {
47-
if(after != null) {
47+
if (after != null) {
4848
sourceFileChanged.add(after.getSourcePath());
49-
} else if(before != null) {
49+
} else if (before != null) {
5050
sourceFileChanged.add(before.getSourcePath());
5151
}
5252
}
@@ -80,15 +80,40 @@ public void flush(ExecutionContext ctx) {
8080
scanner == null ? 0 : (long) scanner.max(TimeUnit.NANOSECONDS),
8181
(long) editor.totalTime(TimeUnit.NANOSECONDS),
8282
editor.takeSnapshot().percentileValues()[0].percentile(),
83-
(long) editor.max(TimeUnit.NANOSECONDS));
84-
//noinspection DuplicatedCode
85-
ctx.computeMessage(ExecutionContext.DATA_TABLES, row, ConcurrentHashMap::new, (extract, allDataTables) -> {
86-
//noinspection unchecked
87-
List<Row> dataTablesOfType = (List<Row>) allDataTables.computeIfAbsent(this, c -> new ArrayList<>());
88-
dataTablesOfType.add(row);
89-
return allDataTables;
90-
});
83+
(long) editor.max(TimeUnit.NANOSECONDS)
84+
);
85+
addRowToDataTable(ctx, row);
9186
}
87+
88+
// find scanners that never finished their edit phase
89+
for (Timer scanner : registry.find("rewrite.recipe.scan").timers()) {
90+
String recipeName = requireNonNull(scanner.getId().getTag("name"));
91+
if (registry.find("rewrite.recipe.edit").tag("name", recipeName).timer() == null) {
92+
Row row = new Row(
93+
recipeName,
94+
Long.valueOf(scanner.count()).intValue(),
95+
sourceFileChanged.size(),
96+
(long) scanner.totalTime(TimeUnit.NANOSECONDS),
97+
scanner.takeSnapshot().percentileValues()[0].percentile(),
98+
(long) scanner.max(TimeUnit.NANOSECONDS),
99+
0L,
100+
0.0,
101+
0L
102+
);
103+
104+
addRowToDataTable(ctx, row);
105+
}
106+
}
107+
}
108+
109+
private void addRowToDataTable(ExecutionContext ctx, Row row) {
110+
//noinspection DuplicatedCode
111+
ctx.computeMessage(ExecutionContext.DATA_TABLES, row, ConcurrentHashMap::new, (extract, allDataTables) -> {
112+
//noinspection unchecked
113+
List<Row> dataTablesOfType = (List<Row>) allDataTables.computeIfAbsent(this, c -> new ArrayList<>());
114+
dataTablesOfType.add(row);
115+
return allDataTables;
116+
});
92117
}
93118

94119
@Value

0 commit comments

Comments
 (0)