File tree Expand file tree Collapse file tree
java/org/apache/catalina/connector Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -900,16 +900,13 @@ public void addCookie(final Cookie cookie) {
900900 return ;
901901 }
902902
903+ // Note: This also ensures context is not null
903904 String header = generateCookieString (cookie );
904905 if (header == null ) {
905906 return ;
906907 }
907- Context context = getContext ();
908- if (context == null ) {
909- return ;
910- }
911908 // if we reached here, no exception, cookie is valid
912- addHeader ("Set-Cookie" , header , context .getCookieProcessor ().getCharset ());
909+ addHeader ("Set-Cookie" , header , getContext () .getCookieProcessor ().getCharset ());
913910 }
914911
915912 /**
@@ -1113,17 +1110,18 @@ public String encodeURL(String url) {
11131110 }
11141111
11151112 if (isEncodeable (absolute )) {
1116- // W3c spec clearly said
1117- if (url .equalsIgnoreCase ("" )) {
1118- url = absolute ;
1119- } else if (url .equals (absolute ) && !hasPath (url )) {
1120- url += '/' ;
1113+ Session session = request .getSessionInternal ();
1114+ if (session != null ) {
1115+ // W3c spec clearly said
1116+ if (url .equalsIgnoreCase ("" )) {
1117+ url = absolute ;
1118+ } else if (url .equals (absolute ) && !hasPath (url )) {
1119+ url += '/' ;
1120+ }
1121+ return toEncoded (url , session .getIdInternal ());
11211122 }
1122- return toEncoded (url , request .getSessionInternal ().getIdInternal ());
1123- } else {
1124- return url ;
11251123 }
1126-
1124+ return url ;
11271125 }
11281126
11291127
You can’t perform that action at this time.
0 commit comments