Replace System.getProperties().remove(x) with System.clearProperty(x)

This commit migrates to the not-so-new System.clearProperty() method
introduced in Java 1.5.
This commit is contained in:
Sam Brannen
2023-12-06 17:11:46 +01:00
parent f14b122c9c
commit 438c3818cc
7 changed files with 19 additions and 19 deletions

View File

@@ -57,8 +57,8 @@ public class ApplicationContextExpressionBenchmark {
@TearDown
public void teardown() {
System.getProperties().remove("country");
System.getProperties().remove("name");
System.clearProperty("country");
System.clearProperty("name");
}
}

View File

@@ -43,7 +43,7 @@ class ContextNamespaceHandlerTests {
@AfterEach
void tearDown() {
System.getProperties().remove("foo");
System.clearProperty("foo");
}

View File

@@ -196,7 +196,7 @@ class ApplicationContextExpressionTests {
assertThat(tb6.tb).isSameAs(tb0);
}
finally {
System.getProperties().remove("country");
System.clearProperty("country");
}
}
@@ -230,8 +230,8 @@ class ApplicationContextExpressionTests {
assertThat(tb.getCountry2()).isEqualTo("-UK2-");
}
finally {
System.getProperties().remove("name");
System.getProperties().remove("country");
System.clearProperty("name");
System.clearProperty("country");
}
}
@@ -264,7 +264,7 @@ class ApplicationContextExpressionTests {
assertThat(FileCopyUtils.copyToString(resourceInjectionBean.reader)).isEqualTo(FileCopyUtils.copyToString(new EncodedResource(resource).getReader()));
}
finally {
System.getProperties().remove("logfile");
System.clearProperty("logfile");
}
}

View File

@@ -73,7 +73,7 @@ class ResourceEditorTests {
assertThat(resolved.getFilename()).isEqualTo("foo");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -87,7 +87,7 @@ class ResourceEditorTests {
assertThat(resolved.getFilename()).isEqualTo("foo-${bar}");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -102,7 +102,7 @@ class ResourceEditorTests {
});
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}

View File

@@ -70,7 +70,7 @@ class ResourceArrayPropertyEditorTests {
assertThat(resources[0].getFilename()).isEqualTo("foo");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -85,7 +85,7 @@ class ResourceArrayPropertyEditorTests {
editor.setAsText("${test.prop}-${bar}"));
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}

View File

@@ -37,7 +37,7 @@ class SystemPropertyUtilsTests {
assertThat(resolved).isEqualTo("bar");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -49,7 +49,7 @@ class SystemPropertyUtilsTests {
assertThat(resolved).isEqualTo("bar");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -61,7 +61,7 @@ class SystemPropertyUtilsTests {
assertThat(resolved).isEqualTo("bar");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -73,7 +73,7 @@ class SystemPropertyUtilsTests {
assertThat(resolved).isEqualTo("bar");
}
finally {
System.getProperties().remove("test.prop");
System.clearProperty("test.prop");
}
}
@@ -122,8 +122,8 @@ class SystemPropertyUtilsTests {
assertThat(resolved).isEqualTo("foo=baz");
}
finally {
System.getProperties().remove("test.prop");
System.getProperties().remove("bar");
System.clearProperty("test.prop");
System.clearProperty("bar");
}
}

View File

@@ -264,7 +264,7 @@ public abstract class WebUtils {
Assert.notNull(servletContext, "ServletContext must not be null");
String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
System.getProperties().remove(key);
System.clearProperty(key);
}
/**