Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: erroneous QueryCompiler retry when nothing unaccounted for #6451

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,17 @@ public void testCollidingCompile() throws Exception {

@Test
public void testMultiCompileWithFailure() throws ExecutionException, InterruptedException {
final String goodProgram = String.join(
"\n",
final String goodProgram = String.join("\n",
"public class GoodTest {",
" public static void main (String [] args) {",
" }",
"}");
final String badProgram = String.join(
"\n",
"public class BadTest {",
" public static void main (String [] args) {",
" }",
"}}");
final String badProgram = String.join("\n",
"public class Formula {",
" public Formula() {",
" S.badCall(0);",
" }",
"}");

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

try {
ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);
// noinspection DataFlowIssue
throw Assert.statementNeverExecuted();
} catch (Exception ignored) {
}
ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);

Assert.eqTrue(resolvers[0].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
Assert.eqTrue(resolvers[1].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
Assert.neqNull(resolvers[1].getFuture().get(), "resolvers[1].getFuture().get()");
}

@Test
public void testMultiCompileWithFailureSecond() throws ExecutionException, InterruptedException {
final String badProgram = String.join("\n",
"public class Formula {",
" public Formula() {",
" S.badCall(0);",
" }",
"}");
final String goodProgram = String.join("\n",
"public class Formula {",
" public static void main (String [] args) {",
" }",
"}");

QueryCompilerRequest[] requests = new QueryCompilerRequest[] {
QueryCompilerRequest.builder()
.description("Test Good Compile")
.className("Formula")
.classBody(goodProgram)
.packageNameRoot("com.deephaven.test")
.build(),
QueryCompilerRequest.builder()
.description("Test Bad Compile")
.className("Formula")
.classBody(badProgram)
.packageNameRoot("com.deephaven.test")
.build(),
};

// noinspection unchecked
CompletionStageFuture.Resolver<Class<?>>[] resolvers =
(CompletionStageFuture.Resolver<Class<?>>[]) new CompletionStageFuture.Resolver[] {
CompletionStageFuture.make(),
CompletionStageFuture.make(),
};

ExecutionContext.getContext().getQueryCompiler().compile(requests, resolvers);

Assert.eqTrue(resolvers[1].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
Assert.eqTrue(resolvers[0].getFuture().isDone(), "resolvers[0].getFuture().isDone()");
Assert.neqNull(resolvers[0].getFuture().get(), "resolvers[1].getFuture().get()");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ private boolean doCreateClassesSingleRound(
}
});

return wantRetry;
return wantRetry && !toRetry.isEmpty();
}

/**
Expand Down