This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new e95fc6e040 Fixes issue #11827 - Maven DI crashes if the file
org.apache.maven.api.di.Inject contains empty lines
e95fc6e040 is described below
commit e95fc6e04060e6f63abf7d95b5f515cb974a3217
Author: Juan Farré <[email protected]>
AuthorDate: Mon Mar 23 21:41:41 2026 +0100
Fixes issue #11827 - Maven DI crashes if the file
org.apache.maven.api.di.Inject contains empty lines
* Fixes issue #11827
* Use Java 17 features
* Issue #11827 - Trim each read line to avoid related errors
(cherry picked from commit 18677376599198838410c51a9cb2e0216b24b375)
---
.../src/main/java/org/apache/maven/di/impl/InjectorImpl.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git
a/impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java
b/impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java
index f2963b911b..e4d2f7d928 100644
--- a/impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java
+++ b/impl/maven-di/src/main/java/org/apache/maven/di/impl/InjectorImpl.java
@@ -99,8 +99,11 @@ public Injector discover(@Nonnull ClassLoader classLoader) {
try (InputStream is = url.openStream();
BufferedReader reader =
new BufferedReader(new
InputStreamReader(Objects.requireNonNull(is)))) {
- for (String line :
- reader.lines().filter(l ->
!l.startsWith("#")).toList()) {
+ for (String line : reader.lines()
+ .map(String::trim)
+ .filter(l -> !l.isEmpty())
+ .filter(l -> !l.startsWith("#"))
+ .toList()) {
Class<?> clazz = classLoader.loadClass(line);
bindImplicit(clazz);
}