Skip to content

Commit

Permalink
Make a defensive copy in InMemoryFileSystem (#8061)
Browse files Browse the repository at this point in the history
  • Loading branch information
swankjesse committed Oct 17, 2023
1 parent a64a116 commit b76e210
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -119,7 +122,4 @@ class InMemoryFileSystem : FileSystem, TestRule {
}

override fun toString() = "InMemoryFileSystem"
fun allPaths(): MutableSet<File> {
return files.keys
}
}
2 changes: 1 addition & 1 deletion okhttp/src/test/java/okhttp3/CacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void testResponseCaching(TransferKind transferKind) throws IOException {
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);
Expand Down

0 comments on commit b76e210

Please sign in to comment.