This is an automated email from the ASF dual-hosted git repository. pengys pushed a commit to branch 5.x in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/5.x by this push: new 69a765d FileUtils Transaction problem (#1996) 69a765d is described below commit 69a765d32bf1fdf4fb207272d8f79fb2316382f4 Author: caoyixiong <32847163+ian...@users.noreply.github.com> AuthorDate: Wed Dec 5 21:03:57 2018 +0800 FileUtils Transaction problem (#1996) * close inputStream safety * FIX NPE in AlarmService * fix 5.x too many open files bug * checkstyle bug * checkstyle bug * checkstyle bug * fix offset bug * change param name --- .../org/apache/skywalking/apm/collector/core/util/FileUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/FileUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/FileUtils.java index 8803670..97c1e99 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/FileUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/FileUtils.java @@ -43,8 +43,9 @@ public enum FileUtils { long position = length - 1; randomAccessFile.seek(position); while (position >= 0) { - if (randomAccessFile.read() == '\n') { - return randomAccessFile.readLine(); + String lineString = ""; + if (randomAccessFile.read() == '\n' && StringUtils.isNotEmpty(lineString = randomAccessFile.readLine())) { + return lineString; } randomAccessFile.seek(position); if (position == 0) { @@ -73,8 +74,7 @@ public enum FileUtils { randomAccessFile = new RandomAccessFile(file, "rwd"); long length = randomAccessFile.length(); randomAccessFile.seek(length); - randomAccessFile.writeBytes(System.lineSeparator()); - randomAccessFile.writeBytes(value); + randomAccessFile.writeBytes(System.lineSeparator() + value); } catch (IOException e) { logger.error(e.getMessage(), e); } finally {