Polish and reinstate usage of FileSystemUtils.deleteRecursively
Closes gh-9942
This commit is contained in:
parent
c4aba91c47
commit
c3bc32db02
|
|
@ -42,12 +42,10 @@ public class JarFileRemoteApplicationLauncher extends RemoteApplicationLauncher
|
|||
@Override
|
||||
protected String createApplicationClassPath() throws Exception {
|
||||
File appDirectory = new File("target/app");
|
||||
if (appDirectory.isDirectory()) {
|
||||
FileSystemUtils.deleteRecursively(appDirectory.toPath());
|
||||
if (appDirectory.isDirectory()) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to delete '" + appDirectory.getAbsolutePath() + "'");
|
||||
}
|
||||
if (appDirectory.isDirectory()
|
||||
&& !FileSystemUtils.deleteRecursively(appDirectory.toPath())) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to delete '" + appDirectory.getAbsolutePath() + "'");
|
||||
}
|
||||
appDirectory.mkdirs();
|
||||
Manifest manifest = new Manifest();
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@ package sample.integration.consumer;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.FileVisitOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
|
@ -39,6 +35,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -54,16 +51,14 @@ public class SampleIntegrationApplicationTests {
|
|||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void deleteInputAndOutput() throws InterruptedException, IOException {
|
||||
public void deleteInputAndOutput() throws InterruptedException {
|
||||
deleteIfExists(new File("target/input"));
|
||||
deleteIfExists(new File("target/output"));
|
||||
}
|
||||
|
||||
private void deleteIfExists(File directory) throws InterruptedException, IOException {
|
||||
private void deleteIfExists(File directory) throws InterruptedException {
|
||||
if (directory.exists()) {
|
||||
Files.walk(directory.toPath(), FileVisitOption.FOLLOW_LINKS)
|
||||
.sorted(Comparator.reverseOrder()).map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
assertThat(FileSystemUtils.deleteRecursively(directory)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue