Skip to content

Fixes issue #11827 - Maven DI crashes if the file org.apache.maven.api.di.Inject contains empty lines#11830

Merged
slawekjaranowski merged 1 commit intoapache:maven-4.0.xfrom
slawekjaranowski:cp-11828
Mar 24, 2026
Merged

Fixes issue #11827 - Maven DI crashes if the file org.apache.maven.api.di.Inject contains empty lines#11830
slawekjaranowski merged 1 commit intoapache:maven-4.0.xfrom
slawekjaranowski:cp-11828

Conversation

@slawekjaranowski
Copy link
Member

(cherry picked from commit 1867737)


Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

…ven.api.di.Inject contains empty lines

* Fixes issue apache#11827

* Use Java 17 features

* Issue apache#11827 - Trim each read line to avoid related errors

(cherry picked from commit 1867737)
@slawekjaranowski slawekjaranowski added the bug Something isn't working label Mar 24, 2026
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean and correct fix.

The change properly handles empty lines and whitespace in META-INF/maven/org.apache.maven.api.di.Inject service files, which is a common scenario when using Shade plugin's AppendingTransformer to merge these files from multiple JARs.

The .map(String::trim).filter(l -> !l.isEmpty()) pattern follows the same convention as Java's ServiceLoader for parsing service provider configuration files.

Minor note: no unit test was added for discover(), but the fix is defensive and straightforward. A test could be added later if desired.

Claude Code on behalf of Guillaume Nodet

@slawekjaranowski slawekjaranowski merged commit e95fc6e into apache:maven-4.0.x Mar 24, 2026
22 checks passed
@slawekjaranowski slawekjaranowski deleted the cp-11828 branch March 24, 2026 10:59
@github-actions github-actions bot added this to the 4.0.0 milestone Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maven DI crashes if the file org.apache.maven.api.di.Inject contains empty lines

3 participants