Skip to content

AbstractServerHttpRequest constructor breaks binary compatibility between 5.2.x and 5.3.x #26151

@ikhoon

Description

@ikhoon

Motivation:

The AbstractServerHttpRequest constructor signature has been changed by 3276f81#diff-80d003153fc35acd9545fb81c726d9aa41dffc39c507c590e03e07a2450ed1bf.
This change causes NoSuchMethodError when a Spring 5.3 run with a compiled class that extends 5.2.x version AbstractServerHttpRequest.

java.lang.NoSuchMethodError: org/springframework/http/server/reactive/AbstractServerHttpRequest.<init>(Ljava/net/URI;Ljava/lang/String;Lorg/springframework/http/HttpHeaders;)V (loaded from file:/Users/wickedev/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/5.3.0-RC2/ce128df6b5debc37d8019a17773f8a31af7ffba8/spring-web-5.3.0-RC2.jar by jdk.internal.loader.ClassLoaders$AppClassLoader@62918e21) called from class com.linecorp.armeria.spring.web.reactive.ArmeriaServerHttpRequest (loaded from file:/Users/wickedev/.gradle/caches/modules-2/files-2.1/com.linecorp.armeria/armeria-spring-boot2-webflux-autoconfigure/1.0.0/a5b511b31f065caba67d35b7d081735e81277898/armeria-spring-boot2-webflux-autoconfigure-1.0.0.jar by jdk.internal.loader.ClassLoaders$AppClassLoader@62918e21).
	at com.linecorp.armeria.spring.web.reactive.ArmeriaServerHttpRequest.<init>(ArmeriaServerHttpRequest.java:60)
	at com.linecorp.armeria.spring.web.reactive.ArmeriaHttpHandlerAdapter.handle(ArmeriaHttpHandlerAdapter.java:54)
	at com.linecorp.armeria.spring.web.reactive.ArmeriaReactiveWebServerFactory.lambda$configureService$5(ArmeriaReactiveWebServerFactory.java:243)
	at com.linecorp.armeria.spring.web.reactive.ArmeriaReactiveWebServerFactory$$Lambda$472/0000000000000000.serve(Unknown Source)

Suggestion:

Revive the removed constructor with a deprecation annotation.

public abstract class AbstractServerHttpRequest implements ServerHttpRequest {


	public AbstractServerHttpRequest(URI uri, @Nullable String contextPath, MultiValueMap<String, String> headers) {
        ...
    }

    @Deprecated
	public AbstractServerHttpRequest(URI uri, @Nullable String contextPath, HttpHeaders headers) {
        this.uri = uri;
        path = RequestPath.parse(uri, contextPath);
        // Need to call `readOnlyHttpHeaders` with `HttpHeaders`
        // HttpHeaders.readOnlyHttpHeaders(MultiValueMap) is added in 5.3.x
        this.headers = HttpHeaders.readOnlyHttpHeaders(headers);
	}
}

Related: line/armeria#3131

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions