Fixed the race condition: print dev mode ready message after WatchService registration - #526
Open
sajeerzeji wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes OpenLiberty/ci.maven#2070
PR Ci.Maven: OpenLiberty/ci.maven#2073
PR Ci.Gradle: OpenLiberty/ci.gradle#1095
In DevUtil.watchFiles(), the "Liberty is running in dev mode." startup banner is now printed after all source, test, config, and resource directories have been registered with the WatchService, but before initWatchLoop() enters the event poll. Previously the banner was emitted by runHotkeyReaderThread() in the callers (ci.maven's DevMojo, ci.gradle's DevTask) before watchFiles() was even called, meaning any file change made immediately after that message by a test or a user could race ahead of the watcher and be silently dropped with no recompile triggered. Moving the print into watchFiles() and checking it in with the existing firstStartup flag makes the ready message a reliable synchronisation point: once a user or test sees it, the WatchService is fully set up and guaranteed to detect changes. The runHotkeyReaderThread() post test run re print path is unchanged.