Maven virtual registry: allow digests request without a file in the cache
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
🔥 Problem
The Maven virtual registry expects a specific requests order for a given file:
- The file itself (
.jarfor example). - The digests of the file. We could have multiple requests here (
.md5or.sha1for example).
As such, the cache entry is created for (1.) but not for (2.) because the expectation was that (1.) was always the first request to hit the virtual registry.
Well, that is not entirely true.
Under some conditions (for example, the file already exists in the local cache ~/.m2/repository), maven clients can decide to re-use that file but verify the integrity. To do so, they will skip (1.) and go for (2.) directly.
The virtual registry will answer 404 not found as (1.) was not executed first = the cache entry doesn't exist = we can't locate the requested digest.
🚒 Solution
Requesting a digest, such as .md5 should:
- walk the list of upstreams and locate where the file is.
- return the digest to the requesting client.
- cache the actual file. By doing so, all the digests will become available.
Example:
The virtual registry receives a request to /my_package.pom.md5. We need to:
- locate the upstream that has the
my_package.pomfile. - download and return the
my_package.pom.md5contents to the client. - download and cache the
my_package.pomfile. By doing so, all the digests of this file will be created in the cache too.
(1.) is the current logic that walks the list of upstreams. (2.) can be taken care by workhorse (sendurl instruction). (3.) could be done in a background job.