@@ -76,8 +76,8 @@ public enum ReportsDirectory {
7676 FAILSAFE_3 ("(.*)(ITCase)" , FAILSAFE_PATH ),
7777 ARTIFACT (".*" , "artifact-capture" );
7878
79- private String regex ;
80- private String folder ;
79+ private final String regex ;
80+ private final String folder ;
8181
8282 ReportsDirectory (String regex , String folder ) {
8383 this .regex = regex ;
@@ -196,11 +196,12 @@ public static String getBaseDir() {
196196
197197 private static class Visitor implements FileVisitor <Path > {
198198
199- private String baseName ;
200- private String extension ;
201- private int base , ext ;
202- private PathMatcher pathMatcher ;
203- private List <Integer > intList = new ArrayList <>();
199+ private final String baseName ;
200+ private final String extension ;
201+ private final int base ;
202+ private final int ext ;
203+ private final PathMatcher pathMatcher ;
204+ private final List <Integer > intList = new ArrayList <>();
204205
205206 Visitor (String baseName , String extension ) {
206207 this .baseName = baseName ;
@@ -221,7 +222,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
221222 String name = file .getFileName ().toString ();
222223 String iStr = "0" + name .substring (base , name .length () - ext );
223224 iStr = iStr .replace ("0-" , "" );
224- intList .add (Integer .valueOf (iStr ) + 1 );
225+ intList .add (Integer .parseInt (iStr ) + 1 );
225226 }
226227 return FileVisitResult .CONTINUE ;
227228 }
@@ -242,7 +243,7 @@ public String getNewName() {
242243 if (intList .isEmpty ()) {
243244 newName = baseName + "." + extension ;
244245 } else {
245- Collections .sort (intList , Collections .reverseOrder ());
246+ intList .sort (Collections .reverseOrder ());
246247 newName = baseName + "-" + intList .get (0 ) + "." + extension ;
247248 }
248249
@@ -286,9 +287,9 @@ public static boolean addSystemPathList(List<String> pathList) {
286287 }
287288 }
288289 String path = env .get (name );
289- return (path != null ) ? pathList . addAll ( Arrays .asList (path .split (File .pathSeparator ))) : false ;
290+ return (path != null ) && addNewPaths ( pathList , Arrays .asList (path .split (File .pathSeparator )));
290291 }
291-
292+
292293 /**
293294 * Append Macintosh path entries to the specified list.
294295 * <p>
@@ -300,27 +301,44 @@ public static boolean addSystemPathList(List<String> pathList) {
300301 */
301302 public static boolean addMacintoshPathList (List <String > pathList ) {
302303 boolean didChange = false ;
303- if (System .getProperty ("os.name" ).startsWith ("Mac" )) {
304- List <String > pathFileList = new ArrayList <>();
305- pathFileList .add ("/etc/paths" );
306- String [] paths = new File ("/etc/paths.d" ).list ();
307- if (paths != null ) {
308- pathFileList .addAll (Arrays .asList (paths ));
304+ if (OSInfo .getDefault ().getType () == OSInfo .OSType .MACINTOSH ) {
305+ List <File > fileList = new ArrayList <>();
306+ File pathsFile = new File ("/etc/paths" );
307+ if (pathsFile .exists ()) fileList .add (pathsFile );
308+ File [] pathsList = new File ("/etc/paths.d" ).listFiles ();
309+ if (pathsList != null ) {
310+ fileList .addAll (Arrays .asList (pathsList ));
309311 }
310- for (String thisPathFile : pathFileList ) {
311- File pathFile = new File (thisPathFile );
312- if (pathFile .exists ()) {
313- try {
314- didChange |= pathList .addAll (Files .readAllLines (pathFile .toPath ()));
315- } catch (IOException eaten ) {
316- // nothing to do here
317- }
312+ for (File thisFile : fileList ) {
313+ try {
314+ didChange |= addNewPaths (pathList , Files .readAllLines (thisFile .toPath ()));
315+ } catch (IOException eaten ) {
316+ // nothing to do here
318317 }
319318 }
320319 }
321320 return didChange ;
322321 }
323322
323+ /**
324+ * Append new path entries to the specified list.
325+ * <p>
326+ * <b>NOTE</b>: Entries from [newPaths] that already exist in [pathList] are ignored.
327+ *
328+ * @param pathList existing list to receive new path entries
329+ * @param newPaths path entries to be evaluated for novelty
330+ * @return {@code true} if entries were appended; otherwise {@code false}
331+ */
332+ private static boolean addNewPaths (List <String > pathList , List <String > newPaths ) {
333+ boolean didChange = false ;
334+ for (String thisPath : newPaths ) {
335+ if (!pathList .contains (thisPath )) {
336+ didChange |= pathList .add (thisPath );
337+ }
338+ }
339+ return didChange ;
340+ }
341+
324342 /**
325343 * Prepend the specified string to the indicated array.
326344 *
0 commit comments