11/*
2- * Copyright 2002-2024 the original author or authors.
2+ * Copyright 2002-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2323import org .springframework .util .ObjectUtils ;
2424import org .springframework .web .bind .annotation .RequestHeader ;
2525import org .springframework .web .service .annotation .GetExchange ;
26+ import org .springframework .web .service .annotation .HttpExchange ;
2627
2728import static org .assertj .core .api .Assertions .assertThat ;
2829
3233 *
3334 * @author Olga Maciaszek-Sharma
3435 * @author Rossen Stoyanchev
36+ * @author Yanming Zhou
3537 */
3638class RequestHeaderArgumentResolverTests {
3739
@@ -49,6 +51,12 @@ void header() {
4951 assertRequestHeaders ("id" , "test" );
5052 }
5153
54+ @ Test
55+ void doesNotOverrideAnnotationHeaders () {
56+ this .service .executeWithAnnotationHeaders ("test" );
57+ assertRequestHeaders ("id" , "default" , "test" );
58+ }
59+
5260 private void assertRequestHeaders (String key , String ... values ) {
5361 List <String > actualValues = this .client .getRequestValues ().getHeaders ().get (key );
5462 if (ObjectUtils .isEmpty (values )) {
@@ -65,6 +73,9 @@ private interface Service {
6573 @ GetExchange
6674 void execute (@ RequestHeader String id );
6775
76+ @ HttpExchange (method = "GET" , headers = "id=default" )
77+ void executeWithAnnotationHeaders (@ RequestHeader String id );
78+
6879 }
6980
7081}
0 commit comments