From 603e23077575df3e974baa51d7dfd9086c5caa9a Mon Sep 17 00:00:00 2001 From: maura fortino Date: Wed, 11 Oct 2023 11:58:38 -0400 Subject: [PATCH 1/2] removed memory aliasing issue --- WRPHandler_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WRPHandler_test.go b/WRPHandler_test.go index c19769e..99a5e5b 100644 --- a/WRPHandler_test.go +++ b/WRPHandler_test.go @@ -84,7 +84,8 @@ func TestFanoutRequest(t *testing.T) { Entity: testCase.Entity, } - mockWRPAccessAuthority.On("authorizeWRP", r.Context(), &testCase.Entity.Message).Return(testCase.Modify, testCase.Err) + testEntity := testCase.Entity.Message + mockWRPAccessAuthority.On("authorizeWRP", r.Context(), &testEntity).Return(testCase.Modify, testCase.Err) wrpFanoutHandler.ServeWRP(wrpResponseWriter, wrpRequest) From ecb3d78c1bb1359f8af6e94eee51afbd17653b65 Mon Sep 17 00:00:00 2001 From: maura fortino Date: Wed, 11 Oct 2023 11:59:13 -0400 Subject: [PATCH 2/2] minor changes to validateWRP func --- primaryHandler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primaryHandler.go b/primaryHandler.go index 28706a9..c458ab3 100644 --- a/primaryHandler.go +++ b/primaryHandler.go @@ -567,8 +567,7 @@ func ValidateWRP() func(http.Handler) http.Handler { return func(delegate http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - if msg, ok := wrpcontext.Get[*wrp.Message](ctx); ok { + if msg, ok := wrpcontext.Get[*wrp.Message](r.Context()); ok { validators := wrp.SpecValidators() var err error for _, v := range validators { @@ -586,6 +585,7 @@ func ValidateWRP() func(http.Handler) http.Handler { return } } + delegate.ServeHTTP(w, r) }) }