You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2016/09/30 19:49:49 UTC
svn commit: r1762959 -
/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java
Author: seelmann
Date: Fri Sep 30 19:49:49 2016
New Revision: 1762959
URL: http://svn.apache.org/viewvc?rev=1762959&view=rev
Log:
Simplify code, don't throw exception to control flow
Modified:
directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java
Modified: directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java?rev=1762959&r1=1762958&r2=1762959&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java (original)
+++ directory/studio/trunk/plugins/ldapservers/src/main/java/org/apache/directory/studio/ldapservers/LdapServersUtils.java Fri Sep 30 19:49:49 2016
@@ -68,6 +68,12 @@ public class LdapServersUtils
*/
public static void runStartupListenerWatchdog( LdapServer server, int port ) throws Exception
{
+ // If no protocol is enabled, we pass this and declare the server as started
+ if ( port == 0 )
+ {
+ return;
+ }
+
// Getting the current time
long startTime = System.currentTimeMillis();
@@ -77,37 +83,12 @@ public class LdapServersUtils
// Looping until the end of the watchdog if the server is still 'starting'
while ( ( System.currentTimeMillis() < watchDog ) && ( LdapServerStatus.STARTING == server.getStatus() ) )
{
- // Getting the port to test
- try
- {
- // If no protocol is enabled, we pass this and
- // declare the server as started
- if ( port != 0 )
- {
- // Trying to see if the port is available
- if ( AvailablePortFinder.available( port ) )
- {
- // The port is still available
- throw new Exception();
- }
- }
-
- // If we pass the creation of the context, it means
- // the server is correctly started
-
- // We set the state of the server to 'started'...
- server.setStatus( LdapServerStatus.STARTED );
-
- // ... and we exit the thread
- return;
- }
- catch ( Exception e )
+ // Trying to see if the port is available
+ if ( AvailablePortFinder.available( port ) )
{
- // If we get an exception, it means the server is not
- // yet started
+ // The port is still available
- // We just wait one second before starting the test once
- // again
+ // We just wait one second before starting the test once again
try
{
Thread.sleep( 1000 );
@@ -117,6 +98,15 @@ public class LdapServersUtils
// Nothing to do...
}
}
+ else
+ {
+ // We set the state of the server to 'started'...
+ server.setStatus( LdapServerStatus.STARTED );
+
+ // ... and we exit the thread
+ return;
+
+ }
}
// If, at the end of the watch dog, the state of the server is