abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r628400 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
Date Sun, 17 Feb 2008 01:16:05 GMT
Author: dandiep
Date: Sat Feb 16 17:16:01 2008
New Revision: 628400

URL: http://svn.apache.org/viewvc?rev=628400&view=rev
Log:
Turns out you can't always reset a connection. This seems like a slightly better thing to
do, but I'm open to suggestions.

"""
SEVERE: Servlet.service() for servlet Abdera threw exception
java.lang.IllegalStateException
    at org.apache.catalina.connector.ResponseFacade.reset(ResponseFacade.java:310)
    at javax.servlet.ServletResponseWrapper.reset(ServletResponseWrapper.java:183)
    at org.apache.abdera.protocol.server.servlet.AbderaServlet.error(AbderaServlet.java:141)
    at org.apache.abdera.protocol.server.servlet.AbderaServlet.service(AbderaServlet.java:96)
"""

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java?rev=628400&r1=628399&r2=628400&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
Sat Feb 16 17:16:01 2008
@@ -138,17 +138,28 @@
     Throwable t, 
     HttpServletResponse response) 
       throws IOException {
-    if (response.isCommitted()) response.reset();
+    boolean reset = false;
+    if (response.isCommitted()) {
+      try {
+        response.reset();
+        reset = true;
+      } catch (Throwable resetT) {
+        log.error("Could not reset connection to write an error message.", resetT);
+      }
+    }
     if (t != null) log.error(message, t);
     else log.error(message);
-    response.setStatus(500);
-    StreamWriter sw = 
-      getAbdera().newStreamWriter()
-                 .setOutputStream(
-                   response.getOutputStream(),
-                   "UTF-8");
-    Error.create(sw, 500, message,t);
-    sw.close();
+    
+    if (reset) {
+      response.setStatus(500);
+      StreamWriter sw = 
+        getAbdera().newStreamWriter()
+                   .setOutputStream(
+                     response.getOutputStream(),
+                     "UTF-8");
+      Error.create(sw, 500, message,t);
+      sw.close();
+    }
   }
   
   protected Map<String,String> getProperties(ServletConfig config) {



Mime
View raw message