cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r746373 - in /cxf/trunk/rt/transports/http-jetty/src: main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Date Fri, 20 Feb 2009 21:43:20 GMT
Author: dkulp
Date: Fri Feb 20 21:43:19 2009
New Revision: 746373

URL: http://svn.apache.org/viewvc?rev=746373&view=rev
Log:
Fix race condition where a LARGE wsdl containing imports could cause the server to lockup.

Modified:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=746373&r1=746372&r2=746373&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Fri Feb 20 21:43:19 2009
@@ -37,6 +37,7 @@
 import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -228,26 +229,32 @@
                                                                        contextMatchOnExact())
                     : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                 if (recognized) {
-                    //replace the endpointInfo address with request url only for get wsdl
  
-                    synchronized (endpointInfo) {
-                        String oldAddress = updateEndpointAddress(reqAddr);   
-                        resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
-                        try {
-                            qh.writeResponse(requestURL, pathInfo, endpointInfo, resp.getOutputStream());
-                        } catch (Exception ex) {
-                            LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                    //replace the endpointInfo address with request url only for get wsdl
+                    String errorMsg = null;
+                    CachedOutputStream out = new CachedOutputStream();
+                    try {
+                        synchronized (endpointInfo) {
+                            String oldAddress = updateEndpointAddress(reqAddr);   
+                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
                             try {
-                                resp.sendError(500, ex.getMessage());
-                            } catch (IOException ioe) {
-                                //ignore
+                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
+                            } catch (Exception ex) {
+                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                                errorMsg = ex.getMessage();
                             }
+                            endpointInfo.setAddress(oldAddress);
                         }
-                        endpointInfo.setAddress(oldAddress);
-                        resp.getOutputStream().flush();                     
-                        baseRequest.setHandled(true);
-                        return;    
+                        if (errorMsg != null) {
+                            resp.sendError(500, errorMsg);
+                        } else {
+                            out.writeCacheTo(resp.getOutputStream());
+                            resp.getOutputStream().flush();                     
+                        }
+                    } finally {
+                        out.close();
                     }
-                    
+                    baseRequest.setHandled(true);
+                    return;
                 }
             }
         }

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=746373&r1=746372&r2=746373&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Fri Feb 20 21:43:19 2009
@@ -830,7 +830,10 @@
         EasyMock.expectLastCall().andReturn(true);   
         wsdlQueryHandler.getResponseContentType("http://localhost/bar/foo?wsdl", "/bar/foo");
         EasyMock.expectLastCall().andReturn("text/xml");
-        wsdlQueryHandler.writeResponse("http://localhost/bar/foo?wsdl", "/bar/foo", endpointInfo,
os);
+        wsdlQueryHandler.writeResponse(EasyMock.eq("http://localhost/bar/foo?wsdl"),
+                                       EasyMock.eq("/bar/foo"), 
+                                       EasyMock.eq(endpointInfo),
+                                       (OutputStream)EasyMock.anyObject());
         EasyMock.expectLastCall().once();
         EasyMock.replay(bus);
         EasyMock.replay(queryHandlerRegistry);



Mime
View raw message