]> source.dussan.org Git - archiva.git/commitdiff
Reducing compiler warnings
authorMartin Stockhammer <martin_s@apache.org>
Sun, 1 Apr 2018 17:40:26 +0000 (19:40 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 1 Apr 2018 17:40:26 +0000 (19:40 +0200)
14 files changed:
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexContext.java
archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/search/MavenRepositorySearch.java
archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/archiva/proxy/DefaultRepositoryProxyConnectors.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/MockWagon.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/index/mock/MavenIndexContextMock.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java

index 4cc234a1070003387e3734729154f8530ccecfc0..209f75ad5db388e8d81154607c502da97c9bd8a8 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.commons.lang.StringUtils;
  *
  */
 public class ProxyConnectorSelectionPredicate
-    implements Predicate
+    implements Predicate<ProxyConnectorConfiguration>
 {
     private String sourceId;
 
@@ -42,7 +42,7 @@ public class ProxyConnectorSelectionPredicate
     }
 
     @Override
-    public boolean evaluate( Object object )
+    public boolean evaluate( ProxyConnectorConfiguration object )
     {
         boolean satisfies = false;
 
index aef12a553b93394e1bbe6fc2caef4ea75f5dd28b..1689eeec95767ca00980000fbb4b314393d08de4 100644 (file)
@@ -213,17 +213,9 @@ public class MetadataUpdaterConsumer
                 log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) );
                 return;
             }
-
-            metadataTools.updateMetadata( this.repository, projectRef );
+            metadataTools.updateMetadata( this.repository, metadataPath );
             log.debug( "Updated metadata: {}", this.metadataTools.toPath( projectRef ) );
         }
-        catch ( LayoutException e )
-        {
-            log.warn( "Unable to convert path [{}] to an internal project reference: ", path, e );
-            triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
-                "Unable to convert path [" + path + "] to an internal project reference: "
-                    + e.getMessage( ) );
-        }
         catch ( RepositoryMetadataException e )
         {
             log.error( "Unable to write project metadat for artifact [{}]:", path, e );
@@ -236,13 +228,6 @@ public class MetadataUpdaterConsumer
             triggerConsumerWarning( TYPE_METADATA_IO,
                 "Project metadata not written due to IO warning: " + e.getMessage( ) );
         }
-        catch ( ContentNotFoundException e )
-        {
-            log.warn( "Project metadata not written because no versions were found to update: ", e );
-            triggerConsumerWarning( TYPE_METADATA_IO,
-                "Project metadata not written because no versions were found to update: "
-                    + e.getMessage( ) );
-        }
     }
 
     private void updateVersionMetadata( ArtifactReference artifact, String path )
@@ -265,16 +250,9 @@ public class MetadataUpdaterConsumer
                 return;
             }
 
-            metadataTools.updateMetadata( this.repository, versionRef );
+            metadataTools.updateMetadata( this.repository, metadataPath );
             log.debug( "Updated metadata: {}", this.metadataTools.toPath( versionRef ) );
         }
-        catch ( LayoutException e )
-        {
-            log.warn( "Unable to convert path [{}] to an internal version reference: ", path, e );
-            triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF,
-                "Unable to convert path [" + path + "] to an internal version reference: "
-                    + e.getMessage( ) );
-        }
         catch ( RepositoryMetadataException e )
         {
             log.error( "Unable to write version metadata for artifact [{}]: ", path, e );
@@ -287,13 +265,6 @@ public class MetadataUpdaterConsumer
             triggerConsumerWarning( TYPE_METADATA_IO,
                 "Version metadata not written due to IO warning: " + e.getMessage( ) );
         }
-        catch ( ContentNotFoundException e )
-        {
-            log.warn( "Version metadata not written because no versions were found to update: ", e );
-            triggerConsumerWarning( TYPE_METADATA_IO,
-                "Version metadata not written because no versions were found to update: "
-                    + e.getMessage( ) );
-        }
     }
 
     /*
index ce6dc280364198580d52300c80e3a485dc4994e9..f30bf6a4fba7affa43f1a264b2c95aa077e61912 100644 (file)
@@ -166,7 +166,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
 
             if ( needsMetadataUpdate )
             {
-                updateMetadata( artifactRef );
+                updateMetadata( path );
             }
         }
         catch ( LayoutException e )
@@ -183,57 +183,17 @@ public class CleanupReleasedSnapshotsRepositoryPurge
         }
     }
 
-    private void updateMetadata( ArtifactReference artifact )
+    private void updateMetadata( String path )
     {
-        VersionedReference versionRef = new VersionedReference( );
-        versionRef.setGroupId( artifact.getGroupId( ) );
-        versionRef.setArtifactId( artifact.getArtifactId( ) );
-        versionRef.setVersion( artifact.getVersion( ) );
-
-        ProjectReference projectRef = new ProjectReference( );
-        projectRef.setGroupId( artifact.getGroupId( ) );
-        projectRef.setArtifactId( artifact.getArtifactId( ) );
 
         try
         {
-            metadataTools.updateMetadata( repository, versionRef );
-        }
-        catch ( ContentNotFoundException e )
-        {
-            // Ignore. (Just means we have no snapshot versions left to reference).
+            metadataTools.updateMetadata( repository, path );
         }
         catch ( RepositoryMetadataException e )
-        {
-            // Ignore. 
-        }
-        catch ( IOException e )
-        {
-            // Ignore. 
-        }
-        catch ( LayoutException e )
         {
             // Ignore.
         }
 
-        try
-        {
-            metadataTools.updateMetadata( repository, projectRef );
-        }
-        catch ( ContentNotFoundException e )
-        {
-            // Ignore. (Just means we have no snapshot versions left to reference).
-        }
-        catch ( RepositoryMetadataException e )
-        {
-            // Ignore. 
-        }
-        catch ( IOException e )
-        {
-            // Ignore. 
-        }
-        catch ( LayoutException e )
-        {
-            // Ignore.
-        }
     }
 }
index 37f602f795d673a0fa4aa5a380ad48aa89fca265..e031922fb042fad9f98232712244298944f3fa75 100644 (file)
@@ -108,6 +108,7 @@ public class MavenIndexContext implements ArchivaIndexingContext {
         return IndexingContext.class.equals(clazz);
     }
 
+    @SuppressWarnings( "unchecked" )
     @Override
     public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException {
         if (IndexingContext.class.equals(clazz)) {
index 5d0698fb6f97bde42701401e7b93d6d53d44a323..6a7c9fd8364efec1a55d4165388cdce4bb8784ab 100644 (file)
@@ -145,6 +145,7 @@ public class MavenRepositorySearch
     /**
      * @see RepositorySearch#search(String, SearchFields, SearchResultLimits)
      */
+    @SuppressWarnings( "deprecation" )
     @Override
     public SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits )
         throws RepositorySearchException
@@ -325,7 +326,7 @@ public class MavenRepositorySearch
 
             FlatSearchResponse response = indexer.searchFlat( request );
 
-            if ( response == null || response.getTotalHits() == 0 )
+            if ( response == null || response.getTotalHitsCount() == 0 )
             {
                 SearchResults results = new SearchResults();
                 results.setLimits( limits );
index ebb5463a3b730507f811db2ec84d1258b0e28e4b..94fb690ae30dbb2cfb8d9511a51f83184361ed46 100644 (file)
@@ -144,7 +144,7 @@ public class DefaultRepositoryProxyConnectors
 
     @Inject
     @Named(value = "archivaTaskScheduler#repository")
-    private ArchivaTaskScheduler scheduler;
+    private ArchivaTaskScheduler<RepositoryTask> scheduler;
 
     @Inject
     private RepositoryRegistry repositoryRegistry;
index 52943c1c04c03ac0b0d5c67452007b26b3296d94..18cf3a3a01110f12caebf1f19f9d8208c6092d0f 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.archiva.configuration.ProxyConnectorConfiguration;
 import org.apache.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
 import org.apache.archiva.metadata.model.facets.AuditEvent;
 import org.apache.archiva.repository.RepositoryRegistry;
-import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
@@ -205,7 +205,7 @@ public class DefaultProxyConnectorAdmin
         }
 
         ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId );
-        return (ProxyConnectorConfiguration) CollectionUtils.find( configuration.getProxyConnectors(), selectedProxy );
+        return IterableUtils.find( configuration.getProxyConnectors(), selectedProxy );
     }
 
     protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector )
index 6148fe58eac2463005c8ddef4cf4729f3ff8a770..2537a62ab9b7c4ad19f911ede5862a617d2018e9 100644 (file)
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.archiva.consumers.RepositoryContentConsumer;
 import org.apache.archiva.repository.BasicManagedRepository;
 import org.apache.archiva.repository.BasicRemoteRepository;
 import org.apache.archiva.repository.ManagedRepository;
@@ -59,6 +60,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.function.Function;
 
 import static org.easymock.EasyMock.*;
 
@@ -347,16 +349,20 @@ public class RepositoryContentConsumersTest
         return path;
     }
 
-    private static Map convertToMap( List objects )
+    private static <T> Map<String, T> convertToMap( List<T> objects)
     {
-        HashMap map = new HashMap();
-        for ( Object o : objects )
+        HashMap<String,T> map = new HashMap<>();
+        for ( T o : objects )
         {
-            map.put( o, o );
+            map.put( o.toString(), o );
         }
         return map;
     }
 
+    private static <T> Function<List<T>,Map<String,T>> getConversionFunction(Class<T> type) {
+        return ts -> convertToMap( ts );
+    }
+
     public class MockApplicationContext
         implements ApplicationContext
     {
@@ -445,23 +451,25 @@ public class RepositoryContentConsumersTest
             throw new UnsupportedOperationException( "Not supported yet." );
         }
 
+        @SuppressWarnings( "unchecked" )
         @Override
-        public Map getBeansOfType( Class type )
+        public <T> Map<String, T> getBeansOfType( Class<T> type )
             throws BeansException
         {
-            if ( type == KnownRepositoryContentConsumer.class )
-            {
-                return convertToMap( knownRepositoryContentConsumer );
+            List<T> list = null;
+            if (type == KnownRepositoryContentConsumer.class) {
+                list = (List<T>) knownRepositoryContentConsumer;
+            } else if (type == InvalidRepositoryContentConsumer.class) {
+                list = (List<T>) invalidRepositoryContentConsumers;
             }
-            if ( type == InvalidRepositoryContentConsumer.class )
-            {
-                return convertToMap( invalidRepositoryContentConsumers );
+            if (list!=null) {
+                return getConversionFunction( type ).apply( list );
             }
             throw new UnsupportedOperationException( "Should not have been called" );
         }
 
         @Override
-        public Map getBeansOfType( Class type, boolean includeNonSingletons, boolean allowEagerInit )
+        public <T> Map<String, T> getBeansOfType( Class<T> type, boolean includeNonSingletons, boolean allowEagerInit )
             throws BeansException
         {
             throw new UnsupportedOperationException( "Not supported yet." );
@@ -487,7 +495,7 @@ public class RepositoryContentConsumersTest
         }
 
         @Override
-        public Object getBean( String name, Class requiredType )
+        public <T> T getBean( String name, Class<T> requiredType )
             throws BeansException
         {
             throw new UnsupportedOperationException( "Not supported yet." );
index 66e6e5efb8665b15ec100bb7f7c4d1e4ed2591b0..170140dcc626b04984c23bee23e8dc6fe5ceb97f 100644 (file)
               org.apache.archiva.scheduler;version=${project.version},
               org.apache.commons.io;version="[1.4,2)",
               org.apache.commons.lang*;version="[2.4,3)",
-              org.apache.lucene*;version="[3,4)",
               org.springframework*;version="[3,4)",
               org.apache.archiva.redback.components.taskqueue*,
               org.apache.maven.index*,
index a9ccb8db34afd4a8649fb1b2ed20d3cf3a6fab22..02c4125a409876526dd0ffddd9ccbca873d68474 100644 (file)
@@ -68,7 +68,7 @@ public class TemporaryGroupIndexSessionCleaner
     @Override
     public void sessionDestroyed( HttpSessionEvent httpSessionEvent )
     {
-        Map<String, TemporaryGroupIndex> tempFilesPerKey =
+        @SuppressWarnings( "unchecked" ) Map<String, TemporaryGroupIndex> tempFilesPerKey =
             (Map<String, TemporaryGroupIndex>) httpSessionEvent.getSession().getAttribute(
                 TEMPORARY_INDEX_SESSION_KEY );
 
index d5f323c5e5ab069bd68dd75937d27c346efd38f4..e0db09597d7e45a0756b2b48ab1230ab9d49890f 100644 (file)
@@ -108,6 +108,7 @@ public class MavenIndexContextMock implements ArchivaIndexingContext {
         return IndexingContext.class.equals(clazz);
     }
 
+    @SuppressWarnings( "unchecked" )
     @Override
     public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException {
         if (IndexingContext.class.equals(clazz)) {
index 8731c7c5a43e635dc950aa59136fb7cd3324b623..9030f6581fb9e155b4496ce16f978b5416b9212c 100644 (file)
@@ -154,11 +154,11 @@ public class MavenRepositoryProviderTest
         repo.setUrl( "https://repo.maven.apache.org/maven2/test" );
         repo.setDownloadRemoteIndex( true );
         repo.setDownloadRemoteIndexOnStartup( true );
-        Map header = new HashMap(  );
+        Map<String,String> header = new HashMap<>(  );
         header.put("header1","value1");
         header.put("header2","value2");
         repo.setExtraHeaders( header );
-        Map params = new HashMap(  );
+        Map<String,String> params = new HashMap<>(  );
         params.put("param1","pval1");
         params.put("param2","pval2");
         repo.setExtraParameters( params );
index e1be3e4490cc5fc48dd8ce01cca08034fd1f5070..5271cc63eb967180aa77fee715b6bf624c1ff7ff 100644 (file)
@@ -60,6 +60,7 @@ import static org.junit.Assert.*;
 /**
  * MetadataToolsTest
  */
+@SuppressWarnings( "deprecation" )
 @ContextConfiguration (
     { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
 public class MetadataToolsTest