diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java index cb4cb0de1d7b..96dddd0125aa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,9 @@ public interface Scope { * @return the corresponding object, or {@code null} if none found * @throws IllegalStateException if the underlying scope is not currently active */ - @Nullable Object resolveContextualObject(String key); + default @Nullable Object resolveContextualObject(String key) { + return null; + } /** * Return the conversation ID for the current underlying scope, if any. @@ -147,6 +149,8 @@ public interface Scope { * conversation ID for the current scope * @throws IllegalStateException if the underlying scope is not currently active */ - @Nullable String getConversationId(); + default @Nullable String getConversationId() { + return null; + } } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java index 164718deb727..b9967ee5eaa9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,14 +44,4 @@ public Object remove(String name) { public void registerDestructionCallback(String name, Runnable callback) { } - @Override - public Object resolveContextualObject(String key) { - return null; - } - - @Override - public String getConversationId() { - return null; - } - } diff --git a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java index 67bad8cae59b..f065e32a8246 100644 --- a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java +++ b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,11 +83,6 @@ public void registerDestructionCallback(String name, Runnable callback) { "Consider using RequestScope in a web environment."); } - @Override - public @Nullable Object resolveContextualObject(String key) { - return null; - } - @Override public String getConversationId() { return Thread.currentThread().getName(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index 7c82bcc0e233..2e255b84eaff 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -353,11 +353,6 @@ public Object get(String name, ObjectFactory objectFactory) { return beans.get(name); } - @Override - public String getConversationId() { - return null; - } - @Override public void registerDestructionCallback(String name, Runnable callback) { throw new IllegalStateException("Not supposed to be called"); @@ -368,10 +363,6 @@ public Object remove(String name) { return beans.remove(name); } - @Override - public Object resolveContextualObject(String key) { - return null; - } } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java index 1907f3ccec1b..73ee254760a6 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,16 +83,6 @@ public Object remove(String name) { @Override public void registerDestructionCallback(String name, Runnable callback) { } - - @Override - public Object resolveContextualObject(String key) { - return null; - } - - @Override - public String getConversationId() { - return null; - } } diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index 5578213184e8..6c435961d55f 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1090,16 +1090,6 @@ public Object remove(String name) { @Override public void registerDestructionCallback(String name, Runnable callback) { } - - @Override - public Object resolveContextualObject(String key) { - return null; - } - - @Override - public String getConversationId() { - return null; - } } 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 4e18f567b6c1..191885d34260 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,10 +94,6 @@ public Object resolveContextualObject(String key) { return null; } } - @Override - public String getConversationId() { - return null; - } }); ac.getBeanFactory().setConversionService(new DefaultConversionService()); diff --git a/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java b/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java index d1b3fb380fbc..a690571d23a6 100644 --- a/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1214,21 +1214,11 @@ public Object remove(String name) { public void registerDestructionCallback(String name, Runnable callback) { } - @Override - public String getConversationId() { - return null; - } - @Override public Object get(String name, ObjectFactory objectFactory) { instanceCount++; return objectFactory.getObject(); } - - @Override - public Object resolveContextualObject(String s) { - return null; - } } class BirthdayCardSender { diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java index 6a41c4fec173..f85d83997fb0 100644 --- a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/SimpleMapScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,20 +68,10 @@ public void registerDestructionCallback(String name, Runnable callback) { this.callbacks.add(callback); } - @Override - public Object resolveContextualObject(String key) { - return null; - } - public void close() { for (Runnable runnable : this.callbacks) { runnable.run(); } } - @Override - public String getConversationId() { - return null; - } - } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java index 657072529b08..7d9121283c83 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpSessionScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,11 +70,6 @@ public void registerDestructionCallback(String name, Runnable callback) { SimpAttributesContextHolder.currentAttributes().registerDestructionCallback(name, callback); } - @Override - public @Nullable Object resolveContextualObject(String key) { - return null; - } - @Override public String getConversationId() { return SimpAttributesContextHolder.currentAttributes().getSessionId(); diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java b/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java index dacebd9119ea..5aaa4ff25506 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,11 +81,6 @@ public void registerDestructionCallback(String name, Runnable callback) { } } - @Override - public @Nullable Object resolveContextualObject(String key) { - return null; - } - @Override public @Nullable String getConversationId() { return TransactionSynchronizationManager.getCurrentTransactionName(); diff --git a/spring-web/src/main/java/org/springframework/web/context/request/RequestScope.java b/spring-web/src/main/java/org/springframework/web/context/request/RequestScope.java index 74423d9cc1bd..52754f0c21e9 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/RequestScope.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/RequestScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.springframework.web.context.request; -import org.jspecify.annotations.Nullable; - /** * Request-backed {@link org.springframework.beans.factory.config.Scope} * implementation. @@ -44,13 +42,4 @@ protected int getScope() { return RequestAttributes.SCOPE_REQUEST; } - /** - * There is no conversation id concept for a request, so this method - * returns {@code null}. - */ - @Override - public @Nullable String getConversationId() { - return null; - } - } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java index b6aa02fafa6a..98de63bd4465 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,17 +96,6 @@ public void registerDestructionCallback(String name, Runnable callback) { } } - @Override - public @Nullable Object resolveContextualObject(String key) { - return null; - } - - @Override - public @Nullable String getConversationId() { - return null; - } - - /** * Invoke all registered destruction callbacks. * To be called on ServletContext shutdown.