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 44import java .net .URLDecoder ;
55import java .nio .charset .StandardCharsets ;
66import java .util .ArrayList ;
7+ import java .util .Collections ;
78import java .util .LinkedHashMap ;
89import java .util .List ;
910import java .util .Map ;
@@ -338,7 +339,7 @@ public void afterResponse(Runnable runnable) {
338339
339340 /** Internal accessor for the after-hook queue; used by RequestPreparationFilter. */
340341 public List <Runnable > afterHooks () {
341- return afterHooks ;
342+ return Collections . unmodifiableList ( afterHooks ) ;
342343 }
343344
344345 private static Map <String , String > parseQuery (String query ) {
Original file line number Diff line number Diff line change @@ -273,7 +273,12 @@ void withPrincipalsSharesAfterHookQueue() {
273273 }
274274
275275 assertThat (log ).containsExactly ("from-original" , "from-enriched" );
276- assertThat (original .afterHooks ()).isSameAs (enriched .afterHooks ());
276+ // Adding via one Request is visible via the other — the backing list is shared.
277+ original .afterResponse (() -> log .add ("from-original-again" ));
278+ List <Runnable > enrichedView = enriched .afterHooks ();
279+ assertThat (enrichedView ).hasSize (3 );
280+ enrichedView .get (2 ).run ();
281+ assertThat (log ).containsExactly ("from-original" , "from-enriched" , "from-original-again" );
277282 }
278283
279284 @ Test
You can’t perform that action at this time.
0 commit comments