You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/12/18 16:13:12 UTC

svn commit: r605226 - /myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java

Author: imario
Date: Tue Dec 18 07:13:11 2007
New Revision: 605226

URL: http://svn.apache.org/viewvc?rev=605226&view=rev
Log:
void NPE when peeking the ConversationManager

Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java?rev=605226&r1=605225&r2=605226&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationManager.java Tue Dec 18 07:13:11 2007
@@ -87,7 +87,22 @@
 	 */
 	public static ConversationManager getInstance(boolean create)
 	{
-		ConversationManager conversationManager = (ConversationManager) FrameworkAdapter.getCurrentInstance().getSessionAttribute(CONVERSATION_MANAGER_KEY);
+		FrameworkAdapter frameworkAdapter = FrameworkAdapter.getCurrentInstance();
+		if (frameworkAdapter == null)
+		{
+			if (!create)
+			{
+				// if we should not created one, it doesn't matter if there is no
+				// FrameworkAdapter available.
+				return null;
+			}
+			else
+			{
+				throw new IllegalStateException("FrameworkAdapter not found");
+			}
+		}
+
+		ConversationManager conversationManager = (ConversationManager) frameworkAdapter.getSessionAttribute(CONVERSATION_MANAGER_KEY);
 		if (conversationManager == null && create)
 		{
 			// TODO: do not call new directly here, as it makes it impossible to configure
@@ -305,7 +320,7 @@
 	/**
 	 * Get the Messager used to inform the user about anomalies.
 	 * <p>
-	 * What instance is returned is controlled by the FrameworkAdapter. See 
+	 * What instance is returned is controlled by the FrameworkAdapter. See
 	 * {@link org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter} for details.
 	 */
 	public ConversationMessager getMessager()