directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1703578 - in /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api: LdapConnectionConfig.java LdapNetworkConnection.java
Date Thu, 17 Sep 2015 11:26:51 GMT
Author: elecharny
Date: Thu Sep 17 11:26:51 2015
New Revision: 1703578

URL: http://svn.apache.org/r1703578
Log:
o Using InetAddress.getLocalHost().getHostName() instead of "localhost'

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java?rev=1703578&r1=1703577&r2=1703578&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionConfig.java
Thu Sep 17 11:26:51 2015
@@ -22,6 +22,7 @@ package org.apache.directory.ldap.client
 
 
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
@@ -55,19 +56,7 @@ public class LdapConnectionConfig
     public static final int DEFAULT_LDAPS_PORT = 636;
 
     /** The default host : localhost */
-    public static String DEFAULT_LDAP_HOST;
-    
-    static
-    {
-        try
-        {
-            DEFAULT_LDAP_HOST = InetAddress.getLocalHost().getHostName();//"127.0.0.1";
-        }
-        catch ( Exception e )
-        {
-            
-        }
-    }
+    public static final String DEFAULT_LDAP_HOST = "localhost";
 
     /** The LDAP version */
     public static final int LDAP_V3 = 3;
@@ -309,7 +298,14 @@ public class LdapConnectionConfig
      */
     public String getDefaultLdapHost()
     {
-        return DEFAULT_LDAP_HOST;
+        try
+        {
+            return InetAddress.getLocalHost().getHostName();
+        }
+        catch ( UnknownHostException uhe )
+        {
+            return DEFAULT_LDAP_HOST;
+        }
     }
 
 

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1703578&r1=1703577&r2=1703578&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Thu Sep 17 11:26:51 2015
@@ -26,8 +26,10 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.ConnectException;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
+import java.net.UnknownHostException;
 import java.nio.channels.UnresolvedAddressException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -491,7 +493,15 @@ public class LdapNetworkConnection exten
         // Default to localhost if null
         if ( Strings.isEmpty( server ) )
         {
-            config.setLdapHost( "localhost" );
+            try
+            {
+                config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+            }
+            catch ( UnknownHostException uhe )
+            {
+                config.setLdapHost( "localhost" );
+            }
+            
         }
         else
         {



Mime
View raw message