[
https://issues.apache.org/jira/browse/GEODE-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122463#comment-16122463
]
ASF GitHub Bot commented on GEODE-3413:
---------------------------------------
Github user jaredjstewart commented on a diff in the pull request:
https://github.com/apache/geode/pull/699#discussion_r132585334
--- 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 --
I saw that you used Apache common's `Validate` class in other places.
Would that be good to use here since the default java `assert` won't do
anything under normal circumstances?
> Overhaul launcher tests and process tests
> -----------------------------------------
>
> Key: GEODE-3413
> URL: https://issues.apache.org/jira/browse/GEODE-3413
> Project: Geode
> Issue Type: Improvement
> Components: gfsh
> Reporter: Kirk Lund
> Assignee: Kirk Lund
> Labels: LauncherTest, ProcessTest
>
> The launcher and process tests are closely related and in need of overhauling
> to improve debugging and remove flakiness.
> In addition, the org.apache.geode.internal.process package is need of
> improving the test code coverage.
> Launcher tests:
> *
> geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherServiceStatusTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LauncherMemberMXBeanIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
> * geode-core/src/test/java/org/apache/geode/distributed/LocatorStateTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherLocalFileIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
> *
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherWithProviderIntegrationTest.java
> Process tests:
> *
> geode-core/src/test/java/org/apache/geode/internal/process/BlockingProcessStreamReaderJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/FileProcessControllerIntegrationJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessControllerJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessLauncherDUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessLauncherJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/PidFileJUnitTest.java
> *
> geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryJUnitTest.java
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)