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

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

Closed
ikhoon opened this issue Nov 25, 2020 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@ikhoon
Copy link

ikhoon commented Nov 25, 2020

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 25, 2020
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 25, 2020
@jhoeller jhoeller added this to the 5.3.2 milestone Nov 25, 2020
@jhoeller jhoeller self-assigned this Nov 25, 2020
@jhoeller jhoeller changed the title AbstractServerHttpRequest constructor breaks compatibility between 5.2.x and 5.3.x AbstractServerHttpRequest constructor breaks binary compatibility between 5.2.x and 5.3.x Nov 25, 2020
@jhoeller
Copy link
Contributor

I've ended up restoring the original constructor side by side, without a deprecation marker. Some of our own subclasses pass in a HttpHeaders instance, so we'd have to do awkward casting to bypass the deprecated constructor. Also, HttpHeaders.readOnlyHttpHeaders(HttpHeaders) allows us to skip a downcast, so a dedicated constructor for it doesn't hurt.

trustin pushed a commit to line/armeria that referenced this issue Nov 26, 2020
Dependencies 
- completalbe-futures 0.3.3 -> 0.3.4
- dropwizard-core 2.0.13 -> 2.0.15
- Fastutil 8.4.2 -> 8.4.3
- gax-grpc 1.60.0 -> 1.60.1
- gRPC 1.33.0 -> 1.33.1
- grpc-kotlin-stub 0.2.0 -> 0.2.1
- io.dropwizard.metrics 4.1.13 -> 4.1.15
- Jackson 2.11.2 -> 2.11.3
- Micrometer 1.5.5 -> 1.6.1
- org.bouncycastle 1.66 -> 1.67
- Reactor 3.3.10.RELEASE -> 3.4.0
- reactor-kotlin-extensions 1.0.2.RELEASE -> 1.1.0
- Spring Boot 2.3.4.RELEASE -> 2.4.0
- spring-web 5.2.9.RELEASE -> 5.3.1.RELEASE
- tomcat-embed-core 9.0.39 -> 9.0.40
- Examples and testings
  - akka-actor-typed_2.13 2.6.9 -> 2.6.10
  - akka-grpc-runtime_2.13 1.0.1 -> 1.0.2
  - Checkstyle 8.36.2 -> 8.37
  - Dagger 2.29.1 -> 2.30.1
  - Eureka 1.10.7 -> 1.10.10
  - Finagle 20.9.0 -> 20.10.0
  - Gradle 6.7 -> 6.7.1
  - httpclient 4.5.12 -> 4.5.13
  - jmh-gradle-plugin 0.5.0 -> 0.5.2
  - json-unit 2.19.0-> 2.21.0
  - kotlin-allopen 1.4.10 -> 1.4.20
  - mockito-core 3.5.15 -> 3.6.0
  - monix-reactive_2.13 3.2.2+45-5c6c8b9e -> 3.3.0
  - proguard-gradle 7.0.0 -> 7.0.1

Modifications:
- boot-autoconfigure and boot-actuator-autoconfigure does not have starter dependency anymore.
  - boot-webflux-autoconfigure has stater dependency though because there are no autoconfigure dependency for webflux.
- Forked `AbstractServerHttpRequest` to support both Spring 5.2 and 5.3.
  - See spring-projects/spring-framework#26151

Co-authored-by: Ikhun Um <ikhun.um@linecorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants