This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new cab09fcf75 Optimize when call getSessionCookieName &
getSessionUriParamName (#660)
cab09fcf75 is described below
commit cab09fcf755400ef613f7989a2b43d1ce57e13f8
Author: Herb <[email protected]>
AuthorDate: Wed Sep 6 21:41:53 2023 +0900
Optimize when call getSessionCookieName & getSessionUriParamName (#660)
Reduce duplicate / unnecessary code
---
java/org/apache/catalina/util/SessionConfig.java | 27 +++++-------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/java/org/apache/catalina/util/SessionConfig.java
b/java/org/apache/catalina/util/SessionConfig.java
index 69a0e09ad2..932c115820 100644
--- a/java/org/apache/catalina/util/SessionConfig.java
+++ b/java/org/apache/catalina/util/SessionConfig.java
@@ -32,14 +32,7 @@ public class SessionConfig {
* @return the cookie name for the context
*/
public static String getSessionCookieName(Context context) {
-
- String result = getConfiguredSessionCookieName(context);
-
- if (result == null) {
- result = DEFAULT_SESSION_COOKIE_NAME;
- }
-
- return result;
+ return getConfiguredSessionCookieName(context,
DEFAULT_SESSION_COOKIE_NAME);
}
/**
@@ -49,19 +42,11 @@ public class SessionConfig {
* @return the parameter name for the session
*/
public static String getSessionUriParamName(Context context) {
-
- String result = getConfiguredSessionCookieName(context);
-
- if (result == null) {
- result = DEFAULT_SESSION_PARAMETER_NAME;
- }
-
- return result;
+ return getConfiguredSessionCookieName(context,
DEFAULT_SESSION_PARAMETER_NAME);
}
- private static String getConfiguredSessionCookieName(Context context) {
-
+ private static String getConfiguredSessionCookieName(Context context,
String defaultName) {
// Priority is:
// 1. Cookie name defined in context
// 2. Cookie name configured for app
@@ -72,15 +57,13 @@ public class SessionConfig {
return cookieName;
}
- SessionCookieConfig scc =
- context.getServletContext().getSessionCookieConfig();
+ SessionCookieConfig scc =
context.getServletContext().getSessionCookieConfig();
cookieName = scc.getName();
if (cookieName != null && cookieName.length() > 0) {
return cookieName;
}
}
-
- return null;
+ return defaultName;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]