davsclaus commented on code in PR #27847:
URL: https://github.com/apache/camel/pull/27847#discussion_r4275536431
##########
core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java:
##########
@@ -193,6 +230,127 @@ protected void doStart() throws Exception {
super.doStart();
}
+ private static boolean matches(AntPathMatcher matcher, String part, String
name, String path, String relative) {
+ return name.equals(part) || matcher.match(part, path, false)
+ || relative != null && matcher.match(part, relative, false);
+ }
+
+ /**
+ * A folder that an exclude of the pattern matches as a whole, such as
<tt>inbox</tt> for <tt>!inbox/**</tt>: the
+ * folder is left out of the scan, so the files the routes read and write
in it are not walked on every scan.
+ */
+ @Override
+ protected boolean isExcludedDirectory(Path dir) {
+ if (excludes.isEmpty() || folder == null) {
+ return false;
+ }
+ String relative = relativePath(dir.toFile());
+ if (relative == null || relative.isEmpty()) {
+ return false;
+ }
+ for (String part : excludes) {
+ // inbox and inbox/** match the folder itself; a file pattern such
as *.json does not leave a folder out
+ if (part.equals(relative) || AntPathMatcher.INSTANCE.match(part,
relative + "/_", false)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** The file a route was loaded from, as an absolute path, or null when it
is not a file. */
+ private static Path sourcePath(Resource resource) {
+ String location = resource != null ? resource.getLocation() : null;
+ if (location == null || location.contains(":") &&
!location.startsWith("file:")) {
+ return null;
+ }
+ try {
+ return Paths.get(location.startsWith("file:") ?
location.substring(5) : location).toAbsolutePath().normalize();
+ } catch (Exception e) {
Review Comment:
Kept on purpose. `sourcePath` only helps tell data files from route sources
for the reload-loop warning, so any failure to resolve a location should mean
"not a file source" and never break a reload. That includes a
`SecurityException` from `toAbsolutePath()`, not only `InvalidPathException`.
Thanks for the rounds; the other five points are in.
_Claude Code on behalf of @davsclaus._
--
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]