Github user kirklund commented on a diff in the pull request: https://github.com/apache/geode/pull/699#discussion_r132599897 --- Diff: geode-core/src/main/java/org/apache/geode/internal/process/LocalProcessLauncher.java --- @@ -96,33 +117,55 @@ void close() { * @throws IOException if unable to create or write to the file */ private void writePid(final boolean force) throws FileAlreadyExistsException, IOException { - final boolean created = this.pidFile.createNewFile(); - if (!created && !force) { - int otherPid = 0; - try { - otherPid = ProcessUtils.readPid(this.pidFile); - } catch (IOException e) { - // suppress - } catch (NumberFormatException e) { - // suppress - } - boolean ignorePidFile = false; - if (otherPid != 0 && !ignoreIsPidAlive()) { - ignorePidFile = !ProcessUtils.isProcessAlive(otherPid); - } - if (!ignorePidFile) { - throw new FileAlreadyExistsException("Pid file already exists: " + this.pidFile + " for " - + (otherPid > 0 ? "process " + otherPid : "unknown process")); + if (this.pidFile.exists()) { + if (!force) { + checkOtherPid(readOtherPid()); } + this.pidFile.delete(); + } + + assert !this.pidFile.exists(); --- End diff -- Did you like the use of Validate? I'm not sure how I feel about Validate after using it heavily in this package. Jianxia added the asserts when he fixed a bug in this method and I just left them in place. I think we could easily change them to Validate calls or remove them altogether.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---