cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1300431 - /cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java
Date Wed, 14 Mar 2012 01:02:07 GMT
Author: thorsten
Date: Wed Mar 14 01:02:07 2012
New Revision: 1300431

URL: http://svn.apache.org/viewvc?rev=1300431&view=rev
Log:
Preventing NPE and throwing a more helping error message

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java?rev=1300431&r1=1300430&r2=1300431&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/CallStackCollectorDataStore.java
Wed Mar 14 01:02:07 2012
@@ -16,15 +16,34 @@
  */
 package org.apache.cocoon.servlet.collector;
 
+import org.apache.cocoon.callstack.CallFrame;
 import org.apache.cocoon.callstack.CallStack;
 
 public class CallStackCollectorDataStore implements CollectorDataStore {
 
     public Object get(String key) {
-        return CallStack.getCurrentFrame().getAttribute(key);
+        final CallFrame frame = CallStack.getCurrentFrame();
+        if (null != frame) {
+            return frame.getAttribute(key);
+        } else {
+            throw new InvalidStatusCodeException(
+                    "Seems you are in no frame, this usually "
+                            + "happens when you are not in a servlet context. "
+                            + "Please use CallStackHelper.enterServlet(...) "
+                            + "if you need to enter in a context.");
+        }
     }
 
     public void set(String key, Object value) {
-        CallStack.getCurrentFrame().setAttribute(key, value);
+        final CallFrame frame = CallStack.getCurrentFrame();
+        if (null != frame) {
+            frame.setAttribute(key, value);
+        } else {
+            throw new InvalidStatusCodeException(
+                    "Seems you are in no frame, this usually "
+                            + "happens when you are not in a servlet context. "
+                            + "Please use CallStackHelper.enterServlet(...) "
+                            + "if you need to enter in a context.");
+        }
     }
 }



Mime
View raw message