1003491 System logs filled with zkoss error for several hours. Fixed NPE when native session have been destroyed.

This commit is contained in:
Heng Sin Low 2013-11-18 10:44:08 +08:00
parent 6937c2dbdb
commit 4623148e1e
1 changed files with 14 additions and 1 deletions

View File

@ -65,6 +65,19 @@ public class SessionContextListener implements ExecutionInit,
Session session = exec.getDesktop().getSession(); Session session = exec.getDesktop().getSession();
Properties ctx = (Properties)session.getAttribute(SESSION_CTX); Properties ctx = (Properties)session.getAttribute(SESSION_CTX);
HttpSession httpSession = (HttpSession)session.getNativeSession(); HttpSession httpSession = (HttpSession)session.getNativeSession();
//create empty context if there's no valid native session
if (httpSession == null)
{
ctx = new Properties();
ctx.put(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER, new ServerContextURLHandler() {
public void showURL(String url) {
SessionManager.getAppDesktop().showURL(url, true);
}
});
ServerContext.setCurrentInstance(ctx);
return;
}
if (ctx != null) if (ctx != null)
{ {
//verify ctx //verify ctx
@ -283,7 +296,7 @@ public class SessionContextListener implements ExecutionInit,
HttpSession httpSession = (HttpSession)session.getNativeSession(); HttpSession httpSession = (HttpSession)session.getNativeSession();
//verify ctx //verify ctx
String cacheId = ctx.getProperty(SERVLET_SESSION_ID); String cacheId = ctx.getProperty(SERVLET_SESSION_ID);
if (cacheId == null || !cacheId.equals(httpSession.getId()) ) if (cacheId == null || httpSession == null || !cacheId.equals(httpSession.getId()) )
{ {
return false; return false;
} }