Hi,
I was writing some tests for the simple feature service implementation
when I got tangled up in a separate issue... the basic test I wrote
was failing to build a valid response, but the response status I got back
was a 200 and just a "[" as the content of the response.
No logs, no way to know what happened.

After some debugging I found that Restlet logged the exception that
was thrown only at the INFO level, which is disabled during tests,
and that it did set the status to 500, but too late because the response
was already committed.

For the first issue I'm attaching a patch that seems to solve it:
the ServletConverter gets subclassed to override the logging level
of the error to SEVERE.

For the second one (setting the status before commiting the request)
I guess we should have a output strategy
handling on the rest path, so that we cache some kb of data before
sending back a response.
I _think_ this may be doable by wrapping the httpservletresponse
into one that would build a stream backed by the output strategy

Opinions?

Cheers
Andrea


-- 
Ing. Andrea Aime
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584962313
fax:     +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------
diff --git a/src/rest/src/main/java/org/geoserver/rest/GeoServerServletConverter.java b/src/rest/src/main/java/org/geoserver/rest/GeoServerServletConverter.java
index ed7e2dc..b2c0c56 100644
--- a/src/rest/src/main/java/org/geoserver/rest/GeoServerServletConverter.java
+++ b/src/rest/src/main/java/org/geoserver/rest/GeoServerServletConverter.java
@@ -1,3 +1,7 @@
+/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
+ * This code is licensed under the GPL 2.0 license, availible at the root
+ * application directory.
+ */
 package org.geoserver.rest;
 
 import java.util.logging.Level;
@@ -12,10 +16,15 @@ import org.restlet.data.Status;
 import com.noelios.restlet.ext.servlet.ServletConverter;
 import com.noelios.restlet.http.HttpResponse;
 
+/**
+ * A custom servlet controller that forces the logging level of errors to SEVERE
+ * 
+ * @author Andrea Aime - GeoSolutions
+ */
 public class GeoServerServletConverter extends ServletConverter {
-    
+
     static final Logger LOGGER = Logging.getLogger(GeoServerServletConverter.class);
-    
+
     public GeoServerServletConverter(ServletContext context, Restlet target) {
         super(context, target);
     }
@@ -23,14 +32,15 @@ public class GeoServerServletConverter extends ServletConverter {
     public GeoServerServletConverter(ServletContext context) {
         super(context);
     }
-    
+
     @Override
     public Logger getLogger() {
         return LOGGER;
     }
-    
+
     /**
      * Overridden to get at the very least a log at severe level
+     * 
      * @param response
      */
     @Override
@@ -42,12 +52,11 @@ public class GeoServerServletConverter extends ServletConverter {
             // Send the response to the client
             response.getHttpCall().sendResponse(response);
         } catch (Exception e) {
+            // raise the logging level to SEVERE
             LOGGER.log(Level.SEVERE, "Exception intercepted", e);
             response.getHttpCall().setStatusCode(Status.SERVER_ERROR_INTERNAL.getCode());
-            response.getHttpCall().setReasonPhrase(
-                    "An unexpected exception occured");
+            response.getHttpCall().setReasonPhrase("An unexpected exception occured");
         }
     }
 
-
 }
diff --git a/src/rest/src/main/java/org/geoserver/rest/RESTDispatcher.java b/src/rest/src/main/java/org/geoserver/rest/RESTDispatcher.java
index 514227f..87cca6d 100644
--- a/src/rest/src/main/java/org/geoserver/rest/RESTDispatcher.java
+++ b/src/rest/src/main/java/org/geoserver/rest/RESTDispatcher.java
@@ -66,7 +66,7 @@ public class RESTDispatcher extends AbstractController {
     protected void initApplicationContext() throws BeansException {
         super.initApplicationContext();
 
-        myConverter = new ServletConverter(getServletContext());
+        myConverter = new GeoServerServletConverter(getServletContext());
         myConverter.setTarget(createRoot());
     }
 
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to