File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http
test/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import java .net .URLDecoder ;
44import java .nio .charset .StandardCharsets ;
55import java .util .ArrayList ;
6+ import java .util .Collections ;
67import java .util .LinkedHashMap ;
78import java .util .List ;
89import java .util .Map ;
@@ -271,7 +272,7 @@ public void afterResponse(Runnable runnable) {
271272
272273 /** Internal accessor for the after-hook queue; used by RequestPreparationFilter. */
273274 public List <Runnable > afterHooks () {
274- return afterHooks ;
275+ return Collections . unmodifiableList ( afterHooks ) ;
275276 }
276277
277278 private static Map <String , String > parseQuery (String query ) {
Original file line number Diff line number Diff line change @@ -272,7 +272,12 @@ void withPrincipalsSharesAfterHookQueue() {
272272 }
273273
274274 assertThat (log ).containsExactly ("from-original" , "from-enriched" );
275- assertThat (original .afterHooks ()).isSameAs (enriched .afterHooks ());
275+ // Adding via one Request is visible via the other — the backing list is shared.
276+ original .afterResponse (() -> log .add ("from-original-again" ));
277+ List <Runnable > enrichedView = enriched .afterHooks ();
278+ assertThat (enrichedView ).hasSize (3 );
279+ enrichedView .get (2 ).run ();
280+ assertThat (log ).containsExactly ("from-original" , "from-enriched" , "from-original-again" );
276281 }
277282
278283 @ Test
You can’t perform that action at this time.
0 commit comments