Browse Source

[Fix-4271][server] Fix IOException or NoSuchFileException in logger server (#4272)

pull/3/MERGE
Shiwen Cheng 4 years ago committed by GitHub
parent
commit
c4d75443e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java

13
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java

@ -169,10 +169,15 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
private List<String> readPartFileContent(String filePath,
int skipLine,
int limit) {
try (Stream<String> stream = Files.lines(Paths.get(filePath))) {
return stream.skip(skipLine).limit(limit).collect(Collectors.toList());
} catch (IOException e) {
logger.error("read file error",e);
File file = new File(filePath);
if (file.exists() && file.isFile()) {
try (Stream<String> stream = Files.lines(Paths.get(filePath))) {
return stream.skip(skipLine).limit(limit).collect(Collectors.toList());
} catch (IOException e) {
logger.error("read file error",e);
}
} else {
logger.info("file path: {} not exists", filePath);
}
return Collections.emptyList();
}

Loading…
Cancel
Save