Portlet session mutex uses global session attribute to be shared among all portlets in the session (SPR-8888)
This commit is contained in:
parent
53cb529162
commit
21f61e3680
|
|
@ -29,10 +29,10 @@ import javax.portlet.PortletContext;
|
|||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletRequestDispatcher;
|
||||
import javax.portlet.PortletResponse;
|
||||
import javax.portlet.PortletSession;
|
||||
import javax.portlet.ResourceRequest;
|
||||
import javax.portlet.ResourceResponse;
|
||||
import javax.portlet.PortletResponse;
|
||||
import javax.portlet.filter.PortletRequestWrapper;
|
||||
import javax.portlet.filter.PortletResponseWrapper;
|
||||
import javax.servlet.http.Cookie;
|
||||
|
|
@ -271,7 +271,7 @@ public abstract class PortletUtils {
|
|||
*/
|
||||
public static Object getSessionMutex(PortletSession session) {
|
||||
Assert.notNull(session, "Session must not be null");
|
||||
Object mutex = session.getAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE);
|
||||
Object mutex = session.getAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, PortletSession.APPLICATION_SCOPE);
|
||||
if (mutex == null) {
|
||||
mutex = session;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-20011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -25,8 +25,6 @@ import javax.portlet.PortletContext;
|
|||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletSession;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.ITestBean;
|
||||
|
|
@ -38,6 +36,9 @@ import org.springframework.mock.web.portlet.MockPortletRequest;
|
|||
import org.springframework.mock.web.portlet.MockPortletSession;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
|
|
@ -374,7 +375,7 @@ public final class PortletUtilsTests {
|
|||
public void testGetSessionMutexWithExistingSessionMutexReturnsTheExistingSessionMutex() throws Exception {
|
||||
MockPortletSession session = new MockPortletSession();
|
||||
Object expectSessionMutex = new Object();
|
||||
session.setAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, expectSessionMutex);
|
||||
session.setAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, expectSessionMutex, PortletSession.APPLICATION_SCOPE);
|
||||
Object actualSessionMutex = PortletUtils.getSessionMutex(session);
|
||||
assertNotNull("PortletUtils.getSessionMutex(..) must never return a null mutex", actualSessionMutex);
|
||||
assertSame("PortletUtils.getSessionMutex(..) must return the bound mutex attribute if a mutex has been bound as a Session attribute beforehand",
|
||||
|
|
|
|||
Loading…
Reference in New Issue