Author: fmeschbe
Date: Wed Jan 16 02:12:00 2008
New Revision: 612407

URL: http://svn.apache.org/viewvc?rev=612407&view=rev
Log:
Catch possible exception which may be thrown if there is no "request" object

Modified:
    
incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java

Modified: 
incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java?rev=612407&r1=612406&r2=612407&view=diff
==============================================================================
--- 
incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
 (original)
+++ 
incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptablePrintWriter.java
 Wed Jan 16 02:12:00 2008
@@ -148,14 +148,18 @@
     private Locale getLocale() {
         if (locale == null) {
             
-            // check whether we have a request object which has the locale
-            Object reqObj = ScriptRuntime.name(Context.getCurrentContext(),
-                this, SlingBindings.REQUEST);
-            if (reqObj instanceof Wrapper) {
-                Object wrapped = ((Wrapper) reqObj).unwrap();
-                if (wrapped instanceof HttpServletRequest) {
-                    locale = ((HttpServletRequest) wrapped).getLocale();
+            try {
+                // check whether we have a request object which has the locale
+                Object reqObj = ScriptRuntime.name(Context.getCurrentContext(),
+                    this, SlingBindings.REQUEST);
+                if (reqObj instanceof Wrapper) {
+                    Object wrapped = ((Wrapper) reqObj).unwrap();
+                    if (wrapped instanceof HttpServletRequest) {
+                        locale = ((HttpServletRequest) wrapped).getLocale();
+                    }
                 }
+            } catch (Exception e) {
+                // ignore any exceptions resulting from this and use default
             }
 
             // default, if the no request locale or no request is available


Reply via email to