@Test public void noPidFileReturnsEarly() throws Exception { final boolean result = this.pidFileMixin.call(); assertThat(result).isTrue(); }
@Override public Boolean call() throws Exception { if (pidFilePath == null) { return true; } if (Files.exists(pidFilePath)) { LOGGER.info("File already exists {}", pidFilePath); } else { LOGGER.info("Created pid file {}", pidFilePath); } final String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0]; try (OutputStream stream = Files.newOutputStream(pidFilePath, CREATE, TRUNCATE_EXISTING)) { stream.write(pid.getBytes(UTF_8)); } return true; }
PidFileMixin implements Callable<Boolean> { @Override public Boolean call() throws Exception { if (pidFilePath == null) { return true; } if (Files.exists(pidFilePath)) { LOGGER.info("File already exists {}", pidFilePath); } else { LOGGER.info("Created pid file {}", pidFilePath); } final String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0]; try (OutputStream stream = Files.newOutputStream(pidFilePath, CREATE, TRUNCATE_EXISTING)) { stream.write(pid.getBytes(UTF_8)); } return true; } }
PidFileMixin implements Callable<Boolean> { @Override public Boolean call() throws Exception { if (pidFilePath == null) { return true; } if (Files.exists(pidFilePath)) { LOGGER.info("File already exists {}", pidFilePath); } else { LOGGER.info("Created pid file {}", pidFilePath); } final String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0]; try (OutputStream stream = Files.newOutputStream(pidFilePath, CREATE, TRUNCATE_EXISTING)) { stream.write(pid.getBytes(UTF_8)); } return true; }  }
PidFileMixin implements Callable<Boolean> { @Override public Boolean call() throws Exception { if (pidFilePath == null) { return true; } if (Files.exists(pidFilePath)) { LOGGER.info("File already exists {}", pidFilePath); } else { LOGGER.info("Created pid file {}", pidFilePath); } final String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0]; try (OutputStream stream = Files.newOutputStream(pidFilePath, CREATE, TRUNCATE_EXISTING)) { stream.write(pid.getBytes(UTF_8)); } return true; }  @Override Boolean call(); void setPidFilePath(final Path pidFilePath); }
PidFileMixin implements Callable<Boolean> { @Override public Boolean call() throws Exception { if (pidFilePath == null) { return true; } if (Files.exists(pidFilePath)) { LOGGER.info("File already exists {}", pidFilePath); } else { LOGGER.info("Created pid file {}", pidFilePath); } final String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0]; try (OutputStream stream = Files.newOutputStream(pidFilePath, CREATE, TRUNCATE_EXISTING)) { stream.write(pid.getBytes(UTF_8)); } return true; }  @Override Boolean call(); void setPidFilePath(final Path pidFilePath);  }