Skip to content

Commit

Permalink
Surface original ParseError instead of ClassCastException
Browse files Browse the repository at this point in the history
Fixes #657
  • Loading branch information
timtebeek committed Nov 17, 2023
1 parent 18501f9 commit f6ffdc3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ public Map<MavenProject, Xml.Document> parseMaven(List<MavenProject> mavenProjec
mavenParserBuilder.activeProfiles(activeProfiles.toArray(new String[]{}));
}

List<SourceFile> mavens = mavenParserBuilder
.build()
.parse(allPoms, baseDir, ctx).collect(toList());
List<SourceFile> mavens = mavenParserBuilder.build()
.parse(allPoms, baseDir, ctx)
.collect(toList());

if (logger.isDebugEnabled()) {
logDebug(topLevelProject, "Base directory : '" + baseDir + "'");
Expand All @@ -501,7 +501,11 @@ public Map<MavenProject, Xml.Document> parseMaven(List<MavenProject> mavenProjec
Path path = baseDir.resolve(document.getSourcePath());
MavenProject mavenProject = projectsByPath.get(path);
if (mavenProject != null) {
projectMap.put(mavenProject, (Xml.Document) document);
if (document instanceof Xml.Document) {
projectMap.put(mavenProject, (Xml.Document) document);
} else if (document instanceof ParseError) {
logError(mavenProject, "Parse error in Maven Project File '" + path + "': "+ document);
}
}
}
for (MavenProject mavenProject : mavenProjects) {
Expand Down

0 comments on commit f6ffdc3

Please sign in to comment.