use of org.eclipse.aether.transfer.ArtifactNotFoundException 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;
}
use of org.eclipse.aether.transfer.ArtifactNotFoundException in project fabric8 by jboss-fuse.
the class AetherResolutionWithHintsTest method hintedResolution.
@Test
public void hintedResolution() throws Exception {
final MavenConfigurationImpl mavenConfiguration = mavenConfiguration();
mavenConfiguration.setSettings(settingsWithProxy());
MavenResolver resolver = new AetherBasedResolver(mavenConfiguration);
try {
resolver.download("mvn:org.ops4j.pax.web/pax-web-api/1");
fail("Resolution should fail");
} catch (IOException e) {
RepositoryException exception = ((AetherBasedResolver) resolver).findAetherException(e);
assertNotNull(exception);
assertTrue(exception instanceof ArtifactResolutionException);
ArtifactResolutionException are = (ArtifactResolutionException) exception;
assertThat(are.getResult().getExceptions().size(), equalTo(3));
assertTrue("Non-retryable exception", are.getResult().getExceptions().get(0) instanceof ArtifactNotFoundException);
assertTrue("Non-retryable exception", are.getResult().getExceptions().get(1) instanceof ArtifactNotFoundException);
assertTrue("Retryable exception", are.getResult().getExceptions().get(2) instanceof ArtifactTransferException);
assertFalse("Retryable exception", are.getResult().getExceptions().get(2) instanceof ArtifactNotFoundException);
try {
// try again with exception hint
resolver.download("mvn:org.ops4j.pax.web/pax-web-api/1", e);
fail("Resolution should fail");
} catch (IOException e2) {
exception = ((AetherBasedResolver) resolver).findAetherException(e2);
assertNotNull(exception);
assertTrue(exception instanceof ArtifactResolutionException);
are = (ArtifactResolutionException) exception;
assertThat(are.getResult().getExceptions().size(), equalTo(1));
assertTrue("Retryable exception", are.getResult().getExceptions().get(0) instanceof ArtifactTransferException);
assertFalse("Retryable exception", are.getResult().getExceptions().get(0) instanceof ArtifactNotFoundException);
}
} finally {
resolver.close();
}
}
use of org.eclipse.aether.transfer.ArtifactNotFoundException in project mule by mulesoft.
the class DefaultRepositoryService method lookupBundle.
@Override
public File lookupBundle(BundleDependency bundleDependency) {
try {
if (remoteRepositories.isEmpty()) {
throw new RepositoryServiceDisabledException("Repository service has not been configured so it's disabled. " + "To enable it you must configure the set of repositories to use using the system property: " + MULE_REMOTE_REPOSITORIES_PROPERTY);
}
DefaultArtifact artifact = toArtifact(bundleDependency);
ArtifactRequest getArtifactRequest = new ArtifactRequest();
getArtifactRequest.setRepositories(remoteRepositories);
getArtifactRequest.setArtifact(artifact);
ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, getArtifactRequest);
return artifactResult.getArtifact().getFile();
} catch (ArtifactResolutionException e) {
if (e.getCause() instanceof ArtifactNotFoundException) {
throw new BundleNotFoundException(e);
} else {
throw new RepositoryConnectionException("There was a problem connecting to one of the repositories", e);
}
}
}
Aggregations