gnodet-bot commented on code in PR #13941:
URL: https://github.com/apache/maven/pull/13941#discussion_r4522381471


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/AbstractSession.java:
##########
@@ -170,10 +170,14 @@ private static List<Listener> 
getListeners(RepositorySystemSession session, Look
         return (List<Listener>) 
session.getData().computeIfAbsent(Listener.class, () -> {
             List<Listener> list = new CopyOnWriteArrayList<>();
             if (lookup != null) {
-                for (SpiService spi : lookup.lookupList(SpiService.class)) {
-                    if (spi instanceof Listener listener && 
!list.contains(listener)) {
-                        list.add(listener);
+                try {
+                    for (SpiService spi : lookup.lookupList(SpiService.class)) 
{
+                        if (spi instanceof Listener listener && 
!list.contains(listener)) {
+                            list.add(listener);
+                        }
                     }
+                } catch (LookupException e) {
+                    // ignore if lookup is unavailable in test environments

Review Comment:
   ⚠️ **Silent exception swallow:** `LookupException` is thrown by 
`lookupList()` only for provisioning failures — it already returns an empty 
list when no components are registered. Silently swallowing it hides real DI 
container issues.
   
   At minimum, log at WARN:
   ```suggestion
                   } catch (LookupException e) {
                       // LookupException means a DI provisioning failure, not 
simply "no components found"
                       // (lookupList returns empty list in that case). Log so 
it doesn't silently disappear.
                       
org.slf4j.LoggerFactory.getLogger(AbstractSession.class).warn(
                               "Failed to discover Listener implementations via 
SPI", e);
   ```



##########
api/maven-api-core/src/main/java/org/apache/maven/api/Listener.java:
##########
@@ -48,6 +48,11 @@
  *       {@code META-INF/services/org.apache.maven.api.spi.SpiService}. Maven 
will
  *       discover and register such listeners automatically at session 
initialization.</li>
  * </ul>
+ * <p>
+ * Implementations should handle their own errors. Any {@link 
RuntimeException} thrown by {@link #onEvent(Event)}
+ * is caught and logged at {@code WARN} level by event dispatchers (such as 
{@code EventSpyImpl} for execution events
+ * and {@code MavenRepositoryListener} for repository events) to protect build 
stability and ensure that other

Review Comment:
   ⚠️ **API Javadoc references implementation class names:** `EventSpyImpl` and 
`MavenRepositoryListener` are internal implementation classes from 
`maven-impl`/`maven-core`. Public API Javadoc should not reference 
implementation details — this creates a documentation coupling that is hard to 
maintain if classes are renamed or refactored.
   
   Suggest using generic terms:
   ```suggestion
    * is caught and logged at {@code WARN} level by event dispatchers to 
protect build stability and ensure that other
   ```



-- 
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]

Reply via email to