From c9977dedecad7b10a0ce7b5ad429244bd6da1620 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Thu, 14 Nov 2024 14:43:41 +0100 Subject: [PATCH] simplify error reporting --- .../org/eclipse/edc/boot/system/DependencyGraph.java | 11 ++++++----- .../system/injection/ConfigurationInjectionPoint.java | 6 +++--- .../boot/system/injection/ServiceInjectionPoint.java | 4 ++-- .../boot/system/injection/ValueInjectionPoint.java | 4 ++-- .../eclipse/edc/boot/system/ExtensionLoaderTest.java | 3 +-- .../injection/ConfigurationInjectionPointTest.java | 2 +- .../edc/connector/core/CoreServicesExtension.java | 3 --- .../client/StsRemoteClientConfigurationExtension.java | 6 ------ 8 files changed, 15 insertions(+), 24 deletions(-) diff --git a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/DependencyGraph.java b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/DependencyGraph.java index 3babafbd78..5a7f98a979 100644 --- a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/DependencyGraph.java +++ b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/DependencyGraph.java @@ -26,6 +26,7 @@ import org.eclipse.edc.runtime.metamodel.annotation.Requires; import org.eclipse.edc.spi.system.ServiceExtension; import org.eclipse.edc.spi.system.ServiceExtensionContext; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; @@ -131,7 +132,7 @@ public static DependencyGraph of(ServiceExtensionContext context, List { if (injectionPoint.isRequired()) { unsatisfiedInjectionPoints.computeIfAbsent(injectionPoint.getTargetInstance().getClass(), s -> new ArrayList<>()) - .add(new InjectionFailure(injectionPoint, injectionPoint.getTypeString() + " " + f.getFailureDetail())); + .add(new InjectionFailure(injectionPoint.getTargetInstance(), injectionPoint, f.getFailureDetail())); } }); @@ -225,13 +226,12 @@ public List getProblems() { var dependent = entry.getKey(); var dependencies = entry.getValue(); var missingDependencyList = dependencies.stream().map(injectionFailure -> " --> " + injectionFailure.failureDetail()).toList(); - return "-- %s is missing\n%s".formatted(dependent, String.join("\n", missingDependencyList)); + return "## %s is missing\n%s".formatted(dependent, String.join("\n", missingDependencyList)); }); return messages.toList(); } - private static Stream> getRequiredFeatures(Class clazz) { var requiresAnnotation = clazz.getAnnotation(Requires.class); if (requiresAnnotation != null) { @@ -256,10 +256,11 @@ private static Set> getProvidedFeatures(ServiceExtension ext) { return allProvides; } - private record InjectionFailure(InjectionPoint injectionPoint, String failureDetail) { + private record InjectionFailure(ServiceExtension dependent, InjectionPoint dependency, + @Nullable String failureDetail) { @Override public String toString() { - return "%s %s".formatted(injectionPoint.getTypeString(), failureDetail); + return "%s %s".formatted(dependency.getTypeString(), failureDetail); } } } diff --git a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPoint.java b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPoint.java index ee8a01f56c..12a2053872 100644 --- a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPoint.java +++ b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPoint.java @@ -159,7 +159,7 @@ public Result>> getProviders(Map, List> constructorFilter(List args) { diff --git a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ServiceInjectionPoint.java b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ServiceInjectionPoint.java index 6677620492..0b98e112d2 100644 --- a/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ServiceInjectionPoint.java +++ b/core/common/boot/src/main/java/org/eclipse/edc/boot/system/injection/ServiceInjectionPoint.java @@ -106,7 +106,7 @@ public Result>> getProviders(Map, List>> getProviders(Map, List valueType) { diff --git a/core/common/boot/src/test/java/org/eclipse/edc/boot/system/ExtensionLoaderTest.java b/core/common/boot/src/test/java/org/eclipse/edc/boot/system/ExtensionLoaderTest.java index c415d6371a..fbeaf6ac0c 100644 --- a/core/common/boot/src/test/java/org/eclipse/edc/boot/system/ExtensionLoaderTest.java +++ b/core/common/boot/src/test/java/org/eclipse/edc/boot/system/ExtensionLoaderTest.java @@ -231,8 +231,7 @@ void buildDependencyGraph_dependencyNotSatisfied() { var graph = loader.buildDependencyGraph(context); assertThat(graph.isValid()).isFalse(); - assertThat(graph.getProblems()) - .contains("class org.eclipse.edc.boot.system.ExtensionLoaderTest$DependingExtension --> Service someService of type class org.eclipse.edc.boot.system.ExtensionLoaderTest$SomeObject"); + assertThat(graph.getProblems()).hasSize(1); verify(serviceLocator).loadImplementors(eq(ServiceExtension.class), anyBoolean()); } diff --git a/core/common/boot/src/test/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPointTest.java b/core/common/boot/src/test/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPointTest.java index 9cd7773752..e33aeab9f4 100644 --- a/core/common/boot/src/test/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPointTest.java +++ b/core/common/boot/src/test/java/org/eclipse/edc/boot/system/injection/ConfigurationInjectionPointTest.java @@ -115,6 +115,6 @@ void getProviders_hasViolations() { var result = injectionPoint.getProviders(Map.of(), context); assertThat(result.succeeded()).isFalse(); - assertThat(result.getFailureDetail()).isEqualTo("configurationObject (ConfigurationObject) --> [requiredVal (property \"foo.bar.baz\")]"); + assertThat(result.getFailureDetail()).isEqualTo("Configuration object \"configurationObject\" of type [class org.eclipse.edc.boot.system.testextensions.ConfigurationObject], through nested settings [Configuration value \"requiredVal\" of type [class java.lang.String] (property 'foo.bar.baz')]"); } } \ No newline at end of file diff --git a/core/common/connector-core/src/main/java/org/eclipse/edc/connector/core/CoreServicesExtension.java b/core/common/connector-core/src/main/java/org/eclipse/edc/connector/core/CoreServicesExtension.java index 59d09145a7..3c98660ae9 100644 --- a/core/common/connector-core/src/main/java/org/eclipse/edc/connector/core/CoreServicesExtension.java +++ b/core/common/connector-core/src/main/java/org/eclipse/edc/connector/core/CoreServicesExtension.java @@ -69,9 +69,6 @@ public class CoreServicesExtension implements ServiceExtension { @Setting(description = "Connector hostname, which e.g. is used in referer urls", defaultValue = DEFAULT_EDC_HOSTNAME, key = EDC_HOSTNAME, warnOnMissingConfig = true) public static String hostname; - @Setting(key = "bar.baz") - public static Long barBaz; - @Inject private EventExecutorServiceContainer eventExecutorServiceContainer; diff --git a/extensions/common/iam/identity-trust/identity-trust-sts/identity-trust-sts-remote-client/src/main/java/org/eclipse/edc/iam/identitytrust/sts/remote/client/StsRemoteClientConfigurationExtension.java b/extensions/common/iam/identity-trust/identity-trust-sts/identity-trust-sts-remote-client/src/main/java/org/eclipse/edc/iam/identitytrust/sts/remote/client/StsRemoteClientConfigurationExtension.java index ff0e296269..2c84f9d4f5 100644 --- a/extensions/common/iam/identity-trust/identity-trust-sts/identity-trust-sts-remote-client/src/main/java/org/eclipse/edc/iam/identitytrust/sts/remote/client/StsRemoteClientConfigurationExtension.java +++ b/extensions/common/iam/identity-trust/identity-trust-sts/identity-trust-sts-remote-client/src/main/java/org/eclipse/edc/iam/identitytrust/sts/remote/client/StsRemoteClientConfigurationExtension.java @@ -48,17 +48,11 @@ public StsRemoteClientConfiguration clientConfiguration(ServiceExtensionContext return new StsRemoteClientConfiguration(clientConfig.tokenUrl(), clientConfig.clientId(), clientConfig.clientSecretAlias()); } - @Inject - private FooService fooService; - @Settings private record StsClientConfig( @Setting(key = "edc.iam.sts.oauth.token.url", description = "STS OAuth2 endpoint for requesting a token") String tokenUrl, @Setting(key = "edc.iam.sts.oauth.client.id", description = "STS OAuth2 client id") String clientId, @Setting(key = "edc.iam.sts.oauth.client.secret.alias", description = "Vault alias of STS OAuth2 client secret") String clientSecretAlias) { } - - private class FooService { - } }