gnodet commented on PR #2252:
URL: https://github.com/apache/maven-resolver/pull/2252#issuecomment-7376287498
## Detailed Code Review Comments
### 1. **EnhancedLocalRepositoryManager.java:161** - Logic correctness ✅
The OR condition for checking both old and new tracking formats is correct:
```java
if (props.get(getKey(file, getRepositoryKey(repository, context))) != null
|| props.get(getKey(file, getUrlQualifiedRepositoryKey(repository,
context))) != null)
```
This allows reading artifacts tracked by either Maven 3.9.x or Maven 3.10+.
### 2. **EnhancedLocalRepositoryManager.java:181-193** - Implementation
correctness ✅
The `getUrlQualifiedRepositoryKey` method correctly implements the
`nidAndHurlRepositoryKey` format from Resolver 2.x:
- Uses `PathUtils.stringToPathSegment(repository.getId())` to handle special
characters in repository IDs
- Appends context to URL before hashing for repository managers
- Matches the exact format written by Resolver 2.x
**Minor suggestion:** The JavaDoc could be enhanced to explain when context
matters (see below).
### 3. **EnhancedLocalRepositoryManagerTest.java:277-287** - Test coverage ✅
Good test for the happy path: artifact tracked with URL-qualified key is
found when ID and URL match.
### 4. **EnhancedLocalRepositoryManagerTest.java:289-297** - Security
validation ✅
Excellent test: ensures that an artifact tracked with a different URL is NOT
accepted, even if the repository ID matches. This prevents incorrectly
accepting artifacts from a different source.
### 5. **EnhancedLocalRepositoryManagerTest.java:301-308** - Context
handling ✅
Properly tests that repository manager context is part of the key hash:
- Artifact tracked with context "test" is found when requesting with same
context
- Same artifact is NOT found when requesting with different context
---
### 📝 Optional Enhancements
**Enhanced JavaDoc for `getUrlQualifiedRepositoryKey`:**
Consider adding more detail about when context matters:
```java
/**
* Returns the key Maven Resolver 2.x writes by default, so that an artifact
downloaded
* by Maven 3.10 or 4 from the same repository is accepted. For a plain
repository this is
* {@code <pathSegment(id)>-<sha1(url)>}; for a repository manager the
context is appended to
* the URL before hashing: {@code <pathSegment(id)>-<sha1(url+context)>}.
*
* <p>The context is significant only for repository managers: the same
repository manager
* with different contexts produces different keys, ensuring artifacts
downloaded in different
* contexts are tracked separately.
*
* <p>Entries are still written with {@link
#getRepositoryKey(RemoteRepository, String)} for
* backward compatibility with other Maven 1.9.x builds.
*
* @param repository the remote repository
* @param context the request context, may be {@code null}
* @return the repository key in Resolver 2.x format
*/
```
---
## Summary
This PR is **production-ready**. The implementation is:
- ✅ Correct (matches Resolver 2.x behavior exactly)
- ✅ Secure (validates URL matches, not just ID)
- ✅ Well-tested (all scenarios covered)
- ✅ Backward compatible (write old, read both)
- ✅ Minimal (read-side only, no behavioral changes)
The only suggestion is an optional JavaDoc enhancement for future
maintainability.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]