Skip to content

Silently swallowed exceptions in ResolveDependenciesMojo.getModuleDescriptor() #1621

@elharo

Description

@elharo

Problem

Two catch blocks in getModuleDescriptor() silently ignore exceptions when extracting module descriptors:

} catch (IOException e) {
    // noop  <-- IOException silently swallowed
}

} catch (ClassNotFoundException | SecurityException | IllegalAccessException | IllegalArgumentException e) {
    // do nothing  <-- Multiple exceptions silently ignored
}

These swallowed exceptions hide errors when reading manifest files or using reflection to access Java 9+ module APIs, making it difficult to diagnose module descriptor extraction failures.

Fix

At minimum, log the exceptions at debug level:

} catch (IOException e) {
    getLog().debug("Failed to read manifest from " + artifactFile + ": " + e.getMessage());
}

} catch (ClassNotFoundException | SecurityException | IllegalAccessException | IllegalArgumentException e) {
    getLog().debug("Failed to extract module descriptor using reflection: " + e.getMessage());
}

File

src/main/java/org/apache/maven/plugins/dependency/resolvers/ResolveDependenciesMojo.java:304-311

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions