From d52e22e38a861bd64d3ec637de308c8f516465d1 Mon Sep 17 00:00:00 2001 From: zhourui Date: Wed, 14 Dec 2022 17:53:12 +0800 Subject: [PATCH] fix --- .../x/server/console/swapcommand/Exit.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/o2server/x_console/src/main/java/com/x/server/console/swapcommand/Exit.java b/o2server/x_console/src/main/java/com/x/server/console/swapcommand/Exit.java index 460d7cb906..f9119a577f 100644 --- a/o2server/x_console/src/main/java/com/x/server/console/swapcommand/Exit.java +++ b/o2server/x_console/src/main/java/com/x/server/console/swapcommand/Exit.java @@ -9,31 +9,31 @@ import java.nio.channels.FileLock; public class Exit { - public static void main(String... args) throws Exception { - try (RandomAccessFile raf = new RandomAccessFile(getBasePath() + "/command.swap", "rw")) { - FileChannel fc = raf.getChannel(); - MappedByteBuffer mbb = fc.map(MapMode.READ_WRITE, 0, 256); - FileLock flock = null; - flock = fc.lock(); - mbb.put("exit".getBytes()); - flock.release(); - } - } + public static void main(String... args) throws Exception { + try (RandomAccessFile raf = new RandomAccessFile(getBasePath() + "/command.swap", "rw")) { + FileChannel fc = raf.getChannel(); + MappedByteBuffer mbb = fc.map(MapMode.READ_WRITE, 0, 256); + FileLock flock = null; + flock = fc.lock(); + mbb.put("exit".getBytes()); + flock.release(); + } + } - private static String getBasePath() throws Exception { - String path = Exit.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - File file = new File(path); - if (!file.isDirectory()) { - file = file.getParentFile(); - } - while (null != file) { - File versionFile = new File(file, "version.o2"); - if (versionFile.exists()) { - return file.getAbsolutePath(); - } - file = file.getParentFile(); - } - throw new Exception("can not define o2server base directory."); - } + private static String getBasePath() { + String path = Exit.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + File file = new File(path); + if (!file.isDirectory()) { + file = file.getParentFile(); + } + while (null != file) { + File versionFile = new File(file, "version.o2"); + if (versionFile.exists()) { + return file.getAbsolutePath(); + } + file = file.getParentFile(); + } + throw new IllegalStateException("can not define o2server base directory."); + } } -- GitLab