1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-12 10:23:16 +03:00

Make a defensive copy in InMemoryFileSystem (#8061)

This commit is contained in:
Jesse Wilson
2023-10-17 01:29:12 -04:00
committed by GitHub
parent a64a116392
commit b76e210436
2 changed files with 4 additions and 4 deletions

View File

@@ -35,6 +35,9 @@ class InMemoryFileSystem : FileSystem, TestRule {
private val openSources = IdentityHashMap<Source, File>()
private val openSinks = IdentityHashMap<Sink, File>()
val allPaths: Set<File>
get() = files.keys.toSet()
override fun apply(base: Statement, description: Description): Statement {
return object : Statement() {
override fun evaluate() {
@@ -119,7 +122,4 @@ class InMemoryFileSystem : FileSystem, TestRule {
}
override fun toString() = "InMemoryFileSystem"
fun allPaths(): MutableSet<File> {
return files.keys
}
}

View File

@@ -317,7 +317,7 @@ public final class CacheTest {
Response response1 = client.newCall(request).execute();
assertThat(response1.body().string()).isEqualTo("ABC");
File cacheEntry = fileSystem.allPaths().stream()
File cacheEntry = fileSystem.getAllPaths().stream()
.filter((e) -> e.getName().endsWith(".0"))
.findFirst()
.orElseThrow(Exception::new);