From 042d8d0b4c699e58629d99b7860bc6b8c546c773 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 7 Apr 2016 11:41:32 +0200 Subject: [PATCH] FacesRequestAttributes falls back to ExternalContext as session mutex Issue: SPR-12402 --- .../context/request/FacesRequestAttributes.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java b/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java index 73301c34a9..bfbf032b01 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/FacesRequestAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -217,7 +217,7 @@ public class FacesRequestAttributes implements RequestAttributes { Object session = getExternalContext().getSession(true); try { // Both HttpSession and PortletSession have a getId() method. - Method getIdMethod = session.getClass().getMethod("getId", new Class[0]); + Method getIdMethod = session.getClass().getMethod("getId"); return ReflectionUtils.invokeMethod(getIdMethod, session).toString(); } catch (NoSuchMethodException ex) { @@ -227,12 +227,12 @@ public class FacesRequestAttributes implements RequestAttributes { @Override public Object getSessionMutex() { - // Enforce presence of a session first to allow listeners - // to create the mutex attribute, if any. - Object session = getExternalContext().getSession(true); - Object mutex = getExternalContext().getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); + // Enforce presence of a session first to allow listeners to create the mutex attribute + ExternalContext externalContext = getExternalContext(); + Object session = externalContext.getSession(true); + Object mutex = externalContext.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); if (mutex == null) { - mutex = session; + mutex = (session != null ? session : externalContext); } return mutex; }