Skip to content

[maven-4.0.x] DefaultModelBuilder: rethrows wrong exception in XmlReaderException catch #12611

Description

@elharo

DefaultModelBuilder: Rethrows wrong exception in XmlReaderException catch

Found in: maven-4.0.x branch
File: impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java (lines 1576-1583)
Severity: Low

Description

In the nested catch block where strict=false also fails to read the XML, the code rethrows the original exception e rather than the non-strict exception ne:

} catch (XmlReaderException ne) {
    // still unreadable even in non-strict mode, rethrow original error
    throw e;                        // rethrows the original `e`, not `ne`
}

This means the exception thrown doesn't reflect the actual cause of the final failure (the non-strict read attempt). The exception message and stack trace from the rethrown exception match the original strict-mode failure, not the actual final attempt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions