diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/WebSessionServerOAuth2AuthorizedClientRepository.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/WebSessionServerOAuth2AuthorizedClientRepository.java index e3b462ebac3..b37d325ea3c 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/WebSessionServerOAuth2AuthorizedClientRepository.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/WebSessionServerOAuth2AuthorizedClientRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,14 +94,10 @@ public Mono removeAuthorizedClient(String clientRegistrationId, Authentica // @formatter:on } - @SuppressWarnings("unchecked") private Map getAuthorizedClients(WebSession session) { - Map authorizedClients = (session != null) - ? (Map) session.getAttribute(this.sessionAttributeName) : null; - if (authorizedClients == null) { - authorizedClients = new HashMap<>(); - } - return authorizedClients; + Assert.notNull(session, "session cannot be null"); + Map authorizedClients = session.getAttribute(this.sessionAttributeName); + return (authorizedClients != null) ? authorizedClients : new HashMap<>(); } }