gnodet-bot commented on code in PR #2362:
URL: https://github.com/apache/maven-resolver/pull/2362#discussion_r4665650928
##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java:
##########
@@ -58,6 +58,26 @@ public class EnhancedLocalRepositoryManagerFactory
implements LocalRepositoryMan
public static final String DEFAULT_TRACKING_FILENAME =
"_remote.repositories";
+ /**
+ * Whether tracked release artifacts may be reused regardless of their
recorded remote origin.
+ * If unset, enabled for the stock unsplit local path prefix composer,
unless
+ * {@link
ChainedLocalRepositoryManager#CONFIG_PROP_IGNORE_TAIL_AVAILABILITY} is
explicitly false.
+ * Split layouts and custom prefix composer factories default to
origin-sensitive lookups.
+ * An explicit value overrides this automatic policy. Matching origins
retain repository attribution;
+ * fallback results have no repository assigned. Provenance recording,
snapshots and metadata are unchanged.
+ * Different repositories can serve different bytes for identical
coordinates: enable only when the local
+ * cache is trusted across repository configuration changes. This does not
search other split paths.
+ * The alias {@code aether.enhancedLocalRepository.ignoreAvailability} is
accepted with lower precedence.
+ * Setting this to false does not disable the independent chained
repository tail bypass.
+ *
+ * @configurationSource {@link
RepositorySystemSession#getConfigProperties()}
+ * @configurationType {@link java.lang.Boolean}
+ * @since 2.0.27
+ */
+ public static final String CONFIG_PROP_IGNORE_AVAILABILITY =
CONFIG_PROPS_PREFIX + "ignoreAvailability";
Review Comment:
Missing `DEFAULT_IGNORE_AVAILABILITY` constant and
`@configurationDefaultValue` Javadoc tag.
Every other `CONFIG_PROP_*` in this factory follows the same pattern:
- A `public static final boolean DEFAULT_*` constant
- A `@configurationDefaultValue {@link #DEFAULT_*}` tag in the Javadoc
`CONFIG_PROP_TRACKING_FILENAME`, `CONFIG_PROP_VERIFY_REAL_PATH`, and
`CONFIG_PROP_LEGACY_LOCAL_REPOSITORY` all have both. The new
`CONFIG_PROP_IGNORE_AVAILABILITY` has neither.
Since the effective default is computed dynamically (not a fixed boolean),
you could either:
1. Add `public static final boolean DEFAULT_IGNORE_AVAILABILITY = false;` as
the "unset" baseline and document the auto-override logic in
`@configurationDefaultValue`, or
2. Use `@configurationDefaultValue false` with a note that the actual
default depends on the layout.
The current Javadoc prose already explains the auto policy well — it just
needs the `@configurationDefaultValue` tag so tooling that processes these
annotations doesn't silently omit this property.
##########
src/site/markdown/local-repository.md:
##########
@@ -40,12 +40,29 @@ Enhanced LRM is enhanced with several extra
features, one most notable is scoping cached content by its origin and
context:
if you downloaded an artifact A1 from repository R1
and later initiate build that requires same artifact A1, but repository R1
-is not defined in build, the A1 artifact cached from R1 remote repository
should be handled
-as not present, and needs to be re-downloaded, despite same coordinates.
+is not defined in build, strict origin checking treats the A1 artifact cached
from R1 as not present and requires it to be re-downloaded, despite same
coordinates.
Those two, originating from two different repositories may not be the same
thing.
This is meant to protect users from "bad practice" (artifact coordinates are
unique in ideal world).
+#### Release Availability Policy
+
+The Boolean configuration property `aether.lrm.enhanced.ignoreAvailability`
explicitly overrides whether tracked release artifacts may be reused when their
recorded origin does not match the requested repositories.
+The legacy alias `aether.enhancedLocalRepository.ignoreAvailability` is also
accepted, but the current key wins when both are set.
+Resolver itself does not support Maven-specific aliases for this setting.
+
+When neither key is set, the policy is automatically `true` only with the
stock `DefaultLocalPathPrefixComposerFactory` and split disabled; it is `false`
with custom composer factories or split enabled.
+Explicitly setting `aether.chainedLocalRepository.ignoreTailAvailability` to
`false` also makes this automatic policy `false`, but does not override an
explicitly configured enhanced LRM policy.
+Set `aether.lrm.enhanced.ignoreAvailability=false` to require origin matching
in the enhanced LRM.
+
+When enabled, only tracked releases gain a fallback across an origin mismatch;
matching origins are still attributed normally, while a fallback result has a
`null` repository.
+Artifact registration (`add`) and provenance tracking remain unchanged, and
snapshots and metadata are unaffected.
+Missing files and noncanonical paths are still rejected, and the fallback does
not search other split paths.
+The chained LRM's tail availability bypass remains independent and defaults to
`true`, so strict origin checking across all chain members requires both
`aether.lrm.enhanced.ignoreAvailability=false` and
`aether.chainedLocalRepository.ignoreTailAvailability=false`.
+
+**Warning:** Enabling this fallback changes the trust policy: repositories may
serve different bytes for the same coordinates, and a cached release may now be
reused despite its origin mismatch.
+If you previously changed `aether.lrm.enhanced.trackingFilename` (or its
legacy alias `aether.enhancedLocalRepository.trackingFilename`) to bypass
origin checks, restore the original tracking filename and use the availability
policy instead, keeping the existing provenance records rather than deleting
them.
Review Comment:
Long sentence (34+ words, two coordinated clauses). Consider splitting:
> If you previously changed `aether.lrm.enhanced.trackingFilename` (or its
legacy alias `aether.enhancedLocalRepository.trackingFilename`) to bypass
origin checks, restore the original tracking filename and use the availability
policy instead. This preserves existing provenance records rather than
discarding them.
##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/EnhancedLocalRepositoryManagerFactory.java:
##########
@@ -58,6 +58,26 @@ public class EnhancedLocalRepositoryManagerFactory
implements LocalRepositoryMan
public static final String DEFAULT_TRACKING_FILENAME =
"_remote.repositories";
+ /**
+ * Whether tracked release artifacts may be reused regardless of their
recorded remote origin.
+ * If unset, enabled for the stock unsplit local path prefix composer,
unless
Review Comment:
Passive voice with implicit subject: `"If unset, enabled for the stock
unsplit local path prefix composer"` — enabled *by whom/what*?
Suggestion: `"If unset, defaults to {@code true} for the stock unsplit
{@link DefaultLocalPathPrefixComposerFactory}, unless..."` — makes the subject
explicit and ties to the concrete class name.
--
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]