You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/06/14 18:11:04 UTC

svn commit: r1135673 - /directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java

Author: elecharny
Date: Tue Jun 14 16:11:04 2011
New Revision: 1135673

URL: http://svn.apache.org/viewvc?rev=1135673&view=rev
Log:
Fixed the port selection : the MINA availablePortFinder is buggy, and does not return a free port.

Modified:
    directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java

Modified: directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java?rev=1135673&r1=1135672&r2=1135673&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java Tue Jun 14 16:11:04 2011
@@ -18,8 +18,10 @@
  */
 package org.apache.directory.server.factory;
 
+import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.net.ServerSocket;
 
 import org.apache.directory.server.annotations.CreateKdcServer;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -63,9 +65,17 @@ public class ServerAnnotationProcessor
                 int backlog = transportBuilder.backlog();
                 String address = transportBuilder.address();
                 
-                if ( port == -1 )
+                if ( port <= 0 )
                 {
-                    port = AvailablePortFinder.getNextAvailable( createdPort );
+                    try
+                    {
+                        port = new ServerSocket(0).getLocalPort();
+                    }
+                    catch ( IOException ioe )
+                    {
+                        // Don't know what to do here...
+                    }
+                    
                     createdPort = port + 1;
                 }