Merge pull request #32298 from izeye

* pr/32298:
  Polish MimeMappings changes

Closes gh-32298
This commit is contained in:
Stephane Nicoll 2022-09-12 18:00:56 +02:00
commit c4e47c6fad
2 changed files with 6 additions and 6 deletions

View File

@ -168,8 +168,8 @@ public sealed class MimeMappings implements Iterable<MimeMappings.Mapping> {
}
/**
* Crate a new lazy copy of the given mappings will only copy entries if the mappings
* are mutated.
* Create a new lazy copy of the given mappings that will only copy entries if the
* mappings are mutated.
* @param mappings the source mappings
* @return a new mappings instance
* @since 3.0.0
@ -349,7 +349,7 @@ public sealed class MimeMappings implements Iterable<MimeMappings.Mapping> {
private final MimeMappings source;
private AtomicBoolean copied = new AtomicBoolean();
private final AtomicBoolean copied = new AtomicBoolean();
LazyMimeMappingsCopy(MimeMappings source) {
this.source = source;

View File

@ -181,7 +181,6 @@ class MimeMappingsTests {
void commonMappingsAreSubsetOfAllMappings() {
MimeMappings defaultMappings = new DefaultMimeMappings();
MimeMappings commonMappings = (MimeMappings) ReflectionTestUtils.getField(DefaultMimeMappings.class, "COMMON");
defaultMappings.getAll();
for (Mapping commonMapping : commonMappings) {
assertThat(defaultMappings.get(commonMapping.getExtension())).isEqualTo(commonMapping.getMimeType());
}
@ -209,10 +208,11 @@ class MimeMappingsTests {
MimeMappings mappings = new MimeMappings();
mappings.add("json", "one/json");
MimeMappings lazyCopy = MimeMappings.lazyCopy(mappings);
lazyCopy.add("first", "copy/yes");
assertThat(lazyCopy.get("json")).isEqualTo("one/json");
mappings.add("json", "two/json");
lazyCopy.add("json", "other/json");
assertThat(lazyCopy.get("json")).isEqualTo("other/json");
lazyCopy.add("second", "copy/no");
assertThat(lazyCopy.get("json")).isEqualTo("one/json");
}
@Test