Bug
createArchive() catches Exception in its error handling block, which is broader than necessary and can swallow unrelated exceptions.
Location
AbstractJarMojo.java:291-294:
} 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.
Bug
createArchive()catchesExceptionin its error handling block, which is broader than necessary and can swallow unrelated exceptions.Location
AbstractJarMojo.java:291-294:Problem
Catching
Exceptionwill also catch unchecked runtime exceptions (e.g.NullPointerException,ArrayIndexOutOfBoundsException) and evenThrowablesubtypes likeError(thoughErroris not a subclass ofException). The existing// TODO: improve error handlingcomment acknowledges this. Consider narrowing the catch clause to the specific exception types thrown by the operations in the try block.Suggested fix
Catch
IOExceptionandMavenArchiverException(or other specific exception types from the archiver API) instead of the genericException.