diff --git a/spring-context/src/jmh/java/org/springframework/context/expression/ApplicationContextExpressionBenchmark.java b/spring-context/src/jmh/java/org/springframework/context/expression/ApplicationContextExpressionBenchmark.java index 51a568ca30..8e3d9c1922 100644 --- a/spring-context/src/jmh/java/org/springframework/context/expression/ApplicationContextExpressionBenchmark.java +++ b/spring-context/src/jmh/java/org/springframework/context/expression/ApplicationContextExpressionBenchmark.java @@ -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"); } } diff --git a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java index 661c4d3eb2..f6bf1a69f6 100644 --- a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java @@ -43,7 +43,7 @@ class ContextNamespaceHandlerTests { @AfterEach void tearDown() { - System.getProperties().remove("foo"); + System.clearProperty("foo"); } diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index e9f573c9a1..30e7e972ec 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -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"); } } diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java index d93c4bfba2..2a798cde45 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java @@ -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"); } } diff --git a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java index b17f1a4637..eabd4e46bf 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java @@ -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"); } } diff --git a/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java index 30e70d2f7e..6761a94d66 100644 --- a/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java @@ -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"); } } diff --git a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java index 34c79614d5..e86a31ce29 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java @@ -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); } /**