Hello

Recently I worked a bit on pax-url-aether and among other fixes (like
timeout configuration or improved error reporting), I added 2nd variant of
org.ops4j.pax.url.mvn.MavenResolver.resolve() methods - an exception can be
passed as additional argument which should be treated as _hint_.
This _hint_ may be used to tell the resolver that it's not the first time
we're trying to resolve Maven artifact and this passed exception _may_ be
used to optimize 2nd and further resolution.

Currently pax-url-aether 2.5.0 does some checks - is it (or is caused by)
AetherException? is the exception related to currently resolved artifact?
If these conditions match, optimization is done to narrow list of remote
repositories being queried (again).

Before pax-url-aether 2.5.0 remote repositories are normally taken from
org.ops4j.pax.url.mvn.repositories property (possibly adjusted with repos
from active profiles from current Maven settings.xml). But if
AetherException says that some of the repositories returned simple
ArtifactNotFoundException, there's good chance that the artifact won't
appear in such repository in next few seconds. So such repository is
discarded.

Without going into details, here's @Test that presents this behavior:
https://github.com/ops4j/org.ops4j.pax.url/blob/url-2.5.0/
pax-url-aether/src/test/java/org/ops4j/pax/url/mvn/internal/
AetherResolutionWithHintsTest.java#L83.

OK. Back to Karaf. Karaf4 uses AbstractRetryableDownloadTask and
Maven-related subclass. In this line
<https://github.com/apache/karaf/blob/karaf-4.0.7/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/AbstractRetryableDownloadTask.java#L61>,
when exception occurs the download is retried - without checking if there's
a chance of success. The retry mechanism was designed with OSGi dynamics in
mind and assumption that if something doesn't work now, it may work in few
seconds.

But if download fails because we're getting "connection refused" or "no
route to host" I don't think it's wise to repeat the download process.

I created JIRA issue https://issues.apache.org/jira/browse/KARAF-4773 and
attached PR, where download attempt is retried based on some criteria. And
MavenDownloadTask (karaf) asks MavenResolver (pax-url-aether 2.5.0) if the
exception is actually retryable.

pax-url-aether/AetherBAsedResolvet assumes that errors like "socket
timeout" are retryable and gives abstract hint called "RetryChance.LOW".
Karaf's AbstractRetryableDownloadTask than knows that it may try repeating
the download few times, but not default "9" times.

There are tests that show optimized network access and new timeout
configuration from pax-url-aether 2.5.0 ensures that timeouts are really
enforced. Thus Maven handling in Karaf 4 should actually improve.

Please add comments if needed or if I missed something from my design.

regards
Grzegorz Grzybek

Reply via email to