Memory leak with JSF and view scoped beans in EAP 6
Issue
- When a jsf action invalidate the current session and redirect to the current page, a referred view scoped managed bean leaks.
SessionController:
public class SessionController {
public void invalidateSession() throws Exception {
ExternalContext externalContext= FacesContext.getCurrentInstance().getExternalContext();
externalContext.getSessionMap().clear();
HttpSession session = (HttpSession) externalContext.getSession(true);
session.invalidate();
}
}
LogoutController:
@RequestScoped
@ManagedBean
public class LogoutController {
@Inject
private SessionController sessionController;
public String logout() throws Exception {
sessionController.invalidateSession();
// return to the start page
return "/index.xhtml?faces-redirect=true";
}
}
MyPageController:
@ViewScoped
@ManagedBean
public class MyPageController {
...
}
index.xhtml
...
<h:outputText value="Amount:"></h:outputText> <h:outputText value="#{myPageController.amount}" ></h:outputText>
...
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.3.3
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
