Skip to content

Commit 54b2a82

Browse files
hohwillejan-vcapgemini
authored andcommitted
devonfw#1065: fix NPE on upgrade (maven repo access) (devonfw#1072)
Co-authored-by: jan-vcapgemini <[email protected]>
1 parent 8f3c98e commit 54b2a82

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,21 +609,24 @@ default String getMavenArgs() {
609609
*/
610610
default Path getMavenConfigurationFolder() {
611611

612-
if (getIdeHome() != null) {
613-
Path confPath = getConfPath();
614-
Path m2Folder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
615-
if (!Files.isDirectory(m2Folder)) {
612+
Path confPath = getConfPath();
613+
Path mvnConfFolder = null;
614+
if (confPath != null) {
615+
mvnConfFolder = confPath.resolve(Mvn.MVN_CONFIG_FOLDER);
616+
if (!Files.isDirectory(mvnConfFolder)) {
616617
Path m2LegacyFolder = confPath.resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
617618
if (Files.isDirectory(m2LegacyFolder)) {
618-
m2Folder = m2LegacyFolder;
619+
mvnConfFolder = m2LegacyFolder;
619620
} else {
620-
// fallback to USER_HOME/.m2 folder
621-
m2Folder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
621+
mvnConfFolder = null; // see fallback below
622622
}
623623
}
624-
return m2Folder;
625624
}
626-
return null;
625+
if (mvnConfFolder == null) {
626+
// fallback to USER_HOME/.m2 folder
627+
mvnConfFolder = getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER);
628+
}
629+
return mvnConfFolder;
627630
}
628631

629632
/**

0 commit comments

Comments
 (0)