Skip to content

Commit

Permalink
Remove deprecation warnings with Context.putAll
Browse files Browse the repository at this point in the history
  • Loading branch information
sjohnr committed Jul 8, 2022
1 parent 4a5c0ac commit 4620bd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import reactor.core.publisher.Mono;
import reactor.core.publisher.Operators;
import reactor.util.context.Context;
import reactor.util.context.ContextView;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
Expand Down Expand Up @@ -107,7 +108,7 @@ public Context currentContext() {
return context;
}
Context toMerge = ReactiveSecurityContextHolder.withSecurityContext(Mono.just(this.securityContext));
return toMerge.putAll(context);
return toMerge.putAll(context.readOnly());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
}

private Context withSecurityContext(Context mainContext, ServerWebExchange exchange) {
return mainContext
.putAll(this.repository.load(exchange).as(ReactiveSecurityContextHolder::withSecurityContext));
return mainContext.putAll(
this.repository.load(exchange).as(ReactiveSecurityContextHolder::withSecurityContext).readOnly());
}

}

0 comments on commit 4620bd0

Please sign in to comment.