cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r618856 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/
Date Wed, 06 Feb 2008 02:28:19 GMT
Author: dkulp
Date: Tue Feb  5 18:28:17 2008
New Revision: 618856

URL: http://svn.apache.org/viewvc?rev=618856&view=rev
Log:
Merged revisions 615027 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r615027 | dkulp | 2008-01-24 16:50:25 -0500 (Thu, 24 Jan 2008) | 2 lines
  
  [CXF-1403] Patch from Sergey Beryozkin applied.  Thanks!
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=618856&r1=618855&r2=618856&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Tue Feb  5 18:28:17 2008
@@ -159,6 +159,22 @@
     }
     
     @Test
+    public void testRandomPortAllocation() throws Exception {
+        transportFactory = new JettyHTTPTransportFactory();
+        transportFactory.setBus(new CXFBusImpl());
+        ServiceInfo serviceInfo = new ServiceInfo();
+        serviceInfo.setName(new QName("bla", "Service"));
+        EndpointInfo ei = new EndpointInfo(serviceInfo, "");
+        ei.setName(new QName("bla", "Port"));
+        
+        Destination d1 = transportFactory.getDestination(ei);
+        URL url = new URL(d1.getAddress().getAddress().getValue());
+        assertTrue("No random port has been allocated", 
+                   url.getPort() > 0);
+        
+    }
+    
+    @Test
     public void testGetMultiple() throws Exception {
         transportFactory = new JettyHTTPTransportFactory();
         transportFactory.setBus(new CXFBusImpl());

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=618856&r1=618855&r2=618856&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Tue Feb  5 18:28:17 2008
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
+import java.net.ServerSocket;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
@@ -70,7 +71,7 @@
     public static final String HTTP_RESPONSE = "HTTP.RESPONSE";
     public static final String HTTP_CONTEXT = "HTTP.CONTEXT";
     public static final String PROTOCOL_HEADERS_CONTENT_TYPE = Message.CONTENT_TYPE.toLowerCase();
-    
+        
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
     
     private static final long serialVersionUID = 1L;
@@ -232,6 +233,20 @@
     
     protected static EndpointInfo getAddressValue(EndpointInfo ei, boolean dp) {       
         if (dp) {
+            
+            String eiAddress = ei.getAddress();
+            if (eiAddress == null) {
+                try {
+                    ServerSocket s = new ServerSocket(0);
+                    ei.setAddress("http://localhost:" + s.getLocalPort());
+                    s.close();
+                    return ei;
+                } catch (IOException ex) {
+                    // problem allocating a random port, go to the default one
+                    ei.setAddress("http://localhost");
+                }
+            }
+            
             String addr = StringUtils.addDefaultPortIfMissing(ei.getAddress());
             if (addr != null) {
                 ei.setAddress(addr);



Mime
View raw message