Skip to content

Commit 3827ba0

Browse files
authored
fix: erroneous QueryCompiler retry when nothing unaccounted for (#6451)
Fixes #6216
1 parent 0f761b8 commit 3827ba0

File tree

2 files changed

+52
-15
lines changed

2 files changed

+52
-15
lines changed

engine/context/src/test/java/io/deephaven/engine/context/TestQueryCompiler.java

+51-14
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,17 @@ public void testCollidingCompile() throws Exception {
264264

265265
@Test
266266
public void testMultiCompileWithFailure() throws ExecutionException, InterruptedException {
267-
final String goodProgram = String.join(
268-
"\n",
267+
final String goodProgram = String.join("\n",
269268
"public class GoodTest {",
270269
" public static void main (String [] args) {",
271270
" }",
272271
"}");
273-
final String badProgram = String.join(
274-
"\n",
275-
"public class BadTest {",
276-
" public static void main (String [] args) {",
277-
" }",
278-
"}}");
272+
final String badProgram = String.join("\n",
273+
"public class Formula {",
274+
" public Formula() {",
275+
" S.badCall(0);",
276+
" }",
277+
"}");
279278

280279
QueryCompilerRequest[] requests = new QueryCompilerRequest[] {
281280
QueryCompilerRequest.builder()
@@ -299,15 +298,53 @@ public void testMultiCompileWithFailure() throws ExecutionException, Interrupted
299298
CompletionStageFuture.make(),
300299
};
301300

302-
try {
303-
ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);
304-
// noinspection DataFlowIssue
305-
throw Assert.statementNeverExecuted();
306-
} catch (Exception ignored) {
307-
}
301+
ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);
308302

309303
Assert.eqTrue(resolvers[0].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
310304
Assert.eqTrue(resolvers[1].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
311305
Assert.neqNull(resolvers[1].getFuture().get(), "resolvers[1].getFuture().get()");
312306
}
307+
308+
@Test
309+
public void testMultiCompileWithFailureSecond() throws ExecutionException, InterruptedException {
310+
final String badProgram = String.join("\n",
311+
"public class Formula {",
312+
" public Formula() {",
313+
" S.badCall(0);",
314+
" }",
315+
"}");
316+
final String goodProgram = String.join("\n",
317+
"public class Formula {",
318+
" public static void main (String [] args) {",
319+
" }",
320+
"}");
321+
322+
QueryCompilerRequest[] requests = new QueryCompilerRequest[] {
323+
QueryCompilerRequest.builder()
324+
.description("Test Good Compile")
325+
.className("Formula")
326+
.classBody(goodProgram)
327+
.packageNameRoot("com.deephaven.test")
328+
.build(),
329+
QueryCompilerRequest.builder()
330+
.description("Test Bad Compile")
331+
.className("Formula")
332+
.classBody(badProgram)
333+
.packageNameRoot("com.deephaven.test")
334+
.build(),
335+
};
336+
337+
// noinspection unchecked
338+
CompletionStageFuture.Resolver<Class<?>>[] resolvers =
339+
(CompletionStageFuture.Resolver<Class<?>>[]) new CompletionStageFuture.Resolver[] {
340+
CompletionStageFuture.make(),
341+
CompletionStageFuture.make(),
342+
};
343+
344+
ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);
345+
346+
Assert.eqTrue(resolvers[1].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
347+
Assert.eqTrue(resolvers[0].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
348+
Assert.neqNull(resolvers[0].getFuture().get(), "resolvers[1].getFuture().get()");
349+
}
313350
}

engine/table/src/main/java/io/deephaven/engine/context/QueryCompilerImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ private boolean doCreateClassesSingleRound(
10041004
}
10051005
});
10061006

1007-
return wantRetry;
1007+
return wantRetry && !toRetry.isEmpty();
10081008
}
10091009

10101010
/**

0 commit comments

Comments
 (0)