Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid crawler to obtain a thread with a remanant context #2859

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/src/main/java/jeeves/server/context/ServiceContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public static ServiceContext get() {
return THREAD_LOCAL_INSTANCE.get();
}


public static void clear() {
THREAD_LOCAL_INSTANCE.remove();;
ApplicationContextHolder.clear();;
}
//--------------------------------------------------------------------------
//---
//--- Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package org.fao.geonet.api;

import jeeves.server.context.ServiceContext;
import org.apache.commons.lang.StringUtils;
import org.fao.geonet.utils.Log;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
Expand Down Expand Up @@ -86,6 +87,7 @@ private void createSessionForAllButNotCrawlers(HttpServletRequest request) {
}
} else {
HttpSession httpSession = request.getSession(false);
ServiceContext.clear();
if (Log.isDebugEnabled(Log.REQUEST)) {
Log.debug(Log.REQUEST, String.format(
"Crawler '%s' detected. Session MUST be null: %s",
Expand Down