@Test public void testReadPIDFromFile_WithCorruptedPID_ThrowsCorruptedPidException() throws IOException, CorruptedPidException { Files.write(this.regularFile.toPath(), "notnumber".getBytes(), StandardOpenOption.APPEND); this.exception.expect(CorruptedPidException.class); ServerUtil.readPIDFromFile(this.regularFile.getPath()); }
static Integer readPIDFromFile(String filename) throws CorruptedPidException { if (!new File(filename).exists()) { return null; } String PID = null; try (BufferedReader in = new BufferedReader(new FileReader(filename))){ PID = in.readLine(); } catch (IOException e) { log.debug("Fail to read process id from file", e); } return (PID != null) ? filterPidNumber(PID) : null; }
ServerUtil { static Integer readPIDFromFile(String filename) throws CorruptedPidException { if (!new File(filename).exists()) { return null; } String PID = null; try (BufferedReader in = new BufferedReader(new FileReader(filename))){ PID = in.readLine(); } catch (IOException e) { log.debug("Fail to read process id from file", e); } return (PID != null) ? filterPidNumber(PID) : null; } }
ServerUtil { static Integer readPIDFromFile(String filename) throws CorruptedPidException { if (!new File(filename).exists()) { return null; } String PID = null; try (BufferedReader in = new BufferedReader(new FileReader(filename))){ PID = in.readLine(); } catch (IOException e) { log.debug("Fail to read process id from file", e); } return (PID != null) ? filterPidNumber(PID) : null; }  }
ServerUtil { static Integer readPIDFromFile(String filename) throws CorruptedPidException { if (!new File(filename).exists()) { return null; } String PID = null; try (BufferedReader in = new BufferedReader(new FileReader(filename))){ PID = in.readLine(); } catch (IOException e) { log.debug("Fail to read process id from file", e); } return (PID != null) ? filterPidNumber(PID) : null; }  static long getUptime(); static String uptimeToString(); static String uptimeToString(long uptime); static Long getUsableDiscSpaceInGB(); static boolean isEnoughSpace(); static String getCurrentPid(); static boolean isWindows(); static void stopServerProcess(String pidFile); static void terminateProcessByPid(Integer pid); static void writePIDToFile(String filename); static void writePIDToFile(String filename, String pid); static String getPidByProcessName(String processName); static void deletePidFileIfOwned(String filename); static boolean startAgentProcess(); static boolean startAgentProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker,
            boolean isRebootAfterFailure); static int execWithLog(String cmd); static int execWithLog(String[] cmd); static int execWithLog(String cmd, List<String> lines); static int execWithLog(String[] cmd, List<String> lines); static int execWithLog(String[] cmd, boolean logCommandLine); static int execWithLog(String[] cmd, List<String> lines, boolean logCommandLine); static int execWithLines(String cmd, List<String> outLines); static int execWithLines(String[] cmd, List<String> outLines, boolean logCommand); static String getServerIP(); static void setServerIP(String serverIP); static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
            final long sleepInterval); }
ServerUtil { static Integer readPIDFromFile(String filename) throws CorruptedPidException { if (!new File(filename).exists()) { return null; } String PID = null; try (BufferedReader in = new BufferedReader(new FileReader(filename))){ PID = in.readLine(); } catch (IOException e) { log.debug("Fail to read process id from file", e); } return (PID != null) ? filterPidNumber(PID) : null; }  static long getUptime(); static String uptimeToString(); static String uptimeToString(long uptime); static Long getUsableDiscSpaceInGB(); static boolean isEnoughSpace(); static String getCurrentPid(); static boolean isWindows(); static void stopServerProcess(String pidFile); static void terminateProcessByPid(Integer pid); static void writePIDToFile(String filename); static void writePIDToFile(String filename, String pid); static String getPidByProcessName(String processName); static void deletePidFileIfOwned(String filename); static boolean startAgentProcess(); static boolean startAgentProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker); static boolean startServerProcess(int waitTimeout, ServerServiceChecker serverServiceChecker,
            boolean isRebootAfterFailure); static int execWithLog(String cmd); static int execWithLog(String[] cmd); static int execWithLog(String cmd, List<String> lines); static int execWithLog(String[] cmd, List<String> lines); static int execWithLog(String[] cmd, boolean logCommandLine); static int execWithLog(String[] cmd, List<String> lines, boolean logCommandLine); static int execWithLines(String cmd, List<String> outLines); static int execWithLines(String[] cmd, List<String> outLines, boolean logCommand); static String getServerIP(); static void setServerIP(String serverIP); static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
            final long sleepInterval);  }