Skip to content

Convert applicable methods in Scope to default methods #34757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 <em>conversation ID</em> for the current underlying scope, if any.
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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");
Expand All @@ -368,10 +363,6 @@ public Object remove(String name) {
return beans.remove(name);
}

@Override
public Object resolveContextualObject(String key) {
return null;
}
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -94,10 +94,6 @@ public Object resolveContextualObject(String key) {
return null;
}
}
@Override
public String getConversationId() {
return null;
}
});

ac.getBeanFactory().setConversionService(new DefaultConversionService());
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand Down