Skip to content

Commit

Permalink
#6605: Uncaught Exception java.lang.NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmingliang-ms committed Sep 21, 2022
1 parent 95531fd commit d199625
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static void setupMavenModule(final WizardContext wizardContext, @NotNull
RefreshQueue.getInstance().refresh(true, true, () -> {
final String packageName = wizardContext.getUserData(AzureFunctionsConstants.WIZARD_PACKAGE_NAME_KEY);
final MavenProject parentProject = MavenUtils.getMavenProjectByDirectory(project, parentPath);
final MavenProject rootProject = MavenUtils.getRootMavenProject(project, parentProject);
final MavenId mavenId = new MavenId(groupId, artifactId, version);
final VirtualFile pomFile = Optional.ofNullable(vf).map(file -> file.findChild(MavenConstants.POM_XML)).orElse(null);
if (pomFile == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static String getPluginConfiguration(String effectivePomXml, String group
return null;
}

@Nullable
public static MavenProject getRootMavenProject(final Project project, final MavenProject mavenProject) {
if (mavenProject == null) {
return null;
Expand All @@ -108,11 +109,15 @@ public static MavenProject getRootMavenProject(final Project project, final Mave
MavenId parentId = mavenProject.getParentId();
while (parentId != null) {
result = getMavenProjectById(project, parentId);
if (result == null) {
return null;
}
parentId = result.getParentId();
}
return result;
}

@Nullable
public static MavenProject getMavenProjectById(final Project project, final MavenId mavenId) {
return MavenProjectsManager.getInstance(project).getProjects().stream()
.filter(pro -> Objects.equals(pro.getMavenId(), mavenId)).findFirst().orElse(null);
Expand Down

0 comments on commit d199625

Please sign in to comment.