Skip to content

Commit

Permalink
[hotfix][tests] Remove optional usage
Browse files Browse the repository at this point in the history
  • Loading branch information
openinx authored and zentol committed Nov 15, 2019
1 parent 04aabae commit 4d033ce
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class FlinkDistribution implements ExternalResource {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

private final Optional<Path> logBackupDir;
private final Path logBackupDir;

private final TemporaryFolder temporaryFolder = new TemporaryFolder();

Expand All @@ -86,9 +86,7 @@ public FlinkDistribution() {
Assert.fail("The distDir property was not set. You can set it when running maven via -DdistDir=<path> .");
}
final String backupDirProperty = System.getProperty("logBackupDir");
logBackupDir = backupDirProperty == null
? Optional.empty()
: Optional.of(Paths.get(backupDirProperty));
logBackupDir = backupDirProperty == null ? null : Paths.get(backupDirProperty);
originalFlinkDir = Paths.get(distDirProperty);
}

Expand Down Expand Up @@ -123,16 +121,16 @@ public void afterTestSuccess() {

@Override
public void afterTestFailure() {
logBackupDir.ifPresent(backupLocation -> {
if (logBackupDir != null) {
final UUID id = UUID.randomUUID();
LOG.info("Backing up logs to {}/{}.", backupLocation, id);
LOG.info("Backing up logs to {}/{}.", logBackupDir, id);
try {
Files.createDirectories(backupLocation);
FileUtils.copyDirectory(log.toFile(), backupLocation.resolve(id.toString()).toFile());
Files.createDirectories(logBackupDir);
FileUtils.copyDirectory(log.toFile(), logBackupDir.resolve(id.toString()).toFile());
} catch (IOException e) {
LOG.warn("An error occurred while backing up logs.", e);
}
});
}

afterTestSuccess();
}
Expand Down

0 comments on commit 4d033ce

Please sign in to comment.