elharo opened a new issue, #559:
URL: https://github.com/apache/maven-jar-plugin/issues/559

   ## Bug
   
   `createArchive()` catches `Exception` in its error handling block, which is 
broader than necessary and can swallow unrelated exceptions.
   
   ## Location
   
   `AbstractJarMojo.java:291-294`:
   
   ```java
   } catch (Exception e) {
       // TODO: improve error handling
       throw new MojoException("Error assembling JAR", e);
   }
   ```
   
   ## Problem
   
   Catching `Exception` will also catch unchecked runtime exceptions (e.g. 
`NullPointerException`, `ArrayIndexOutOfBoundsException`) and even `Throwable` 
subtypes like `Error` (though `Error` is not a subclass of `Exception`). The 
existing `// TODO: improve error handling` comment acknowledges this. Consider 
narrowing the catch clause to the specific exception types thrown by the 
operations in the try block.
   
   ## Suggested fix
   
   Catch `IOException` and `MavenArchiverException` (or other specific 
exception types from the archiver API) instead of the generic `Exception`.


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