mirror of https://github.com/apache/maven.git
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. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@331836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2747d1865d
commit
6f562d4c87
|
@ -80,11 +80,23 @@ public class DefaultRepositoryMetadataManager
|
|||
|
||||
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 @@ public class DefaultRepositoryMetadataManager
|
|||
{
|
||||
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 @@ public class DefaultRepositoryMetadataManager
|
|||
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 @@ public class DefaultRepositoryMetadataManager
|
|||
|
||||
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 @@ public class DefaultRepositoryMetadataManager
|
|||
getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" );
|
||||
getLogger().debug( "Exception", e );
|
||||
repository.setBlacklisted( allowBlacklisting );
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,6 +407,13 @@ public class DefaultRepositoryMetadataManager
|
|||
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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue