Skip to content

Commit

Permalink
chore: fix sonar bugs #3640
Browse files Browse the repository at this point in the history
  • Loading branch information
jgomer2001 committed Jan 19, 2023
1 parent f716bd4 commit 092fadd
Showing 1 changed file with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ private Set<String> createFlows(Path dir, DeploymentDetails dd) throws IOExcepti

Set<Path> flowsPaths = flowsCode.keySet();
for (Path p: flowsPaths) {
logger.debug("Reading {}", p.getFileName().toString());
if (logger.isDebugEnabled()) {
logger.debug("Reading {}", p.getFileName());
}
flowsCode.put(p, Files.readString(p));
}

Expand Down Expand Up @@ -345,10 +347,14 @@ private Set<String> computeSourcePaths(Path lib) throws IOException {

BiPredicate<Path, BasicFileAttributes> matcher = (path, attrs) -> attrs.isRegularFile() &&
Stream.of(SCRIPTS_EXTENSIONS).anyMatch(ext -> path.getFileName().toString().endsWith("." + ext));

if (Files.isDirectory(lib)) {
String slib = lib.toString();
return Files.find(lib, 20, matcher).map(Path::toString)
.map(s -> s.substring(slib.length() + 1)).collect(Collectors.toSet());

try (Stream<Path> stream = Files.find(lib, 20, matcher)) {
return stream.map(Path::toString)
.map(s -> s.substring(slib.length() + 1)).collect(Collectors.toSet());
}
}
return Collections.emptySet();

Expand All @@ -363,7 +369,10 @@ private Set<String> transferJarFiles(Path lib) throws IOException {
BiPredicate<Path, BasicFileAttributes> matcher =
(path, attrs) -> attrs.isRegularFile() && path.getFileName().toString().endsWith(".jar");

List<Path> list = Files.find(lib, 1, matcher).collect(Collectors.toList());
List<Path> list = null;
try (Stream<Path> stream = Files.find(lib, 1, matcher)) {
list = stream.collect(Collectors.toList());
}
logger.debug("Moving {} jar files to custom libs dir", list.size());

for (Path jar : list) {
Expand Down Expand Up @@ -524,19 +533,19 @@ private void purge(Set<String> dirs, Set<String> filesToRemove) throws IOExcepti
}
}

if (filesToRemove != null) {
for (String f : filesToRemove) {
Path p = null;
if (filesToRemove == null) return;

if (f.endsWith(".jar")) {
p = Paths.get(CUST_LIBS_DIR, f);
} else {
p = Paths.get(ASSETS_DIR, SCRIPTS_SUBDIR, f);
}

logger.debug("Removing file {}", f);
Files.deleteIfExists(p);
for (String f : filesToRemove) {
Path p = null;

if (f.endsWith(".jar")) {
p = Paths.get(CUST_LIBS_DIR, f);
} else {
p = Paths.get(ASSETS_DIR, SCRIPTS_SUBDIR, f);
}

logger.debug("Removing file {}", f);
Files.deleteIfExists(p);
}

}
Expand Down

0 comments on commit 092fadd

Please sign in to comment.