Author: ningjiang Date: Thu Mar 4 09:00:34 2010 New Revision: 918901 URL: http://svn.apache.org/viewvc?rev=918901&view=rev Log: CAMEL-2519 revert the patch of CAMEL-2519
Removed: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHandleExceptionTest.java Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=918901&r1=918900&r2=918901&view=diff ============================================================================== --- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original) +++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Thu Mar 4 09:00:34 2010 @@ -101,23 +101,17 @@ public void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException { if (exchange.isFailed()) { if (exchange.getException() != null) { - // need to check the response code header - int responseCode = 500; - if (exchange.hasOut()) { - responseCode = exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE, 500, int.class); - } else { // get the header from in message - responseCode = exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE, 500, int.class); - } - doWriteExceptionResponse(exchange.getException(), response, responseCode); + doWriteExceptionResponse(exchange.getException(), response); } else { // it must be a fault, no need to check for the fault flag on the message doWriteFaultResponse(exchange.getOut(), response, exchange); } } else { - if (exchange.hasOut()) { - // just copy the protocol relates header - copyProtocolHeaders(exchange.getIn(), exchange.getOut()); - doWriteResponse(exchange.getOut(), response, exchange); + // just copy the protocol relates header + copyProtocolHeaders(exchange.getIn(), exchange.getOut()); + Message out = exchange.getOut(); + if (out != null) { + doWriteResponse(out, response, exchange); } } } @@ -128,18 +122,9 @@ response.setHeader(Exchange.CONTENT_ENCODING, contentEncoding); } } - - /** - * Please use public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response, int responseCode) throws IOException - */ - @Deprecated - public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException { - // set the reponse code to be 500 - doWriteExceptionResponse(exception, response, 500); - } - public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response, int responseCode) throws IOException { - response.setStatus(responseCode); + public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException { + response.setStatus(500); // 500 for internal server error response.setContentType("text/plain"); // append the stacktrace as response Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java?rev=918901&r1=918900&r2=918901&view=diff ============================================================================== --- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java (original) +++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java Thu Mar 4 09:00:34 2010 @@ -73,11 +73,8 @@ // START SNIPPET: e1 public class MyHttpBinding extends DefaultHttpBinding { - // From camel 2.3.0, we added a new parameter responseCode into doWriteExceptionResponse method - // If the camel version is below camel 2.3.0, please still use below method - // public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException @Override - public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response, int responseCode) throws IOException { + public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException { // we override the doWriteExceptionResponse as we only want to alter the binding how exceptions is // written back to the client.