Skip to content

Commit

Permalink
fix: reporting of JVM hot reload compile errors (#3839)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas authored Dec 22, 2024
1 parent b74b3c5 commit 59e3c99
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -101,6 +102,9 @@ public void reportDevModeProblems(FTLRecorder recorder, OutputTargetBuildItem ou
Path errorOutput = outputTargetBuildItem.getOutputDirectory().resolve(ERRORS_OUT);
devModeProblemTimer = new Timer("FTL Dev Mode Error Report", true);
devModeProblemTimer.schedule(new TimerTask() {

String errorHash;

@Override
public void run() {
Throwable compileProblem = RuntimeUpdatesProcessor.INSTANCE.getCompileProblem();
Expand All @@ -121,15 +125,34 @@ public void run() {
.setMsg(deploymentProblems.getMessage())
.build());
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (var out = Files.newOutputStream(errorOutput)) {
builder.build().writeTo(baos);
errorHash = HashUtil.sha256(baos.toByteArray());
builder.build().writeTo(out);
} catch (IOException e) {
log.error("Failed to write error list", e);
}
} else if (errorHash != null) {
if (!Files.exists(errorOutput)) {
// File already cleared
errorHash = null;
} else {
try {
var currentHash = HashUtil.sha256(Files.readAllBytes(errorOutput));
if (currentHash.equals(errorHash)) {
try (OutputStream output = Files.newOutputStream(errorOutput)) {
ErrorList.newBuilder().build().writeTo(output);
}
}
} catch (IOException e) {
log.errorf("Failed to read error list", e);
}
}
}
}
}, 1000, 1000);
((QuarkusClassLoader) Thread.currentThread().getContextClassLoader()).addCloseTask(new Runnable() {
((QuarkusClassLoader) ModuleProcessor.class.getClassLoader()).addCloseTask(new Runnable() {
@Override
public void run() {
devModeProblemTimer.cancel();
Expand Down

0 comments on commit 59e3c99

Please sign in to comment.