1616
1717package org .springframework .security .web .authentication .rememberme ;
1818
19- import java .io .UnsupportedEncodingException ;
2019import java .net .URLDecoder ;
2120import java .net .URLEncoder ;
2221import java .nio .charset .StandardCharsets ;
@@ -170,7 +169,7 @@ public Authentication autoLogin(HttpServletRequest request, HttpServletResponse
170169 */
171170 protected String extractRememberMeCookie (HttpServletRequest request ) {
172171 Cookie [] cookies = request .getCookies ();
173- if (( cookies == null ) || ( cookies . length == 0 ) ) {
172+ if (cookies == null ) {
174173 return null ;
175174 }
176175 for (Cookie cookie : cookies ) {
@@ -220,12 +219,7 @@ protected String[] decodeCookie(String cookieValue) throws InvalidCookieExceptio
220219 }
221220 String [] tokens = StringUtils .delimitedListToStringArray (cookieAsPlainText , DELIMITER );
222221 for (int i = 0 ; i < tokens .length ; i ++) {
223- try {
224- tokens [i ] = URLDecoder .decode (tokens [i ], StandardCharsets .UTF_8 .toString ());
225- }
226- catch (UnsupportedEncodingException ex ) {
227- this .logger .error (ex .getMessage (), ex );
228- }
222+ tokens [i ] = URLDecoder .decode (tokens [i ], StandardCharsets .UTF_8 );
229223 }
230224 return tokens ;
231225 }
@@ -238,12 +232,7 @@ protected String[] decodeCookie(String cookieValue) throws InvalidCookieExceptio
238232 protected String encodeCookie (String [] cookieTokens ) {
239233 StringBuilder sb = new StringBuilder ();
240234 for (int i = 0 ; i < cookieTokens .length ; i ++) {
241- try {
242- sb .append (URLEncoder .encode (cookieTokens [i ], StandardCharsets .UTF_8 .toString ()));
243- }
244- catch (UnsupportedEncodingException ex ) {
245- this .logger .error (ex .getMessage (), ex );
246- }
235+ sb .append (URLEncoder .encode (cookieTokens [i ], StandardCharsets .UTF_8 ));
247236 if (i < cookieTokens .length - 1 ) {
248237 sb .append (DELIMITER );
249238 }
0 commit comments