Code Review
/
aai
/
babel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Minor formatting fixes
[aai/babel.git]
/
src
/
test
/
java
/
org
/
onap
/
aai
/
babel
/
logging
/
LogReader.java
diff --git
a/src/test/java/org/onap/aai/babel/logging/LogReader.java
b/src/test/java/org/onap/aai/babel/logging/LogReader.java
index
c2a8e64
..
f18fb6d
100644
(file)
--- a/
src/test/java/org/onap/aai/babel/logging/LogReader.java
+++ b/
src/test/java/org/onap/aai/babel/logging/LogReader.java
@@
-18,6
+18,7
@@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.babel.logging;
import java.io.BufferedReader;
package org.onap.aai.babel.logging;
import java.io.BufferedReader;
@@
-27,11
+28,12
@@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
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;
import java.util.concurrent.TimeUnit;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang.time.StopWatch;
+import org.apache.commons.lang
3
.time.StopWatch;
import org.junit.Assert;
public class LogReader {
import org.junit.Assert;
public class LogReader {
@@
-57,9
+59,15
@@
public class LogReader {
}
/**
}
/**
+ * Find the most recently modified log file with a name starting with the specified prefix.
+ *
* @param logDirectory
* @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
* @throws IOException
+ * if an I/O error occurs
*/
public File getLogFile(String logDirectory, String filenamePrefix) throws IOException {
Path cachedLog = cachedLogMap.get(filenamePrefix);
*/
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))
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 {
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
* @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();
*/
public String getNewLines() throws IOException {
StopWatch stopwatch = new StopWatch();