geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kirk Lund (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GEODE-3278) Empty status file causes status server and status locator to hang
Date Thu, 20 Jul 2017 21:34:00 GMT
Kirk Lund created GEODE-3278:
--------------------------------

             Summary: Empty status file causes status server and status locator to hang
                 Key: GEODE-3278
                 URL: https://issues.apache.org/jira/browse/GEODE-3278
             Project: Geode
          Issue Type: Bug
          Components: gfsh
            Reporter: Kirk Lund


I added the following test to FileProcessControllerIntegrationTest to improve code coverage
and hit this hang.
{noformat}
  @Test
  public void emptyStatusFileCausesStatusToHang() throws Exception {
    // given: FileProcessController with pidFile containing real pid
    new IntegerFileWriter(pidFile).writeToFile(pid);
    FileProcessController controller = new FileProcessController(params, pid, 2, MINUTES);

    // when: status is called in one thread
    executor.execute(() -> {
      try {
        statusRef.set(controller.status());
      } catch (Exception e) {
        errorCollector.addError(e);
      }
    });

    // and: json is written to the status file
    new EmptyFileWriter(statusFile).createNewFile();

    // then: returned status should be the json in the file
    await().until(() -> assertThat(statusRef.get()).isEqualTo(STATUS_JSON));
  }
{noformat}
FileProcessController wait forever to read from that status file:
{noformat}
    ControlRequestHandler statusHandler = () -> {
      // read the statusFile
      StringBuilder lines = new StringBuilder();
      try (BufferedReader reader = new BufferedReader(new FileReader(statusFile))) {
        String line;
        while ((line = reader.readLine()) != null) {
          lines.append(line);
        }
      } finally {
        statusRef.set(lines.toString());
      }
    };
{noformat}
The above is blocking file reader which cannot be interrupted on Windows. If we change the
code to be interrupted then we'll need to change to a non-blocking implementation so it can
be interrupted on Windows.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message