You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2005/11/08 17:25:25 UTC

svn commit: r331836 - /maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java

Author: jdcasey
Date: Tue Nov  8 08:25:20 2005
New Revision: 331836

URL: http://svn.apache.org/viewcvs?rev=331836&view=rev
Log:
PR: MNG-1320

o Modified private resolveAlways(..) method to throw TransferFailedException, after blacklisting the repository.

o Added handling for the new TransferFailedException as it's thrown from resolveAlways(..). In two cases, where it's not essential that the metadata be non-empty, this exception is ignored. I'm anticipating this will change for 2.1, but for now it's just marked TODO. In the final case (the one that prompted this MNG), the exception is used to inhibit writing of the empty metadata to the local repository when the transfer fails. NOTE: The metadata is still handled the same as before when the system encounters ResourceDoesNotExistException, to prevent re-checking the remote repo on every build.


Modified:
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java?rev=331836&r1=331835&r2=331836&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java (original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java Tue Nov  8 08:25:20 2005
@@ -80,11 +80,23 @@
 
                     boolean checkForUpdates = policy.checkOutOfDate( new Date( file.lastModified() ) ) || !file.exists();
 
+                    boolean metadataIsEmpty = true;
+                    
                     if ( checkForUpdates )
                     {
                         getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
 
-                        resolveAlways( metadata, repository, file, policy.getChecksumPolicy(), true );
+                        try
+                        {
+                            resolveAlways( metadata, repository, file, policy.getChecksumPolicy(), true );
+                            metadataIsEmpty = false;
+                        }
+                        catch ( TransferFailedException e )
+                        {
+                            // TODO: [jc; 08-Nov-2005] revisit this for 2.1
+                            // suppressing logging to avoid logging this error twice.
+                            metadataIsEmpty = true;
+                        }
                     }
 
                     // touch file so that this is not checked again until interval has passed
@@ -92,7 +104,7 @@
                     {
                         file.setLastModified( System.currentTimeMillis() );
                     }
-                    else
+                    else if ( !metadataIsEmpty )
                     {
                         // this ensures that files are not continuously checked when they don't exist remotely
                         try
@@ -293,7 +305,17 @@
         File file = new File( localRepository.getBasedir(),
                               localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
 
-        resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
+        try
+        {
+            resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
+        }
+        catch ( TransferFailedException e )
+        {
+            // TODO: [jc; 08-Nov-2005] revisit this for 2.1
+            // suppressing logging to avoid logging this error twice.
+            // We don't want to interrupt program flow here. Just allow empty metadata instead.
+            // rethrowing this would change behavior.
+        }
 
         try
         {
@@ -311,7 +333,7 @@
 
     private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file,
                                 String checksumPolicy, boolean allowBlacklisting )
-        throws RepositoryMetadataResolutionException
+        throws RepositoryMetadataResolutionException, TransferFailedException
     {
         if ( !wagonManager.isOnline() )
         {
@@ -350,6 +372,8 @@
             getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" );
             getLogger().debug( "Exception", e );
             repository.setBlacklisted( allowBlacklisting );
+            
+            throw e;
         }
     }
 
@@ -382,6 +406,13 @@
         {
             throw new RepositoryMetadataDeploymentException(
                 "Unable to get previous metadata to update: " + e.getMessage(), e );
+        }
+        catch ( TransferFailedException e )
+        {
+            // TODO: [jc; 08-Nov-2005] revisit this for 2.1
+            // suppressing logging to avoid logging this error twice.
+            // We don't want to interrupt program flow here. Just allow empty metadata instead.
+            // rethrowing this would change behavior.
         }
 
         try