mirror of https://github.com/apache/archiva.git
Making ldapconnection autocloseable
This commit is contained in:
parent
d3b81be613
commit
ed06b9d673
|
@ -47,6 +47,7 @@ import org.springframework.stereotype.Service;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.InvalidNameException;
|
||||
import javax.naming.NamingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -320,7 +321,14 @@ public class DefaultRedbackRuntimeConfigurationService
|
|||
|
||||
if ( ldapConnection != null )
|
||||
{
|
||||
ldapConnection.close();
|
||||
try
|
||||
{
|
||||
ldapConnection.close();
|
||||
}
|
||||
catch ( NamingException e )
|
||||
{
|
||||
log.error( "Could not close connection: {}", e.getMessage( ), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,12 +378,23 @@ public class DefaultRedbackRuntimeConfigurationService
|
|||
log.warn( "fail to get ldapConnection: {}", e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( e.getMessage(), e );
|
||||
}
|
||||
catch ( NamingException e )
|
||||
{
|
||||
log.error( "Could not close connection: {}", e.getMessage( ), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
if ( ldapConnection != null )
|
||||
{
|
||||
ldapConnection.close();
|
||||
try
|
||||
{
|
||||
ldapConnection.close();
|
||||
}
|
||||
catch ( NamingException e )
|
||||
{
|
||||
log.error( "Could not close connection: {}", e.getMessage( ), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ import javax.naming.AuthenticationException;
|
|||
import javax.naming.AuthenticationNotSupportedException;
|
||||
import javax.naming.CommunicationException;
|
||||
import javax.naming.InvalidNameException;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.NoPermissionException;
|
||||
import javax.naming.ServiceUnavailableException;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -512,7 +513,14 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
|
|||
{
|
||||
if ( ldapConnection != null )
|
||||
{
|
||||
ldapConnection.close( );
|
||||
try
|
||||
{
|
||||
ldapConnection.close( );
|
||||
}
|
||||
catch ( NamingException e )
|
||||
{
|
||||
log.error( "Could not close connection: {}", e.getMessage( ) );
|
||||
}
|
||||
}
|
||||
ldapConnection = null;
|
||||
}
|
||||
|
@ -545,7 +553,14 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
|
|||
{
|
||||
if ( ldapConnection != null )
|
||||
{
|
||||
ldapConnection.close( );
|
||||
try
|
||||
{
|
||||
ldapConnection.close( );
|
||||
}
|
||||
catch ( NamingException e )
|
||||
{
|
||||
log.error( "Could not close connection: {}", e.getMessage( ), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue