@@ -250,7 +250,7 @@ public void testProcessFileChanges() throws Exception {
250250 fileSettingsService .start ();
251251 fileSettingsService .clusterChanged (new ClusterChangedEvent ("test" , clusterService .state (), ClusterState .EMPTY_STATE ));
252252 // second file change; contents still don't matter
253- writeTestFile (fileSettingsService .watchedFile (), "{}" );
253+ overwriteTestFile (fileSettingsService .watchedFile (), "{}" );
254254
255255 // wait for listener to be called (once for initial processing, once for subsequent update)
256256 assertTrue (latch .await (20 , TimeUnit .SECONDS ));
@@ -355,6 +355,12 @@ public void testHandleSnapshotRestoreResetsMetadata() throws Exception {
355355 private void writeTestFile (Path path , String contents ) throws IOException {
356356 Path tempFilePath = createTempFile ();
357357 Files .writeString (tempFilePath , contents );
358- Files .move (tempFilePath , path , StandardCopyOption .ATOMIC_MOVE );
358+ Files .move (tempFilePath , path , StandardCopyOption .ATOMIC_MOVE , StandardCopyOption .REPLACE_EXISTING );
359+ }
360+
361+ private void overwriteTestFile (Path path , String contents ) throws IOException {
362+ Path tempFilePath = createTempFile ();
363+ Files .writeString (tempFilePath , contents );
364+ Files .move (tempFilePath , path , StandardCopyOption .REPLACE_EXISTING );
359365 }
360366}
0 commit comments