diff --git a/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc b/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc index 71cb2799757..5b891654715 100644 --- a/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop-api/targetsource.adoc @@ -221,7 +221,7 @@ NOTE: `ThreadLocal` instances come with serious issues (potentially resulting in incorrectly using them in multi-threaded and multi-classloader environments. You should always consider wrapping a `ThreadLocal` in some other class and never directly use the `ThreadLocal` itself (except in the wrapper class). Also, you should -always remember to correctly set and unset (where the latter simply involves a call to +always remember to correctly set and unset (where the latter involves a call to `ThreadLocal.remove()`) the resource local to the thread. Unsetting should be done in any case, since not unsetting it might result in problematic behavior. Spring's `ThreadLocal` support does this for you and should always be considered in favor of using diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSourceTests.java index e639f287d1c..0aa39c18c5b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSourceTests.java @@ -135,7 +135,7 @@ class AbstractRoutingDataSourceTests { routingDataSource.setDefaultTargetDataSource(ds); routingDataSource.setLenientFallback(false); routingDataSource.afterPropertiesSet(); - lookupKey.set(null); + lookupKey.remove(); assertThat(routingDataSource.determineTargetDataSource()).isSameAs(ds); }