From 8577ce286727210b4f8fb057f103ea1fe567efcf Mon Sep 17 00:00:00 2001 From: Ashley <73482956+ascopes@users.noreply.github.com> Date: Sat, 28 Sep 2024 09:05:57 +0100 Subject: [PATCH] Remove noisy logging in SystemPathBinaryResolver.java --- .../utils/SystemPathBinaryResolver.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/utils/SystemPathBinaryResolver.java b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/utils/SystemPathBinaryResolver.java index 47c8267a..be94125b 100644 --- a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/utils/SystemPathBinaryResolver.java +++ b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/utils/SystemPathBinaryResolver.java @@ -46,32 +46,29 @@ public SystemPathBinaryResolver(HostSystem hostSystem) { } public Optional resolve(String name) throws ResolutionException { - log.debug("Looking for executable matching name '{}' on the path", name); - + log.debug("Looking for executable matching name '{}' on PATH", name); var predicate = hostSystem.isProbablyWindows() ? isWindowsMatch(name) : isPosixMatch(name); - var result = Optional.empty(); - for (var dir : hostSystem.getSystemPath()) { try (var files = Files.walk(dir, 1)) { - result = files.filter(predicate).findFirst(); + var result = files.filter(predicate).findFirst(); if (result.isPresent()) { - break; + log.debug("Result for lookup of '{}' on PATH was {}", name, result.get()); + return result; } } catch (IOException ex) { throw new ResolutionException("An exception occurred while scanning the system PATH", ex); } } - log.debug("Result for lookup of '{}' was {}", name, result); - return result; + log.debug("No match found for '{}' on PATH", name); + return Optional.empty(); } private Predicate isWindowsMatch(String name) { - log.debug("Using Windows path matching strategy"); return path -> { var matchesName = FileUtils.getFileNameWithoutExtension(path) .equalsIgnoreCase(name); @@ -81,7 +78,7 @@ private Predicate isWindowsMatch(String name) { .isPresent(); log.debug( - "Path '{}' (WINDOWS) matches name = {}, matches executable extension = {}", + "Path '{}' matches name = {}, matches executable extension = {}", path, matchesName, matchesExtension @@ -92,13 +89,12 @@ private Predicate isWindowsMatch(String name) { } private Predicate isPosixMatch(String name) { - log.debug("Using POSIX path matching strategy"); return path -> { var matchesName = path.getFileName().toString().equals(name); var matchesExecutableFlag = Files.isExecutable(path); log.debug( - "Path '{}' (POSIX) matches name = {}, matches executable flag = {}", + "Path '{}' matches name = {}, matches executable flag = {}", path, matchesName, matchesExecutableFlag