Skip to content

Commit 82ac99f

Browse files
Remove redundant check and exception
Signed-off-by: Tran Ngoc Nhan <[email protected]>
1 parent a96dbd8 commit 82ac99f

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.security.web.authentication.rememberme;
1818

19-
import java.io.UnsupportedEncodingException;
2019
import java.net.URLDecoder;
2120
import java.net.URLEncoder;
2221
import 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

Comments
 (0)