This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch archiva-2.x-gh-actions
in repository https://gitbox.apache.org/repos/asf/archiva.git
The following commit(s) were added to refs/heads/archiva-2.x-gh-actions by this
push:
new c8464a44a minor improvement
c8464a44a is described below
commit c8464a44a716c550ac4448ba036eb128f5cde020
Author: Olivier Lamy <[email protected]>
AuthorDate: Sun Apr 10 14:27:24 2022 +1000
minor improvement
Signed-off-by: Olivier Lamy <[email protected]>
---
.../managed/DefaultManagedRepositoryAdmin.java | 39 +++++-----------------
1 file changed, 8 insertions(+), 31 deletions(-)
diff --git
a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
index f398bca26..8f465b8c0 100644
---
a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
+++
b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java
@@ -78,7 +78,7 @@ public class DefaultManagedRepositoryAdmin
implements ManagedRepositoryAdmin
{
- private Logger log = LoggerFactory.getLogger( getClass() );
+ private final Logger log = LoggerFactory.getLogger( getClass() );
public static final String STAGE_REPO_ID_END = "-stage";
@@ -169,7 +169,7 @@ public class DefaultManagedRepositoryAdmin
return Collections.emptyList();
}
- List<ManagedRepository> managedRepos = new
ArrayList<ManagedRepository>( managedRepoConfigs.size() );
+ List<ManagedRepository> managedRepos = new ArrayList<>(
managedRepoConfigs.size() );
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
{
@@ -314,8 +314,7 @@ public class DefaultManagedRepositoryAdmin
}
catch ( Exception e )
{
- log.warn( new StringBuilder( "Unable to scan repository ["
).append( repoId ).append( "]: " ).append(
- e.getMessage() ).toString(), e );
+ log.warn("Unable to scan repository [" + repoId + "]: " +
e.getMessage(), e );
}
return repository;
@@ -377,18 +376,13 @@ public class DefaultManagedRepositoryAdmin
deleteContent &&
context.getIndexDirectoryFile().exists() );
}
}
- catch ( PlexusSisuBridgeException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- catch ( IOException e )
+ catch ( PlexusSisuBridgeException | IOException e )
{
throw new RepositoryAdminException( e.getMessage(), e );
}
if ( !stagedOne )
{
- RepositorySession repositorySession =
getRepositorySessionFactory().createSession();
- try
+ try (RepositorySession repositorySession =
getRepositorySessionFactory().createSession())
{
MetadataRepository metadataRepository =
repositorySession.getRepository();
metadataRepository.removeRepository( repository.getId() );
@@ -403,10 +397,6 @@ public class DefaultManagedRepositoryAdmin
//throw new RepositoryAdminException( e.getMessage(), e );
log.warn( "skip error during removing repository from
MetadataRepository:{}", e.getMessage(), e );
}
- finally
- {
- repositorySession.close();
- }
}
config.removeManagedRepository( repository );
@@ -514,9 +504,8 @@ public class DefaultManagedRepositoryAdmin
auditInformation,
getArchivaConfiguration().getConfiguration() );
// Save the repository configuration.
- RepositorySession repositorySession =
getRepositorySessionFactory().createSession();
- try
+ try (RepositorySession repositorySession =
getRepositorySessionFactory().createSession())
{
triggerAuditEvent( managedRepositoryConfiguration.getId(), null,
AuditEvent.MODIFY_MANAGED_REPO,
auditInformation );
@@ -535,10 +524,6 @@ public class DefaultManagedRepositoryAdmin
{
throw new RepositoryAdminException( e.getMessage(), e );
}
- finally
- {
- repositorySession.close();
- }
if ( updateIndexContext )
{
@@ -669,15 +654,7 @@ public class DefaultManagedRepositoryAdmin
}
return context;
}
- catch ( MalformedURLException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- catch ( IOException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- catch ( UnsupportedExistingLuceneIndexException e )
+ catch ( IOException | UnsupportedExistingLuceneIndexException e )
{
throw new RepositoryAdminException( e.getMessage(), e );
}
@@ -736,7 +713,7 @@ public class DefaultManagedRepositoryAdmin
}
catch ( TaskQueueException e )
{
- log.error( "failed to schedule scanning of repo with id {}",
repositoryId, e );
+ log.error( "failed to schedule scanning of repo with id " +
repositoryId, e );
return false;
}
return true;