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

remote-dev does not watch config files #12567

Merged
merged 1 commit into from
Oct 7, 2020
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 @@ -13,7 +13,7 @@ public class HotDeploymentConfigFileBuildStep {
@BuildStep
ServiceStartBuildItem setupConfigFileHotDeployment(List<HotDeploymentWatchedFileBuildItem> files) {
// TODO: this should really be an output of the RuntimeRunner
RuntimeUpdatesProcessor processor = IsolatedDevModeMain.runtimeUpdatesProcessor;
RuntimeUpdatesProcessor processor = RuntimeUpdatesProcessor.INSTANCE;
if (processor != null) {
Map<String, Boolean> watchedFilePaths = files.stream()
.collect(Collectors.toMap(HotDeploymentWatchedFileBuildItem::getLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<S
private final List<HotReplacementSetup> hotReplacementSetups = new ArrayList<>();
private static volatile RunningQuarkusApplication runner;
static volatile Throwable deploymentProblem;
static volatile RuntimeUpdatesProcessor runtimeUpdatesProcessor;
private static volatile CuratedApplication curatedApplication;
private static volatile AugmentAction augmentAction;
private static volatile boolean restarting;
Expand Down Expand Up @@ -95,8 +94,8 @@ public void accept(Integer integer) {
System.in.read();
}
System.out.println("Restarting...");
runtimeUpdatesProcessor.checkForChangedClasses();
restartApp(runtimeUpdatesProcessor.checkForFileChange());
RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses();
restartApp(RuntimeUpdatesProcessor.INSTANCE.checkForFileChange());
} catch (Exception e) {
log.error("Failed to restart", e);
}
Expand All @@ -117,7 +116,7 @@ public void accept(Integer integer) {
//we need to set this here, while we still have the correct TCCL
//this is so the config is still valid, and we can read HTTP config from application.properties
log.info("Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
if (runtimeUpdatesProcessor != null) {
if (RuntimeUpdatesProcessor.INSTANCE != null) {
Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());

try {
Expand All @@ -126,7 +125,7 @@ public void accept(Integer integer) {
.loadClass(LoggingSetupRecorder.class.getName());
cl.getMethod("handleFailedStart").invoke(null);
}
runtimeUpdatesProcessor.startupFailed();
RuntimeUpdatesProcessor.INSTANCE.startupFailed();
} catch (Exception e) {
close();
log.error("Failed to recover after failed start", e);
Expand Down Expand Up @@ -253,7 +252,7 @@ public void close() {
} finally {
try {
try {
runtimeUpdatesProcessor.close();
RuntimeUpdatesProcessor.INSTANCE.close();
} catch (IOException e) {
log.error("Failed to close compiler", e);
}
Expand Down Expand Up @@ -340,19 +339,20 @@ public boolean test(String s) {
sourcePath -> module.addSourcePaths(singleton(sourcePath.toAbsolutePath().toString()))));
}
}
runtimeUpdatesProcessor = setupRuntimeCompilation(context, (Path) params.get(APP_ROOT),
RuntimeUpdatesProcessor.INSTANCE = setupRuntimeCompilation(context, (Path) params.get(APP_ROOT),
(DevModeType) params.get(DevModeType.class.getName()));
if (runtimeUpdatesProcessor != null) {
runtimeUpdatesProcessor.checkForFileChange();
runtimeUpdatesProcessor.checkForChangedClasses();
if (RuntimeUpdatesProcessor.INSTANCE != null) {
RuntimeUpdatesProcessor.INSTANCE.checkForFileChange();
RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses();
}
firstStart(deploymentClassLoader, codeGens);

// doStart(false, Collections.emptySet());
if (deploymentProblem != null || runtimeUpdatesProcessor.getCompileProblem() != null) {
if (deploymentProblem != null || RuntimeUpdatesProcessor.INSTANCE.getCompileProblem() != null) {
if (context.isAbortOnFailedStart()) {
throw new RuntimeException(
deploymentProblem == null ? runtimeUpdatesProcessor.getCompileProblem() : deploymentProblem);
deploymentProblem == null ? RuntimeUpdatesProcessor.INSTANCE.getCompileProblem()
: deploymentProblem);
}
}
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class IsolatedRemoteDevModeMain implements BiConsumer<CuratedApplication,

private final List<HotReplacementSetup> hotReplacementSetups = new ArrayList<>();
static volatile Throwable deploymentProblem;
static volatile RuntimeUpdatesProcessor runtimeUpdatesProcessor;
static volatile RemoteDevClient remoteDevClient;
static volatile Closeable remoteDevClientSession;
private static volatile CuratedApplication curatedApplication;
Expand Down Expand Up @@ -150,7 +149,7 @@ void regenerateApplication(Set<String> ignore) {
public void close() {
try {
try {
runtimeUpdatesProcessor.close();
RuntimeUpdatesProcessor.INSTANCE.close();
} catch (IOException e) {
log.error("Failed to close compiler", e);
}
Expand Down Expand Up @@ -190,11 +189,11 @@ public void accept(CuratedApplication o, Map<String, Object> o2) {
}

augmentAction = new AugmentActionImpl(curatedApplication);
runtimeUpdatesProcessor = setupRuntimeCompilation(context, appRoot);
RuntimeUpdatesProcessor.INSTANCE = setupRuntimeCompilation(context, appRoot);

if (runtimeUpdatesProcessor != null) {
runtimeUpdatesProcessor.checkForFileChange();
runtimeUpdatesProcessor.checkForChangedClasses();
if (RuntimeUpdatesProcessor.INSTANCE != null) {
RuntimeUpdatesProcessor.INSTANCE.checkForFileChange();
RuntimeUpdatesProcessor.INSTANCE.checkForChangedClasses();
}

JarResult result = generateApplication();
Expand Down Expand Up @@ -254,7 +253,7 @@ private RemoteDevClient.SyncResult runSync() {
Set<String> removed = new HashSet<>();
Map<String, byte[]> changed = new HashMap<>();
try {
boolean scanResult = runtimeUpdatesProcessor.doScan(true);
boolean scanResult = RuntimeUpdatesProcessor.INSTANCE.doScan(true);
if (!scanResult && !copiedStaticResources.isEmpty()) {
scanResult = true;
regenerateApplication(Collections.emptySet());
Expand Down Expand Up @@ -291,7 +290,7 @@ public Set<String> getRemovedFiles() {

@Override
public Throwable getProblem() {
return runtimeUpdatesProcessor.getDeploymentProblem();
return RuntimeUpdatesProcessor.INSTANCE.getDeploymentProblem();
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable
private static final Logger log = Logger.getLogger(RuntimeUpdatesProcessor.class);

private static final String CLASS_EXTENSION = ".class";
static volatile RuntimeUpdatesProcessor INSTANCE;

private final Path applicationRoot;
private final DevModeContext context;
Expand Down