Skip to content

Commit 4d827a2

Browse files
authored
[7.67.x-blue] flaky test fixed (#1448)
1 parent f6aa140 commit 4d827a2

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/test/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingServiceTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void setUp() {
5252
public void testPingSuccess() {
5353
{
5454
InfinispanPingService service = spy(new InfinispanPingService(remoteCache));
55+
when(pingResponse.isSuccess()).thenReturn(true);
5556
assertTrue(service.ping());
5657
service.stop();
5758
}

uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-fs/src/main/java/org/uberfire/java/nio/fs/file/SimpleFileSystemProvider.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.concurrent.ExecutorService;
3434

3535
import org.apache.commons.io.FileUtils;
36+
import org.slf4j.Logger;
37+
import org.slf4j.LoggerFactory;
3638
import org.uberfire.java.nio.IOException;
3739
import org.uberfire.java.nio.base.BasicFileAttributesImpl;
3840
import org.uberfire.java.nio.base.ExtendedAttributeView;
@@ -73,8 +75,10 @@
7375

7476
public class SimpleFileSystemProvider implements FileSystemProvider {
7577

78+
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleFileSystemProvider.class);
7679
private static final String STREAM_CLOSED = "This stream is closed.";
7780
private static final String USER_DIR = "user.dir";
81+
7882
protected BaseSimpleFileSystem fileSystem;
7983
private final OSType osType;
8084
private final File[] roots;
@@ -419,7 +423,7 @@ public void delete(final Path path,
419423
@Override
420424
public boolean deleteIfExists(final Path path,
421425
final DeleteOption... options)
422-
throws DirectoryNotEmptyException, IOException, SecurityException {
426+
throws IOException, SecurityException {
423427
checkNotNull("path",
424428
path);
425429
synchronized (this) {
@@ -430,16 +434,18 @@ public boolean deleteIfExists(final Path path,
430434
throw new DirectoryNotEmptyException(path.toString());
431435
}
432436

433-
final boolean result = file.exists();
437+
boolean fileRemoved = file.exists();
434438

435-
try {
436-
FileUtils.forceDelete(file);
437-
} catch (final FileNotFoundException ignore) {
438-
} catch (java.io.IOException e) {
439-
throw new IOException(e);
439+
if (file.exists()) {
440+
try {
441+
FileUtils.forceDelete(file);
442+
} catch (java.io.IOException e) {
443+
fileRemoved = false;
444+
LOGGER.error("Error trying to delete file {}", file.getAbsolutePath(), e);
445+
}
440446
}
441447

442-
return result;
448+
return fileRemoved;
443449
} finally {
444450
toGeneralPathImpl(path).clearCache();
445451
}

uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-fs/src/test/java/org/uberfire/java/nio/fs/file/SimpleFileSystemProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ public void checkDeleteIfExists() throws IOException {
594594
assertThat(path.toFile()).doesNotExist();
595595
}
596596

597-
@Test(expected = org.uberfire.java.nio.IOException.class)
597+
@Test
598598
public void checkDeleteIfExistsNonExistent() {
599599
final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
600600

0 commit comments

Comments
 (0)