Skip to content
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

NoSuchMethodError can be thrown from Session.getCookie() due to binary incompatibilty #38589

Closed
candrews opened this issue Nov 28, 2023 · 6 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@candrews
Copy link
Contributor

candrews commented Nov 28, 2023

Spring Boot 3.2.0 breaks binary compatibility with previous versions of Spring Boot (ex, 3.1.6).

Given a class that invokes org.springframework.boot.web.servlet.server.Session.getCookie(), if that class is compiled against Spring Boot 3.1.6 then run with Spring Boot 3.2.0, an exception occurs.

Example code:

import org.springframework.boot.autoconfigure.web.ServerProperties;

public class ExampleService {
	public  ExampleService(ServerProperties serverProperties) throws Exception {
		// get the session cookie name from configuration
		final String sessionCookieName = Optional.ofNullable(serverProperties.getServlet().getSession().getCookie().getName()).orElse("SESSION");
	}
}

When compiled and run against the same version of Spring Boot, it works fine. Compile against Spring Boot 3.1.6 then run against Spring Boot 3.2.0, this exception occurs:

Caused by: java.lang.NoSuchMethodError: 'org.springframework.boot.web.servlet.server.Session$Cookie org.springframework.boot.web.servlet.server.Session.getCookie()'
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 28, 2023
@philwebb
Copy link
Member

The class was removed here. I'm not sure how we can fix this without introducing a new method for getCookie() with a different name.

@philwebb philwebb added the for: team-meeting An issue we'd like to discuss as a team to make progress label Nov 28, 2023
@philwebb
Copy link
Member

Perhaps we can reintroduce the inner class but keep it empty.

@wilkinsona
Copy link
Member

We document that the property accessors aren't public API:

The properties that map to @ConfigurationProperties classes available in Spring Boot, which are configured through properties files, YAML files, environment variables, and other mechanisms, are public API but the accessors (getters/setters) of the class itself are not meant to be used directly.

Given this, I'm not sure that we should do anything here. It would depend a lot on how disruptive/awkward it would be to restore compatibility.

@philwebb
Copy link
Member

Session is a bit special because it's used in ConfigurableServletWebServerFactory. Ideally we'd have a better split between the code in org.springframework.boot.web.servlet.server and the properties classes we ultimately expose under the server.* properties but that's not the case right now. I've regretted that design decision for a while now.

@candrews
Copy link
Contributor Author

candrews commented Dec 4, 2023

Do you have any further thoughts on this issue?

I'm trying to decide what I can do to support the users using the library I support that's impacted by this issue.

Thank you again!

@philwebb
Copy link
Member

philwebb commented Dec 4, 2023

We talked about this today and we're going to put the class back in 3.2.x and look at reorganizing things in 4.x

@philwebb philwebb added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Dec 4, 2023
@philwebb philwebb self-assigned this Dec 4, 2023
@philwebb philwebb modified the milestones: 3.3.x, 3.2.x Dec 4, 2023
@philwebb philwebb changed the title Spring Boot 3.2 binary compatibility isuse: java.lang.NoSuchMethodError: 'org.springframework.boot.web.servlet.server.Session$Cookie org.springframework.boot.web.servlet.server.Session.getCookie()' NoSuchMethodError can be thrown from Session.getCookie() due to binary incompatibilty Dec 5, 2023
@philwebb philwebb modified the milestones: 3.2.x, 3.2.1 Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants