@@ -62,7 +62,6 @@ public void setup() {
6262
6363 @ Test
6464 public void basic () {
65-
6665 this .builder .build ().get ().uri ("/path" ).exchange ();
6766
6867 ClientRequest request = verifyAndGetRequest ();
@@ -73,7 +72,6 @@ public void basic() {
7372
7473 @ Test
7574 public void uriBuilder () {
76-
7775 this .builder .build ().get ()
7876 .uri (builder -> builder .path ("/path" ).queryParam ("q" , "12" ).build ())
7977 .exchange ();
@@ -85,7 +83,6 @@ public void uriBuilder() {
8583
8684 @ Test
8785 public void uriBuilderWithPathOverride () {
88-
8986 this .builder .build ().get ()
9087 .uri (builder -> builder .replacePath ("/path" ).build ())
9188 .exchange ();
@@ -97,7 +94,6 @@ public void uriBuilderWithPathOverride() {
9794
9895 @ Test
9996 public void requestHeaderAndCookie () {
100-
10197 this .builder .build ().get ().uri ("/path" ).accept (MediaType .APPLICATION_JSON )
10298 .cookies (cookies -> cookies .add ("id" , "123" )) // SPR-16178
10399 .exchange ();
@@ -110,7 +106,6 @@ public void requestHeaderAndCookie() {
110106
111107 @ Test
112108 public void defaultHeaderAndCookie () {
113-
114109 WebClient client = this .builder
115110 .defaultHeader ("Accept" , "application/json" ).defaultCookie ("id" , "123" )
116111 .build ();
@@ -125,7 +120,6 @@ public void defaultHeaderAndCookie() {
125120
126121 @ Test
127122 public void defaultHeaderAndCookieOverrides () {
128-
129123 WebClient client = this .builder
130124 .defaultHeader ("Accept" , "application/json" )
131125 .defaultCookie ("id" , "123" )
@@ -141,7 +135,6 @@ public void defaultHeaderAndCookieOverrides() {
141135
142136 @ Test
143137 public void defaultRequest () {
144-
145138 ThreadLocal <String > context = new NamedThreadLocal <>("foo" );
146139
147140 Map <String , Object > actual = new HashMap <>();
@@ -176,7 +169,6 @@ public void bodyObjectPublisher() {
176169
177170 @ Test
178171 public void mutateDoesCopy () {
179-
180172 // First, build the clients
181173
182174 WebClient .Builder builder = WebClient .builder ()
@@ -216,8 +208,7 @@ public void mutateDoesCopy() {
216208 }
217209
218210 @ Test
219- public void attributes () {
220-
211+ public void withStringAttribute () {
221212 Map <String , Object > actual = new HashMap <>();
222213 ExchangeFilterFunction filter = (request , next ) -> {
223214 actual .putAll (request .attributes ());
@@ -230,11 +221,32 @@ public void attributes() {
230221 .exchange ();
231222
232223 assertEquals ("bar" , actual .get ("foo" ));
224+
225+ ClientRequest request = verifyAndGetRequest ();
226+ assertEquals ("bar" , request .attribute ("foo" ).get ());
233227 }
234228
235229 @ Test
236- public void apply () {
230+ public void withNullAttribute () {
231+ Map <String , Object > actual = new HashMap <>();
232+ ExchangeFilterFunction filter = (request , next ) -> {
233+ actual .putAll (request .attributes ());
234+ return next .exchange (request );
235+ };
236+
237+ this .builder .filter (filter ).build ()
238+ .get ().uri ("/path" )
239+ .attribute ("foo" , null )
240+ .exchange ();
237241
242+ assertNull (actual .get ("foo" ));
243+
244+ ClientRequest request = verifyAndGetRequest ();
245+ assertFalse (request .attribute ("foo" ).isPresent ());
246+ }
247+
248+ @ Test
249+ public void apply () {
238250 WebClient client = this .builder
239251 .apply (builder -> builder
240252 .defaultHeader ("Accept" , "application/json" )
0 commit comments