Skip to content

Fix loadGlob using OR instead of AND for glob matching#147

Merged
slachiewicz merged 2 commits into
codehaus-plexus:masterfrom
gnodet:fix/loadglob-or-vs-and
May 19, 2026
Merged

Fix loadGlob using OR instead of AND for glob matching#147
slachiewicz merged 2 commits into
codehaus-plexus:masterfrom
gnodet:fix/loadglob-or-vs-and

Conversation

@gnodet
Copy link
Copy Markdown
Member

@gnodet gnodet commented May 19, 2026

Summary

  • Fix loadGlob in ConfigurationParser where || (OR) was used instead of && (AND) for matching files against prefix and suffix patterns
  • The bug was introduced in 4f4cfe6 ("Some automatic code cleanups") where an automated refactoring incorrectly simplified the filter lambda, breaking De Morgan's law
  • This caused glob patterns like maven-*.jar to match all .jar files instead of only those starting with maven-
  • Add regression test for loadGlob glob matching

Impact

On Linux ext4, File.listFiles() returns files in non-deterministic (inode hash) order. Combined with this bug, load maven-*.jar in Maven's m2.conf loads all jars in the lib directory in arbitrary order instead of loading maven-*.jar files first. This causes class collisions when multiple jars contain the same FQCN — for example, PlexusXmlBeanConverter exists in both maven-embedder.jar (Maven's custom version with XmlNode handling) and org.eclipse.sisu.plexus.jar (Sisu's version without it). When Sisu's version wins the race, Maven's lifecycle configuration injection fails.

This is currently breaking all CI on the Apache Maven maven-4.0.x branch (ubuntu-latest, all JDKs) after a GitHub Actions runner image update changed the filesystem layout.

Claude Code on behalf of Guillaume Nodet

The loadGlob method used || (OR) instead of && (AND) when matching
files against prefix and suffix patterns. This caused glob patterns
like "maven-*.jar" to match all files ending with .jar (since every
jar matches the suffix), regardless of the prefix.

This bug was introduced in 4f4cfe6 ("Some automatic code cleanups")
where an automated refactoring incorrectly simplified the filter lambda,
breaking De Morgan's law: the original negated early-returns
(!prefix → false, !suffix → false, else true) are equivalent to
(prefix AND suffix), not (prefix OR suffix).

On Linux ext4, File.listFiles() returns non-deterministic ordering.
Combined with this bug, classloading order becomes unpredictable,
causing class collisions when multiple jars contain the same FQCN
(e.g., PlexusXmlBeanConverter in both maven-embedder and sisu-plexus).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Path.resolve rejects '*' on Windows with InvalidPathException.
Use File constructor instead, which accepts glob characters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit to apache/maven that referenced this pull request May 19, 2026
Classworlds 2.11.0 introduced a bug in ConfigurationParser.loadGlob
where the glob file filter uses || (OR) instead of && (AND), causing
patterns like "maven-*.jar" to match all jars. On Linux ext4, where
File.listFiles() returns non-deterministic ordering, this leads to
unpredictable classloading order and class collisions between
maven-embedder and sisu-plexus (PlexusXmlBeanConverter), breaking
lifecycle configuration injection.

Fix: codehaus-plexus/plexus-classworlds#147

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@cstamas
Copy link
Copy Markdown
Member

cstamas commented May 19, 2026

@slachiewicz pls review, merge and do a release, as right now, 2.10 and 2.11 are two in a row broken releases.

@slachiewicz slachiewicz merged commit 9d5a694 into codehaus-plexus:master May 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants