diff options
author | Martin Stockhammer <martin_s@apache.org> | 2021-01-17 11:10:34 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2021-01-17 11:10:34 +0100 |
commit | ed06b9d673a72ab9bb52297243a629dbb4f900a3 (patch) | |
tree | b6a4226124ed23a0be0ffd887c5ce6b0aeed9370 /archiva-modules | |
parent | d3b81be6136f6086e493ebd4e4497ce87e85cc2c (diff) | |
download | archiva-ed06b9d673a72ab9bb52297243a629dbb4f900a3.tar.gz archiva-ed06b9d673a72ab9bb52297243a629dbb4f900a3.zip |
Making ldapconnection autocloseable
Diffstat (limited to 'archiva-modules')
2 files changed, 38 insertions, 4 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index 060de9ba3..81b58aa94 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -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 ); + } } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java index d5a435bf9..c8f9c6007 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java @@ -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 ); + } } } |