From ac77fc9dcf6f7cd2cb3cf4f304a3340b8c494165 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 27 Nov 2018 11:24:25 +0000 Subject: [PATCH] Ignore .writing files in Integration samples tests Previously, a temporary .writing file could be found and an attempt made to access its contents. If the temporary file was deleted between it being found and its contents being read, the test would fail with a FileNotFoundException. This commit updates the test to ignore .writing files so that it will only examine the contents of the final file once Integration has finished writing it an atomically moved it to its final location. --- .../consumer/SampleIntegrationApplicationTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java b/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java index 904e3d29180..cf4441730c9 100644 --- a/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java @@ -113,7 +113,9 @@ public class SampleIntegrationApplicationTests { .getResourcePatternResolver(new DefaultResourceLoader()) .getResources("file:target/output/**"); for (Resource candidate : candidates) { - if (candidate.contentLength() == 0) { + if ((candidate.getFilename() != null + && candidate.getFilename().endsWith(".writing")) + || candidate.contentLength() == 0) { return new Resource[0]; } }