Browse Source

REPORT-153340 代码中部分资源流未关闭,使用 try-with-resources 自动关闭流

release/11.0
shengzu.xue 2 weeks ago
parent
commit
b186297457
  1. 11
      designer-base/src/main/java/com/fr/design/RestartHelper.java

11
designer-base/src/main/java/com/fr/design/RestartHelper.java

@ -110,8 +110,8 @@ public class RestartHelper {
private static boolean deleteWhenDebug() { private static boolean deleteWhenDebug() {
File ff = new File(RECORD_FILE); File ff = new File(RECORD_FILE);
Properties properties = new Properties(); Properties properties = new Properties();
try { try (FileInputStream fis = new FileInputStream(ff)) {
properties.load(new FileInputStream(ff)); properties.load(fis);
} catch (IOException ignore) { } catch (IOException ignore) {
return true; return true;
} }
@ -163,7 +163,6 @@ public class RestartHelper {
} }
/** /**
* 重启设计器并删除某些特定的文件 * 重启设计器并删除某些特定的文件
* *
@ -180,13 +179,13 @@ public class RestartHelper {
try { try {
File restartLockFile = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), "restart.lock")); File restartLockFile = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), "restart.lock"));
StableUtils.makesureFileExist(restartLockFile); StableUtils.makesureFileExist(restartLockFile);
randomAccessFile = new RandomAccessFile(restartLockFile,"rw"); randomAccessFile = new RandomAccessFile(restartLockFile, "rw");
FileChannel restartLockFC = randomAccessFile.getChannel(); FileChannel restartLockFC = randomAccessFile.getChannel();
FileLock restartLock = restartLockFC.tryLock(); FileLock restartLock = restartLockFC.tryLock();
if(restartLock == null) { if (restartLock == null) {
FineLoggerFactory.getLogger().error("restart lock null!"); FineLoggerFactory.getLogger().error("restart lock null!");
} }
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
restartAction.execute(filesToBeDelete); restartAction.execute(filesToBeDelete);

Loading…
Cancel
Save