Skip to content

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

@candrews

Description

@candrews

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()'

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions