Skip to content

Commit bcae2d9

Browse files
committed
Update FileUtilsTest.java
1 parent 1d0c619 commit bcae2d9

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

microsphere-java-core/src/test/java/io/microsphere/io/FileUtilsTest.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,29 +244,30 @@ public void testForceDeleteOnIOException() throws Exception {
244244
AtomicInteger status = new AtomicInteger(0);
245245

246246
executor.submit(() -> {
247+
while (status.get() != 2) {
248+
}
247249
synchronized (testFile) {
248-
try (FileOutputStream outputStream = new FileOutputStream(testFile, true)) {
249-
outputStream.write('a');
250-
status.set(1);
251-
executor.submit(() -> {
252-
while (status.get() != 1) {
253-
}
254-
assertThrows(IOException.class, () -> forceDelete(testFile));
255-
status.set(2);
256-
return null;
257-
});
258-
// wait for notification
259-
testFile.wait();
260-
}
250+
testFile.notifyAll();
261251
}
262252
return null;
263253
});
264254

265255
executor.submit(() -> {
266-
while (status.get() != 2) {
256+
while (status.get() != 1) {
267257
}
258+
assertThrows(IOException.class, () -> forceDelete(testFile));
259+
status.set(2);
260+
return null;
261+
});
262+
263+
executor.submit(() -> {
268264
synchronized (testFile) {
269-
testFile.notifyAll();
265+
try (FileOutputStream outputStream = new FileOutputStream(testFile, true)) {
266+
outputStream.write('a');
267+
status.set(1);
268+
// wait for notification
269+
testFile.wait();
270+
}
270271
}
271272
return null;
272273
});

0 commit comments

Comments
 (0)