davsclaus opened a new pull request, #26653: URL: https://github.com/apache/camel/pull/26653
## Description The stepwise benchmark reported that a Java class added to a running `camel run --source-dir --dev` project was not compiled on the reload. Reproducing it showed something narrower: a class added at the top of the source directory *is* compiled and usable within seconds; the class the benchmark added was under `src/main/java/camel/example`, and that tree was invisible to the watcher. `FileWatcherResourceReloadStrategy` registers the directory tree once in `doStart` when recursive. The JDK watch service only reports events for registered directories, and a new directory arrives as one create event on its parent, which the watch task skipped with `if (file.isDirectory()) continue`. So every file written under a directory created after the start went unseen. - When recursive, a directory created under a watched one is registered as it appears, walking its subdirectories (a tree such as `src/main/java/com/acme` is created with its first file in it before the watcher can see the directory), and the files already in it are handled as changes. The macOS sensitivity modifier is kept for the new registrations. - The watcher ignores the compile work directory (`CompileStrategy.getWorkDir()`, `.camel-jbang/compile` for the CLI), at registration and in the event loop: the class files the runtime writes there when it compiles a source are not changes to watch, and with a `*` pattern they would trigger a reload, which compiles again, which writes again. Live check with `camel run --source-dir --dev` and the benchmark's sequence, class under `src/main/java`, a beans.yaml declaring it, the route using it: five new directories watched as they appeared, one reload for the class, the bean bound and the route logging "New order ORD-1001..." with no reload for the class file. Upgrade guide note added. ## Tests - `FileWatcherResourceReloadStrategyTest` (camel-core, real directories and a real watcher, local only since the watch service is too slow to time on the CI file systems): a tree created after the start with a file in it is reloaded, a file written later into the new tree is reloaded, a class file written into the compile work dir is not. - The reload and secret rotation tests of camel-core (23) green. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
