Daemons should not swallow any exception (#969)

The "happy path" should happen without anything thrown, unsure why here runtime ex is rethrown, others swallowed.

Change: just remove the try/catch and make method throw Exception (diff best seen with whitespace ignored).

Fixes #957
Fixes #966
This commit is contained in:
Tamas Cservenak
2024-04-23 10:03:20 +02:00
committed by GitHub
parent 9bafc4b97d
commit a6dbd07ec4
2 changed files with 97 additions and 113 deletions

View File

@@ -717,8 +717,7 @@ public class DaemonMavenCli implements DaemonCli {
} }
private List<CoreExtensionEntry> loadCoreExtensions( private List<CoreExtensionEntry> loadCoreExtensions(
List<CoreExtension> extensions, ClassRealm containerRealm, Set<String> providedArtifacts) { List<CoreExtension> extensions, ClassRealm containerRealm, Set<String> providedArtifacts) throws Exception {
try {
if (extensions.isEmpty()) { if (extensions.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -768,13 +767,6 @@ public class DaemonMavenCli implements DaemonCli {
executionRequestPopulator = null; executionRequestPopulator = null;
container.dispose(); container.dispose();
} }
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
slf4jLogger.warn("Failed to load extensions descriptor {}: {}", extensions, e.getMessage());
}
return Collections.emptyList();
} }
private ClassRealm setupContainerRealm( private ClassRealm setupContainerRealm(

View File

@@ -642,8 +642,7 @@ public class DaemonMavenCli implements DaemonCli {
} }
private List<CoreExtensionEntry> loadCoreExtensions( private List<CoreExtensionEntry> loadCoreExtensions(
List<CoreExtension> extensions, ClassRealm containerRealm, Set<String> providedArtifacts) { List<CoreExtension> extensions, ClassRealm containerRealm, Set<String> providedArtifacts) throws Exception {
try {
if (extensions.isEmpty()) { if (extensions.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -692,13 +691,6 @@ public class DaemonMavenCli implements DaemonCli {
executionRequestPopulator = null; executionRequestPopulator = null;
container.dispose(); container.dispose();
} }
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
slf4jLogger.warn("Failed to load extensions descriptor {}: {}", extensions, e.getMessage());
}
return Collections.emptyList();
} }
private ClassRealm setupContainerRealm( private ClassRealm setupContainerRealm(