Hi Richard,
thank you for finding this out!
IMO there was no concurrency problem, just some logic issues.
I've fixed the issue [1] on trunk. Please let me know, if it works for
you.
Thanks.
WBR,
Alexey.
[1]
https://grizzly.dev.java.net/issues/show_bug.cgi?id=790
> Firstly session.invalidate() does not seem to work as demonstrated
> by my test Servlet below. Reloading the page should cause the
> response message to rotate between "Creating Session", "Resuming
> Session" and "Destroying Session". It only responds with "Creating
> Session" initially and never does after "Destroying Session".
>
> Secondly different browsers get allocated the same session id.
>
> I’m using Grizzly version 1.9.18-i.
>
> Everything works fine when I deploy the war using Glassfish version
> v3.
>
> Does anyone have any ideas what the problem is here?
>
> Shall I raise a bug?
>
> Looking at com.sun.grizzly.http.servlet.HttpSessionImpl invalidate
> does not seem to call setIsValid on the underlying GrizzlySession.
>
> Looking at com.sun.grizzly.tcp.http11.GrizzlyRequest where the
> session management is being done there is no concurrency control on
> the "sessions" map, which might be causing multiple browsers getting
> the same one.
>
> From Richard.
>
>
> I’m embedding it as follows:
>
> public static void main(String[] args) {
> GrizzlyWebServerDeployer deployer = new
> GrizzlyWebServerDeployer();
> deployer.setDeployedApplicationList(new
> ArrayList<String>());
> deployer.setLocations("grizzly.war");
> deployer.setCometEnabled(true);
> deployer.setForceWarDeployment(true);
> deployer.launch();
> }
>
> My test Servlet’s doGet method:
>
> protected void doGet(HttpServletRequest req, HttpServletResponse
> resp) throws ServletException, IOException {
> HttpSession session = req.getSession(false);
> String response;
> if (session == null) {
> session = req.getSession();
> response = "Creating Session " +
> session.getId();
> }
> else {
> if (session.getAttribute("x") !=
> null) {
> response =
> "Destroying Session " + session.getId();
> session.invalidate();
> }
> else {
> response = "Resuming
> Session " + session.getId();
>
> session.setAttribute("x", "x");
> }
> }
> System.err.println(response);
> resp.getWriter().println(response);
> }