提交 69a765d3 编写于 作者: C caoyixiong 提交者: 彭勇升 pengys

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
上级 93aeb497
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册