This is an automated email from the ASF dual-hosted git repository.
martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva.git
The following commit(s) were added to refs/heads/master by this push:
new ed06b9d Making ldapconnection autocloseable
ed06b9d is described below
commit ed06b9d673a72ab9bb52297243a629dbb4f900a3
Author: Martin Stockhammer <[email protected]>
AuthorDate: Sun Jan 17 11:10:34 2021 +0100
Making ldapconnection autocloseable
---
.../DefaultRedbackRuntimeConfigurationService.java | 23 ++++++++++++++++++++--
.../v2/DefaultSecurityConfigurationService.java | 19 ++++++++++++++++--
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 060de9b..81b58aa 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 d5a435b..c8f9c60 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 );
+ }
}
}