]> source.dussan.org Git - archiva.git/commitdiff
minor changes master-maven-indexer-6.0.1 80/head
authorOlivier Lamy <olamy@apache.org>
Sun, 17 Apr 2022 11:12:38 +0000 (21:12 +1000)
committerOlivier Lamy <olamy@apache.org>
Sun, 17 Apr 2022 11:12:38 +0000 (21:12 +1000)
Signed-off-by: Olivier Lamy <olamy@apache.org>
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/ArchivaIndexManagerMock.java
archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/maven/indexer/search/MavenRepositorySearch.java
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/search/AbstractMavenRepositorySearch.java
archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/maven/indexer/search/MavenRepositorySearchTest.java
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/mock/ArchivaIndexManagerMock.java

index def27d1aac67f1909df26219676c6663deec6a3f..b549d0ef502c0196661127af4e915530ed832ed9 100644 (file)
@@ -176,7 +176,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
             active = activeContexts.add( ctxPath );
             try
             {
-                Thread.currentThread( ).sleep( WAIT_TIME );
+                Thread.currentThread().sleep(WAIT_TIME);
             }
             catch ( InterruptedException e )
             {
@@ -229,11 +229,12 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
             DefaultScannerListener listener = new DefaultScannerListener( indexingContext, indexerEngine, true, null );
             ScanningRequest request = new ScanningRequest( indexingContext, listener );
             ScanningResult result = scanner.scan( request );
-            if ( result.hasExceptions( ) )
+            if (result.hasExceptions() && log.isErrorEnabled())
             {
                 log.error( "Exceptions occured during index scan of " + context.getId( ) );
-                result.getExceptions( ).stream( ).map( e -> e.getMessage( ) ).distinct( ).limit( 5 ).forEach(
-                        s -> log.error( "Message: " + s )
+                result.getExceptions().stream().map(Throwable::getMessage)
+                        .distinct().limit(5)
+                        .forEach(s -> log.error("Message: {}", s)
                 );
             }
 
@@ -302,7 +303,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
                                 httpMethodConfiguration.setUsePreemptive( true );
                                 httpMethodConfiguration.setReadTimeout( readTimeout );
                                 httpConfiguration.setGet( httpMethodConfiguration );
-                                AbstractHttpClientWagon.class.cast( wagon ).setHttpConfiguration( httpConfiguration );
+                                ((AbstractHttpClientWagon)wagon).setHttpConfiguration(httpConfiguration );
                             }
 
                             wagon.addTransferListener( new DownloadListener( ) );
@@ -672,7 +673,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
     private static final class DownloadListener
             implements TransferListener
     {
-        private Logger log = LoggerFactory.getLogger( getClass( ) );
+        private final Logger log = LoggerFactory.getLogger( getClass( ) );
 
         private String resourceName;
 
@@ -763,7 +764,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
 
         @Override
         public InputStream retrieve(String name )
-                throws IOException, FileNotFoundException
+                throws IOException
         {
             try
             {
@@ -780,8 +781,8 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
             }
             catch ( ResourceDoesNotExistException e )
             {
-                FileNotFoundException fnfe = new FileNotFoundException( e.getMessage( ) );
-                fnfe.initCause( e );
+                FileNotFoundException fnfe = new FileNotFoundException(e.getMessage( ));
+                fnfe.initCause(e);
                 throw fnfe;
             }
         }
index 082ad7d16b9fa48e2c485705a864cee51f94f7d1..ca9008726a50aeb8ca32f04b1e809dffaafe8d11 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.archiva.maven.indexer.search;
 
 import org.apache.archiva.indexer.UnsupportedBaseContextException;
 import org.apache.archiva.indexer.search.ArtifactInfoFilter;
-import org.apache.archiva.maven.indexer.search.NoClassifierArtifactInfoFilter;
 import org.apache.archiva.indexer.search.RepositorySearch;
 import org.apache.archiva.indexer.search.RepositorySearchException;
 import org.apache.archiva.indexer.search.SearchFields;
@@ -73,7 +72,7 @@ import java.util.Set;
 public class MavenRepositorySearch
     implements RepositorySearch
 {
-    private Logger log = LoggerFactory.getLogger( getClass() );
+    private final Logger log = LoggerFactory.getLogger( getClass() );
 
     private Indexer indexer;
 
@@ -273,13 +272,13 @@ public class MavenRepositorySearch
             throw new RepositorySearchException( "No search fields set." );
         }
         if (qu.clauses()!=null) {
-            log.debug("CLAUSES ", qu.clauses());
+            log.debug("CLAUSES {}", qu.clauses());
             for (BooleanClause cl : qu.clauses()) {
-                log.debug("Clause ",cl);
+                log.debug("Clause {}",cl);
             }
         }
 
-        return search( limits, qu, indexingContextIds, Collections.<ArtifactInfoFilter>emptyList(),
+        return search( limits, qu, indexingContextIds, Collections.emptyList(),
                        searchFields.getRepositories(), searchFields.isIncludePomArtifacts() );
     }
 
@@ -435,10 +434,8 @@ public class MavenRepositorySearch
             {
                 log.warn( "RepositorySearchException occured while accessing index of repository '{}' : {}", repo,
                     e.getMessage() );
-                continue;
             } catch (UnsupportedBaseContextException e) {
                 log.error("Fatal situation: Maven repository without IndexingContext found.");
-                continue;
             }
         }
 
index 2514193e1390f9445f8ecfb78726995ed70abe1b..bdd76d218e96b7b51f87ef50863d5bcf1a776c17 100644 (file)
@@ -32,7 +32,6 @@ import org.apache.archiva.repository.base.ArchivaRepositoryRegistry;
 import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
 import org.apache.archiva.repository.features.IndexCreationFeature;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.index.ArtifactContext;
 import org.apache.maven.index.ArtifactContextProducer;
 import org.apache.maven.index.ArtifactScanningListener;
@@ -346,7 +345,7 @@ public abstract class AbstractMavenRepositorySearch
         StringBuilder sb = new StringBuilder();
         for ( SearchResultHit hit : searchResults.getHits() )
         {
-            sb.append( hit.toString() ).append( SystemUtils.LINE_SEPARATOR );
+            sb.append( hit.toString() ).append( System.lineSeparator() );
         }
         return sb.toString();
     }
index 0439a4defd087e0ec7859b41cb0f9e72480d71e6..767adb3075b9df7131590ceb1c3be5458515a917 100644 (file)
@@ -109,7 +109,7 @@ public class MavenRepositorySearchTest
     {
         createSimpleIndex( false );
 
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+        List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
 
         // search artifactId
         when( archivaConfig.getDefaultLocale() ).thenReturn( Locale.getDefault( ) );
@@ -685,7 +685,7 @@ public class MavenRepositorySearchTest
     {
         createIndexContainingMoreArtifacts( true );
 
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+        List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
 
         SearchFields searchFields = new SearchFields();
         searchFields.setClassName( "com.classname.search.App" );
@@ -733,7 +733,7 @@ public class MavenRepositorySearchTest
     {
         createIndexContainingMoreArtifacts( true );
 
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+        List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
 
         SearchFields searchFields = new SearchFields();
         searchFields.setClassName( "SomeClass" );
@@ -755,7 +755,7 @@ public class MavenRepositorySearchTest
     {
         createIndexContainingMoreArtifacts( true );
 
-        List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+        List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
 
         when( archivaConfig.getConfiguration() ).thenReturn( config );
 
@@ -775,7 +775,7 @@ public class MavenRepositorySearchTest
     {
         createIndexContainingMoreArtifacts( true );
 
-        List<String> selectedRepos = Arrays.asList( "foo" );
+        List<String> selectedRepos = Collections.singletonList("foo");
 
         SearchFields searchFields = new SearchFields();
         searchFields.setClassName( "SomeClass" );
@@ -821,7 +821,7 @@ public class MavenRepositorySearchTest
 
             SearchFields searchFields = new SearchFields();
             searchFields.setGroupId("org.example");
-            searchFields.setRepositories(Arrays.asList(REPO_RELEASE));
+            searchFields.setRepositories(Collections.singletonList(REPO_RELEASE));
 
             searchResults = search.search(null, searchFields, limits);
 
index 260543ba0380ae6378214c0e9535f4d0817218c1..fef24078b2e1f0cafa30e2e2437a6597843f48d3 100644 (file)
@@ -156,7 +156,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
      */
     private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException
     {
-        IndexingContext indexingContext = null;
+        IndexingContext indexingContext;
         try
         {
             indexingContext = getMvnContext( context );
@@ -226,11 +226,12 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
             DefaultScannerListener listener = new DefaultScannerListener( indexingContext, indexerEngine, true, null );
             ScanningRequest request = new ScanningRequest( indexingContext, listener );
             ScanningResult result = scanner.scan( request );
-            if ( result.hasExceptions( ) )
+            if (result.hasExceptions() && log.isErrorEnabled())
             {
-                log.error( "Exceptions occured during index scan of " + context.getId( ) );
-                result.getExceptions( ).stream( ).map( e -> e.getMessage( ) ).distinct( ).limit( 5 ).forEach(
-                        s -> log.error( "Message: " + s )
+                log.error("Exceptions occured during index scan of {}", context.getId());
+                result.getExceptions().stream()
+                        .map(Throwable::getMessage).distinct()
+                        .limit(5).forEach(s -> log.error( "Message: {}", s )
                 );
             }
 
@@ -659,7 +660,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
     private static final class DownloadListener
             implements TransferListener
     {
-        private Logger log = LoggerFactory.getLogger( getClass( ) );
+        private final Logger log = LoggerFactory.getLogger( getClass( ) );
 
         private String resourceName;