Search in sources :

Example 1 with MetadataTransferException

use of org.eclipse.aether.transfer.MetadataTransferException in project fabric8 by jboss-fuse.

the class AetherBasedResolver method isRetryableException.

@Override
public RetryChance isRetryableException(Exception exception) {
    RetryChance retry = RetryChance.NEVER;
    RepositoryException aetherException = findAetherException(exception);
    if (aetherException instanceof ArtifactResolutionException) {
        // aggregate case - exception that contains exceptions - usually per repository
        ArtifactResolutionException resolutionException = (ArtifactResolutionException) aetherException;
        if (resolutionException.getResult() != null) {
            for (Exception ex : resolutionException.getResult().getExceptions()) {
                RetryChance singleRetry = isRetryableException(ex);
                if (retry.chance() < singleRetry.chance()) {
                    retry = singleRetry;
                }
            }
        }
    } else if (aetherException != null) {
        // single exception case
        if (aetherException instanceof ArtifactNotFoundException) {
            // very little chance we'll find the artifact next time
            retry = RetryChance.NEVER;
        } else if (aetherException instanceof MetadataNotFoundException) {
            retry = RetryChance.NEVER;
        } else if (aetherException instanceof ArtifactTransferException || aetherException instanceof MetadataTransferException) {
            // we could try again
            Throwable root = rootException(aetherException);
            if (root instanceof SocketTimeoutException) {
                // we could try again - but without assuming we'll succeed eventually
                retry = RetryChance.LOW;
            } else if (root instanceof ConnectException) {
                // "connection refused" - not retryable
                retry = RetryChance.NEVER;
            } else if (root instanceof NoRouteToHostException) {
                // not retryable
                retry = RetryChance.NEVER;
            }
        } else {
            // general aether exception - let's fallback to NEVER, as retryable cases should be
            // handled explicitly
            retry = RetryChance.NEVER;
        }
    } else {
        // we don't know about non-aether exceptions, so let's allow
        retry = RetryChance.UNKNOWN;
    }
    return retry;
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) MetadataNotFoundException(org.eclipse.aether.transfer.MetadataNotFoundException) ArtifactTransferException(org.eclipse.aether.transfer.ArtifactTransferException) SocketTimeoutException(java.net.SocketTimeoutException) MetadataTransferException(org.eclipse.aether.transfer.MetadataTransferException) RepositoryException(org.eclipse.aether.RepositoryException) ArtifactNotFoundException(org.eclipse.aether.transfer.ArtifactNotFoundException) NoRouteToHostException(java.net.NoRouteToHostException) DependencyCollectionException(org.eclipse.aether.collection.DependencyCollectionException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) ArtifactNotFoundException(org.eclipse.aether.transfer.ArtifactNotFoundException) RepositoryException(org.eclipse.aether.RepositoryException) VersionRangeResolutionException(org.eclipse.aether.resolution.VersionRangeResolutionException) MetadataTransferException(org.eclipse.aether.transfer.MetadataTransferException) NoRouteToHostException(java.net.NoRouteToHostException) ArtifactTransferException(org.eclipse.aether.transfer.ArtifactTransferException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) DependencyResolutionException(org.eclipse.aether.resolution.DependencyResolutionException) MalformedURLException(java.net.MalformedURLException) MetadataNotFoundException(org.eclipse.aether.transfer.MetadataNotFoundException) InvalidVersionSpecificationException(org.eclipse.aether.version.InvalidVersionSpecificationException) ConnectException(java.net.ConnectException)

Aggregations

IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 MalformedURLException (java.net.MalformedURLException)1 NoRouteToHostException (java.net.NoRouteToHostException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 RepositoryException (org.eclipse.aether.RepositoryException)1 DependencyCollectionException (org.eclipse.aether.collection.DependencyCollectionException)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 DependencyResolutionException (org.eclipse.aether.resolution.DependencyResolutionException)1 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)1 ArtifactNotFoundException (org.eclipse.aether.transfer.ArtifactNotFoundException)1 ArtifactTransferException (org.eclipse.aether.transfer.ArtifactTransferException)1 MetadataNotFoundException (org.eclipse.aether.transfer.MetadataNotFoundException)1 MetadataTransferException (org.eclipse.aether.transfer.MetadataTransferException)1 InvalidVersionSpecificationException (org.eclipse.aether.version.InvalidVersionSpecificationException)1