From 1f325e75c6a9e2cb900e99a426de807c1601f46a Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Thu, 16 May 2024 14:52:26 +0200 Subject: [PATCH] Allow processors to notify extensions of no-restart changes (cherry picked from commit bf266dc29c7c3ebf5278842514d52100c891e9b6) --- .../dev/RuntimeUpdatesProcessor.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java index de09063b148bb..46b3ba3b1862c 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/dev/RuntimeUpdatesProcessor.java @@ -398,7 +398,11 @@ public Throwable getDeploymentProblem() { @Override public void setRemoteProblem(Throwable throwable) { compileProblem = throwable; - getCompileOutput().setMessage(throwable.getMessage()); + if (throwable == null) { + getCompileOutput().setMessage(null); + } else { + getCompileOutput().setMessage(throwable.getMessage()); + } } private StatusLine getCompileOutput() { @@ -561,9 +565,7 @@ public boolean doScan(boolean userInitiated, boolean forceRestart) { return true; } else if (!filesChanged.isEmpty()) { try { - for (Consumer> consumer : noRestartChangesConsumers) { - consumer.accept(filesChanged); - } + notifyExtensions(filesChanged); hotReloadProblem = null; getCompileOutput().setMessage(null); } catch (Throwable t) { @@ -585,6 +587,30 @@ public boolean doScan(boolean userInitiated, boolean forceRestart) { } } + /** + * This notifies registered extensions of "no-restart" changed files. + * + * @param noRestartChangedFiles the Set of changed files + */ + public void notifyExtensions(Set noRestartChangedFiles) { + if (lastStartIndex == null) { + // we don't notify extensions if the application never started + return; + } + scanLock.lock(); + codeGenLock.lock(); + try { + + for (Consumer> consumer : noRestartChangesConsumers) { + consumer.accept(noRestartChangedFiles); + } + } finally { + scanLock.unlock(); + codeGenLock.unlock(); + } + + } + public boolean instrumentationEnabled() { if (instrumentationEnabled != null) { return instrumentationEnabled;