Minor formatting fixes
[aai/babel.git] / src / test / java / org / onap / aai / babel / logging / LogReader.java
index 0c4de64..f18fb6d 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * ============LICENSE_START=======================================================
+ * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
@@ -18,6 +18,7 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.babel.logging;
 
 import java.io.BufferedReader;
@@ -27,6 +28,7 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -57,9 +59,15 @@ public class LogReader {
     }
 
     /**
+     * Find the most recently modified log file with a name starting with the specified prefix.
+     *
      * @param logDirectory
-     * @return the most recently created log file.
+     *            the root folder storing log files
+     * @param filenamePrefix
+     *            the log file name prefix
+     * @return the most recently created log file
      * @throws IOException
+     *             if an I/O error occurs
      */
     public File getLogFile(String logDirectory, String filenamePrefix) throws IOException {
         Path cachedLog = cachedLogMap.get(filenamePrefix);
@@ -67,7 +75,7 @@ public class LogReader {
         if (cachedLog == null) {
             Optional<Path> latestFilePath = Files.list(Paths.get(logDirectory))
                     .filter(f -> Files.isDirectory(f) == false && f.getFileName().toString().startsWith(filenamePrefix))
-                    .max((f1, f2) -> (int) (f1.toFile().lastModified() - f2.toFile().lastModified()));
+                    .max(Comparator.comparingLong(f -> f.toFile().lastModified()));
             if (latestFilePath.isPresent()) {
                 cachedLog = latestFilePath.get();
             } else {
@@ -78,8 +86,11 @@ public class LogReader {
     }
 
     /**
+     * Wait for and read new log entries.
+     *
      * @return new lines appended to the log file
      * @throws IOException
+     *             If an I/O error occurs
      */
     public String getNewLines() throws IOException {
         StopWatch stopwatch = new StopWatch();